]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.10.7-201308181813.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.10.7-201308181813.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..79768fb 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,9 +75,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 +TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56 @@ -80,6 +88,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60 +ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64 @@ -92,19 +101,24 @@ bounds.h
65 bsetup
66 btfixupprep
67 build
68 +builtin-policy.h
69 bvmlinux
70 bzImage*
71 capability_names.h
72 capflags.c
73 classlist.h*
74 +clut_vga16.c
75 +common-cmds.h
76 comp*.log
77 compile.h*
78 conf
79 config
80 config-*
81 config_data.h*
82 +config.c
83 config.mak
84 config.mak.autogen
85 +config.tmp
86 conmakehash
87 consolemap_deftbl.c*
88 cpustr.h
89 @@ -115,9 +129,11 @@ devlist.h*
90 dnotify_test
91 docproc
92 dslm
93 +dtc-lexer.lex.c
94 elf2ecoff
95 elfconfig.h*
96 evergreen_reg_safe.h
97 +exception_policy.conf
98 fixdep
99 flask.h
100 fore200e_mkfirm
101 @@ -125,12 +141,15 @@ fore200e_pca_fw.c*
102 gconf
103 gconf.glade.h
104 gen-devlist
105 +gen-kdb_cmds.c
106 gen_crc32table
107 gen_init_cpio
108 generated
109 genheaders
110 genksyms
111 *_gray256.c
112 +hash
113 +hid-example
114 hpet_example
115 hugepage-mmap
116 hugepage-shm
117 @@ -145,14 +164,14 @@ int32.c
118 int4.c
119 int8.c
120 kallsyms
121 -kconfig
122 +kern_constants.h
123 keywords.c
124 ksym.c*
125 ksym.h*
126 kxgettext
127 lex.c
128 lex.*.c
129 -linux
130 +lib1funcs.S
131 logo_*.c
132 logo_*_clut224.c
133 logo_*_mono.c
134 @@ -162,14 +181,15 @@ mach-types.h
135 machtypes.h
136 map
137 map_hugetlb
138 -media
139 mconf
140 +mdp
141 miboot*
142 mk_elfconfig
143 mkboot
144 mkbugboot
145 mkcpustr
146 mkdep
147 +mkpiggy
148 mkprep
149 mkregtable
150 mktables
151 @@ -185,6 +205,8 @@ oui.c*
152 page-types
153 parse.c
154 parse.h
155 +parse-events*
156 +pasyms.h
157 patches*
158 pca200e.bin
159 pca200e_ecd.bin2
160 @@ -194,6 +216,7 @@ perf-archive
161 piggyback
162 piggy.gzip
163 piggy.S
164 +pmu-*
165 pnmtologo
166 ppc_defs.h*
167 pss_boot.h
168 @@ -203,7 +226,10 @@ r200_reg_safe.h
169 r300_reg_safe.h
170 r420_reg_safe.h
171 r600_reg_safe.h
172 +realmode.lds
173 +realmode.relocs
174 recordmcount
175 +regdb.c
176 relocs
177 rlim_names.h
178 rn50_reg_safe.h
179 @@ -213,8 +239,12 @@ series
180 setup
181 setup.bin
182 setup.elf
183 +signing_key*
184 +size_overflow_hash.h
185 sImage
186 +slabinfo
187 sm_tbl*
188 +sortextable
189 split-include
190 syscalltab.h
191 tables.c
192 @@ -224,6 +254,7 @@ tftpboot.img
193 timeconst.h
194 times.h*
195 trix_boot.h
196 +user_constants.h
197 utsrelease.h*
198 vdso-syms.lds
199 vdso.lds
200 @@ -235,13 +266,17 @@ vdso32.lds
201 vdso32.so.dbg
202 vdso64.lds
203 vdso64.so.dbg
204 +vdsox32.lds
205 +vdsox32-syms.lds
206 version.h*
207 vmImage
208 vmlinux
209 vmlinux-*
210 vmlinux.aout
211 vmlinux.bin.all
212 +vmlinux.bin.bz2
213 vmlinux.lds
214 +vmlinux.relocs
215 vmlinuz
216 voffset.h
217 vsyscall.lds
218 @@ -249,9 +284,12 @@ vsyscall_32.lds
219 wanxlfw.inc
220 uImage
221 unifdef
222 +utsrelease.h
223 wakeup.bin
224 wakeup.elf
225 wakeup.lds
226 +x509*
227 zImage*
228 zconf.hash.c
229 +zconf.lex.c
230 zoffset.h
231 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
232 index 2fe6e76..889ee23 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -976,6 +976,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
236 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
237 Default: 1024
238
239 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
240 + ignore grsecurity's /proc restrictions
241 +
242 +
243 hashdist= [KNL,NUMA] Large hashes allocated during boot
244 are distributed across NUMA nodes. Defaults on
245 for 64-bit NUMA, off otherwise.
246 @@ -1928,6 +1932,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
247 noexec=on: enable non-executable mappings (default)
248 noexec=off: disable non-executable mappings
249
250 + nopcid [X86-64]
251 + Disable PCID (Process-Context IDentifier) even if it
252 + is supported by the processor.
253 +
254 nosmap [X86]
255 Disable SMAP (Supervisor Mode Access Prevention)
256 even if it is supported by processor.
257 @@ -2195,6 +2203,25 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
258 the specified number of seconds. This is to be used if
259 your oopses keep scrolling off the screen.
260
261 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
262 + virtualization environments that don't cope well with the
263 + expand down segment used by UDEREF on X86-32 or the frequent
264 + page table updates on X86-64.
265 +
266 + pax_sanitize_slab=
267 + 0/1 to disable/enable slab object sanitization (enabled by
268 + default).
269 +
270 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
271 +
272 + pax_extra_latent_entropy
273 + Enable a very simple form of latent entropy extraction
274 + from the first 4GB of memory as the bootmem allocator
275 + passes the memory pages to the buddy allocator.
276 +
277 + pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
278 + when the processor supports PCID.
279 +
280 pcbit= [HW,ISDN]
281
282 pcd. [PARIDE]
283 diff --git a/Makefile b/Makefile
284 index 33e36ab..31f1dc8 100644
285 --- a/Makefile
286 +++ b/Makefile
287 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
288
289 HOSTCC = gcc
290 HOSTCXX = g++
291 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
292 -HOSTCXXFLAGS = -O2
293 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
294 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
295 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
296
297 # Decide whether to build built-in, modular, or both.
298 # Normally, just do built-in.
299 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
300 # Rules shared between *config targets and build targets
301
302 # Basic helpers built in scripts/
303 -PHONY += scripts_basic
304 -scripts_basic:
305 +PHONY += scripts_basic gcc-plugins
306 +scripts_basic: gcc-plugins
307 $(Q)$(MAKE) $(build)=scripts/basic
308 $(Q)rm -f .tmp_quiet_recordmcount
309
310 @@ -576,6 +577,65 @@ else
311 KBUILD_CFLAGS += -O2
312 endif
313
314 +ifndef DISABLE_PAX_PLUGINS
315 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
316 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
317 +else
318 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
319 +endif
320 +ifneq ($(PLUGINCC),)
321 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
322 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
323 +endif
324 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
325 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
326 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
327 +endif
328 +ifdef CONFIG_KALLOCSTAT_PLUGIN
329 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
330 +endif
331 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
332 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
333 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
334 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
335 +endif
336 +ifdef CONFIG_CHECKER_PLUGIN
337 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
338 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
339 +endif
340 +endif
341 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
342 +ifdef CONFIG_PAX_SIZE_OVERFLOW
343 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
344 +endif
345 +ifdef CONFIG_PAX_LATENT_ENTROPY
346 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
347 +endif
348 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
349 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
350 +endif
351 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
352 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
353 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
354 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
355 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
356 +ifeq ($(KBUILD_EXTMOD),)
357 +gcc-plugins:
358 + $(Q)$(MAKE) $(build)=tools/gcc
359 +else
360 +gcc-plugins: ;
361 +endif
362 +else
363 +gcc-plugins:
364 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
365 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
366 +else
367 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
368 +endif
369 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
370 +endif
371 +endif
372 +
373 include $(srctree)/arch/$(SRCARCH)/Makefile
374
375 ifdef CONFIG_READABLE_ASM
376 @@ -733,7 +793,7 @@ export mod_sign_cmd
377
378
379 ifeq ($(KBUILD_EXTMOD),)
380 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
381 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
382
383 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
384 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
385 @@ -782,6 +842,8 @@ endif
386
387 # The actual objects are generated when descending,
388 # make sure no implicit rule kicks in
389 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
390 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
391 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
392
393 # Handle descending into subdirectories listed in $(vmlinux-dirs)
394 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
395 # Error messages still appears in the original language
396
397 PHONY += $(vmlinux-dirs)
398 -$(vmlinux-dirs): prepare scripts
399 +$(vmlinux-dirs): gcc-plugins prepare scripts
400 $(Q)$(MAKE) $(build)=$@
401
402 # Store (new) KERNELRELASE string in include/config/kernel.release
403 @@ -835,6 +897,7 @@ prepare0: archprepare FORCE
404 $(Q)$(MAKE) $(build)=.
405
406 # All the preparing..
407 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
408 prepare: prepare0
409
410 # Generate some files
411 @@ -942,6 +1005,8 @@ all: modules
412 # using awk while concatenating to the final file.
413
414 PHONY += modules
415 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
416 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
417 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
418 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
419 @$(kecho) ' Building modules, stage 2.';
420 @@ -957,7 +1022,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
421
422 # Target to prepare building external modules
423 PHONY += modules_prepare
424 -modules_prepare: prepare scripts
425 +modules_prepare: gcc-plugins prepare scripts
426
427 # Target to install modules
428 PHONY += modules_install
429 @@ -1023,7 +1088,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
430 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
431 signing_key.priv signing_key.x509 x509.genkey \
432 extra_certificates signing_key.x509.keyid \
433 - signing_key.x509.signer
434 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
435
436 # clean - Delete most, but leave enough to build external modules
437 #
438 @@ -1063,6 +1128,7 @@ distclean: mrproper
439 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
440 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
441 -o -name '.*.rej' \
442 + -o -name '.*.rej' -o -name '*.so' \
443 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
444 -type f -print | xargs rm -f
445
446 @@ -1223,6 +1289,8 @@ PHONY += $(module-dirs) modules
447 $(module-dirs): crmodverdir $(objtree)/Module.symvers
448 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
449
450 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
451 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
452 modules: $(module-dirs)
453 @$(kecho) ' Building modules, stage 2.';
454 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
455 @@ -1359,17 +1427,21 @@ else
456 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
457 endif
458
459 -%.s: %.c prepare scripts FORCE
460 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 +%.s: %.c gcc-plugins prepare scripts FORCE
463 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
464 %.i: %.c prepare scripts FORCE
465 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
466 -%.o: %.c prepare scripts FORCE
467 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
468 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
469 +%.o: %.c gcc-plugins prepare scripts FORCE
470 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
471 %.lst: %.c prepare scripts FORCE
472 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
473 -%.s: %.S prepare scripts FORCE
474 +%.s: %.S gcc-plugins prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.S prepare scripts FORCE
477 +%.o: %.S gcc-plugins prepare scripts FORCE
478 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
479 %.symtypes: %.c prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 @@ -1379,11 +1451,15 @@ endif
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir)
485 -%/: prepare scripts FORCE
486 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
487 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
488 +%/: gcc-plugins prepare scripts FORCE
489 $(cmd_crmodverdir)
490 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
491 $(build)=$(build-dir)
492 -%.ko: prepare scripts FORCE
493 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
494 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
495 +%.ko: gcc-plugins prepare scripts FORCE
496 $(cmd_crmodverdir)
497 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
498 $(build)=$(build-dir) $(@:.ko=.o)
499 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
500 index c2cbe4f..f7264b4 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
504 #define atomic_dec(v) atomic_sub(1,(v))
505 #define atomic64_dec(v) atomic64_sub(1,(v))
506
507 +#define atomic64_read_unchecked(v) atomic64_read(v)
508 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
509 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
510 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
511 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
512 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
513 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
514 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
515 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
516 +
517 #define smp_mb__before_atomic_dec() smp_mb()
518 #define smp_mb__after_atomic_dec() smp_mb()
519 #define smp_mb__before_atomic_inc() smp_mb()
520 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
521 index ad368a9..fbe0f25 100644
522 --- a/arch/alpha/include/asm/cache.h
523 +++ b/arch/alpha/include/asm/cache.h
524 @@ -4,19 +4,19 @@
525 #ifndef __ARCH_ALPHA_CACHE_H
526 #define __ARCH_ALPHA_CACHE_H
527
528 +#include <linux/const.h>
529
530 /* Bytes per L1 (data) cache line. */
531 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
532 -# define L1_CACHE_BYTES 64
533 # define L1_CACHE_SHIFT 6
534 #else
535 /* Both EV4 and EV5 are write-through, read-allocate,
536 direct-mapped, physical.
537 */
538 -# define L1_CACHE_BYTES 32
539 # define L1_CACHE_SHIFT 5
540 #endif
541
542 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
543 #define SMP_CACHE_BYTES L1_CACHE_BYTES
544
545 #endif
546 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
547 index 968d999..d36b2df 100644
548 --- a/arch/alpha/include/asm/elf.h
549 +++ b/arch/alpha/include/asm/elf.h
550 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
551
552 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
553
554 +#ifdef CONFIG_PAX_ASLR
555 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
556 +
557 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
558 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
559 +#endif
560 +
561 /* $0 is set by ld.so to a pointer to a function which might be
562 registered using atexit. This provides a mean for the dynamic
563 linker to call DT_FINI functions for shared libraries that have
564 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
565 index bc2a0da..8ad11ee 100644
566 --- a/arch/alpha/include/asm/pgalloc.h
567 +++ b/arch/alpha/include/asm/pgalloc.h
568 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
569 pgd_set(pgd, pmd);
570 }
571
572 +static inline void
573 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
574 +{
575 + pgd_populate(mm, pgd, pmd);
576 +}
577 +
578 extern pgd_t *pgd_alloc(struct mm_struct *mm);
579
580 static inline void
581 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
582 index 81a4342..348b927 100644
583 --- a/arch/alpha/include/asm/pgtable.h
584 +++ b/arch/alpha/include/asm/pgtable.h
585 @@ -102,6 +102,17 @@ struct vm_area_struct;
586 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
587 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
588 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
589 +
590 +#ifdef CONFIG_PAX_PAGEEXEC
591 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
592 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
593 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
594 +#else
595 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
596 +# define PAGE_COPY_NOEXEC PAGE_COPY
597 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
598 +#endif
599 +
600 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
601
602 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
603 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
604 index 2fd00b7..cfd5069 100644
605 --- a/arch/alpha/kernel/module.c
606 +++ b/arch/alpha/kernel/module.c
607 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
608
609 /* The small sections were sorted to the end of the segment.
610 The following should definitely cover them. */
611 - gp = (u64)me->module_core + me->core_size - 0x8000;
612 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
613 got = sechdrs[me->arch.gotsecindex].sh_addr;
614
615 for (i = 0; i < n; i++) {
616 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
617 index b9e37ad..44c24e7 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1297,10 +1297,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
621 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
622
623 static unsigned long
624 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
625 - unsigned long limit)
626 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
627 + unsigned long limit, unsigned long flags)
628 {
629 struct vm_unmapped_area_info info;
630 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
631
632 info.flags = 0;
633 info.length = len;
634 @@ -1308,6 +1309,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 info.high_limit = limit;
636 info.align_mask = 0;
637 info.align_offset = 0;
638 + info.threadstack_offset = offset;
639 return vm_unmapped_area(&info);
640 }
641
642 @@ -1340,20 +1342,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
643 merely specific addresses, but regions of memory -- perhaps
644 this feature should be incorporated into all ports? */
645
646 +#ifdef CONFIG_PAX_RANDMMAP
647 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
648 +#endif
649 +
650 if (addr) {
651 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
652 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
653 if (addr != (unsigned long) -ENOMEM)
654 return addr;
655 }
656
657 /* Next, try allocating at TASK_UNMAPPED_BASE. */
658 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
659 - len, limit);
660 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
661 +
662 if (addr != (unsigned long) -ENOMEM)
663 return addr;
664
665 /* Finally, try allocating in low memory. */
666 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
667 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
668
669 return addr;
670 }
671 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
672 index 0c4132d..88f0d53 100644
673 --- a/arch/alpha/mm/fault.c
674 +++ b/arch/alpha/mm/fault.c
675 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
676 __reload_thread(pcb);
677 }
678
679 +#ifdef CONFIG_PAX_PAGEEXEC
680 +/*
681 + * PaX: decide what to do with offenders (regs->pc = fault address)
682 + *
683 + * returns 1 when task should be killed
684 + * 2 when patched PLT trampoline was detected
685 + * 3 when unpatched PLT trampoline was detected
686 + */
687 +static int pax_handle_fetch_fault(struct pt_regs *regs)
688 +{
689 +
690 +#ifdef CONFIG_PAX_EMUPLT
691 + int err;
692 +
693 + do { /* PaX: patched PLT emulation #1 */
694 + unsigned int ldah, ldq, jmp;
695 +
696 + err = get_user(ldah, (unsigned int *)regs->pc);
697 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
698 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
699 +
700 + if (err)
701 + break;
702 +
703 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
704 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
705 + jmp == 0x6BFB0000U)
706 + {
707 + unsigned long r27, addr;
708 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
709 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
710 +
711 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
712 + err = get_user(r27, (unsigned long *)addr);
713 + if (err)
714 + break;
715 +
716 + regs->r27 = r27;
717 + regs->pc = r27;
718 + return 2;
719 + }
720 + } while (0);
721 +
722 + do { /* PaX: patched PLT emulation #2 */
723 + unsigned int ldah, lda, br;
724 +
725 + err = get_user(ldah, (unsigned int *)regs->pc);
726 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
727 + err |= get_user(br, (unsigned int *)(regs->pc+8));
728 +
729 + if (err)
730 + break;
731 +
732 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
733 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
734 + (br & 0xFFE00000U) == 0xC3E00000U)
735 + {
736 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
737 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
738 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
739 +
740 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
741 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + return 2;
743 + }
744 + } while (0);
745 +
746 + do { /* PaX: unpatched PLT emulation */
747 + unsigned int br;
748 +
749 + err = get_user(br, (unsigned int *)regs->pc);
750 +
751 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
752 + unsigned int br2, ldq, nop, jmp;
753 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
754 +
755 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
756 + err = get_user(br2, (unsigned int *)addr);
757 + err |= get_user(ldq, (unsigned int *)(addr+4));
758 + err |= get_user(nop, (unsigned int *)(addr+8));
759 + err |= get_user(jmp, (unsigned int *)(addr+12));
760 + err |= get_user(resolver, (unsigned long *)(addr+16));
761 +
762 + if (err)
763 + break;
764 +
765 + if (br2 == 0xC3600000U &&
766 + ldq == 0xA77B000CU &&
767 + nop == 0x47FF041FU &&
768 + jmp == 0x6B7B0000U)
769 + {
770 + regs->r28 = regs->pc+4;
771 + regs->r27 = addr+16;
772 + regs->pc = resolver;
773 + return 3;
774 + }
775 + }
776 + } while (0);
777 +#endif
778 +
779 + return 1;
780 +}
781 +
782 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
783 +{
784 + unsigned long i;
785 +
786 + printk(KERN_ERR "PAX: bytes at PC: ");
787 + for (i = 0; i < 5; i++) {
788 + unsigned int c;
789 + if (get_user(c, (unsigned int *)pc+i))
790 + printk(KERN_CONT "???????? ");
791 + else
792 + printk(KERN_CONT "%08x ", c);
793 + }
794 + printk("\n");
795 +}
796 +#endif
797
798 /*
799 * This routine handles page faults. It determines the address,
800 @@ -133,8 +251,29 @@ retry:
801 good_area:
802 si_code = SEGV_ACCERR;
803 if (cause < 0) {
804 - if (!(vma->vm_flags & VM_EXEC))
805 + if (!(vma->vm_flags & VM_EXEC)) {
806 +
807 +#ifdef CONFIG_PAX_PAGEEXEC
808 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
809 + goto bad_area;
810 +
811 + up_read(&mm->mmap_sem);
812 + switch (pax_handle_fetch_fault(regs)) {
813 +
814 +#ifdef CONFIG_PAX_EMUPLT
815 + case 2:
816 + case 3:
817 + return;
818 +#endif
819 +
820 + }
821 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
822 + do_group_exit(SIGKILL);
823 +#else
824 goto bad_area;
825 +#endif
826 +
827 + }
828 } else if (!cause) {
829 /* Allow reads even for write-only mappings */
830 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
831 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
832 index 18a9f5e..ca910b7 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1766,7 +1766,7 @@ config ALIGNMENT_TRAP
836
837 config UACCESS_WITH_MEMCPY
838 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
839 - depends on MMU
840 + depends on MMU && !PAX_MEMORY_UDEREF
841 default y if CPU_FEROCEON
842 help
843 Implement faster copy_to_user and clear_user methods for CPU
844 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
845 index da1c77d..2ee6056 100644
846 --- a/arch/arm/include/asm/atomic.h
847 +++ b/arch/arm/include/asm/atomic.h
848 @@ -17,17 +17,35 @@
849 #include <asm/barrier.h>
850 #include <asm/cmpxchg.h>
851
852 +#ifdef CONFIG_GENERIC_ATOMIC64
853 +#include <asm-generic/atomic64.h>
854 +#endif
855 +
856 #define ATOMIC_INIT(i) { (i) }
857
858 #ifdef __KERNEL__
859
860 +#define _ASM_EXTABLE(from, to) \
861 +" .pushsection __ex_table,\"a\"\n"\
862 +" .align 3\n" \
863 +" .long " #from ", " #to"\n" \
864 +" .popsection"
865 +
866 /*
867 * On ARM, ordinary assignment (str instruction) doesn't clear the local
868 * strex/ldrex monitor on some implementations. The reason we can use it for
869 * atomic_set() is the clrex or dummy strex done on every exception return.
870 */
871 #define atomic_read(v) (*(volatile int *)&(v)->counter)
872 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
873 +{
874 + return v->counter;
875 +}
876 #define atomic_set(v,i) (((v)->counter) = (i))
877 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
878 +{
879 + v->counter = i;
880 +}
881
882 #if __LINUX_ARM_ARCH__ >= 6
883
884 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
885 int result;
886
887 __asm__ __volatile__("@ atomic_add\n"
888 +"1: ldrex %1, [%3]\n"
889 +" adds %0, %1, %4\n"
890 +
891 +#ifdef CONFIG_PAX_REFCOUNT
892 +" bvc 3f\n"
893 +"2: bkpt 0xf103\n"
894 +"3:\n"
895 +#endif
896 +
897 +" strex %1, %0, [%3]\n"
898 +" teq %1, #0\n"
899 +" bne 1b"
900 +
901 +#ifdef CONFIG_PAX_REFCOUNT
902 +"\n4:\n"
903 + _ASM_EXTABLE(2b, 4b)
904 +#endif
905 +
906 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
907 + : "r" (&v->counter), "Ir" (i)
908 + : "cc");
909 +}
910 +
911 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
912 +{
913 + unsigned long tmp;
914 + int result;
915 +
916 + __asm__ __volatile__("@ atomic_add_unchecked\n"
917 "1: ldrex %0, [%3]\n"
918 " add %0, %0, %4\n"
919 " strex %1, %0, [%3]\n"
920 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
921 smp_mb();
922
923 __asm__ __volatile__("@ atomic_add_return\n"
924 +"1: ldrex %1, [%3]\n"
925 +" adds %0, %1, %4\n"
926 +
927 +#ifdef CONFIG_PAX_REFCOUNT
928 +" bvc 3f\n"
929 +" mov %0, %1\n"
930 +"2: bkpt 0xf103\n"
931 +"3:\n"
932 +#endif
933 +
934 +" strex %1, %0, [%3]\n"
935 +" teq %1, #0\n"
936 +" bne 1b"
937 +
938 +#ifdef CONFIG_PAX_REFCOUNT
939 +"\n4:\n"
940 + _ASM_EXTABLE(2b, 4b)
941 +#endif
942 +
943 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
944 + : "r" (&v->counter), "Ir" (i)
945 + : "cc");
946 +
947 + smp_mb();
948 +
949 + return result;
950 +}
951 +
952 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
953 +{
954 + unsigned long tmp;
955 + int result;
956 +
957 + smp_mb();
958 +
959 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
960 "1: ldrex %0, [%3]\n"
961 " add %0, %0, %4\n"
962 " strex %1, %0, [%3]\n"
963 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
964 int result;
965
966 __asm__ __volatile__("@ atomic_sub\n"
967 +"1: ldrex %1, [%3]\n"
968 +" subs %0, %1, %4\n"
969 +
970 +#ifdef CONFIG_PAX_REFCOUNT
971 +" bvc 3f\n"
972 +"2: bkpt 0xf103\n"
973 +"3:\n"
974 +#endif
975 +
976 +" strex %1, %0, [%3]\n"
977 +" teq %1, #0\n"
978 +" bne 1b"
979 +
980 +#ifdef CONFIG_PAX_REFCOUNT
981 +"\n4:\n"
982 + _ASM_EXTABLE(2b, 4b)
983 +#endif
984 +
985 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
986 + : "r" (&v->counter), "Ir" (i)
987 + : "cc");
988 +}
989 +
990 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
991 +{
992 + unsigned long tmp;
993 + int result;
994 +
995 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
996 "1: ldrex %0, [%3]\n"
997 " sub %0, %0, %4\n"
998 " strex %1, %0, [%3]\n"
999 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1000 smp_mb();
1001
1002 __asm__ __volatile__("@ atomic_sub_return\n"
1003 -"1: ldrex %0, [%3]\n"
1004 -" sub %0, %0, %4\n"
1005 +"1: ldrex %1, [%3]\n"
1006 +" subs %0, %1, %4\n"
1007 +
1008 +#ifdef CONFIG_PAX_REFCOUNT
1009 +" bvc 3f\n"
1010 +" mov %0, %1\n"
1011 +"2: bkpt 0xf103\n"
1012 +"3:\n"
1013 +#endif
1014 +
1015 " strex %1, %0, [%3]\n"
1016 " teq %1, #0\n"
1017 " bne 1b"
1018 +
1019 +#ifdef CONFIG_PAX_REFCOUNT
1020 +"\n4:\n"
1021 + _ASM_EXTABLE(2b, 4b)
1022 +#endif
1023 +
1024 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1025 : "r" (&v->counter), "Ir" (i)
1026 : "cc");
1027 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1028 return oldval;
1029 }
1030
1031 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1032 +{
1033 + unsigned long oldval, res;
1034 +
1035 + smp_mb();
1036 +
1037 + do {
1038 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1039 + "ldrex %1, [%3]\n"
1040 + "mov %0, #0\n"
1041 + "teq %1, %4\n"
1042 + "strexeq %0, %5, [%3]\n"
1043 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1044 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1045 + : "cc");
1046 + } while (res);
1047 +
1048 + smp_mb();
1049 +
1050 + return oldval;
1051 +}
1052 +
1053 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1054 {
1055 unsigned long tmp, tmp2;
1056 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1057
1058 return val;
1059 }
1060 +
1061 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1062 +{
1063 + return atomic_add_return(i, v);
1064 +}
1065 +
1066 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1067 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1068 +{
1069 + (void) atomic_add_return(i, v);
1070 +}
1071
1072 static inline int atomic_sub_return(int i, atomic_t *v)
1073 {
1074 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1075 return val;
1076 }
1077 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1078 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1079 +{
1080 + (void) atomic_sub_return(i, v);
1081 +}
1082
1083 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1084 {
1085 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1086 return ret;
1087 }
1088
1089 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1090 +{
1091 + return atomic_cmpxchg(v, old, new);
1092 +}
1093 +
1094 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1095 {
1096 unsigned long flags;
1097 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1098 #endif /* __LINUX_ARM_ARCH__ */
1099
1100 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1101 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1102 +{
1103 + return xchg(&v->counter, new);
1104 +}
1105
1106 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1107 {
1108 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1109 }
1110
1111 #define atomic_inc(v) atomic_add(1, v)
1112 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1113 +{
1114 + atomic_add_unchecked(1, v);
1115 +}
1116 #define atomic_dec(v) atomic_sub(1, v)
1117 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1118 +{
1119 + atomic_sub_unchecked(1, v);
1120 +}
1121
1122 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1123 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1124 +{
1125 + return atomic_add_return_unchecked(1, v) == 0;
1126 +}
1127 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1128 #define atomic_inc_return(v) (atomic_add_return(1, v))
1129 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1130 +{
1131 + return atomic_add_return_unchecked(1, v);
1132 +}
1133 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1134 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1135
1136 @@ -241,6 +428,14 @@ typedef struct {
1137 u64 __aligned(8) counter;
1138 } atomic64_t;
1139
1140 +#ifdef CONFIG_PAX_REFCOUNT
1141 +typedef struct {
1142 + u64 __aligned(8) counter;
1143 +} atomic64_unchecked_t;
1144 +#else
1145 +typedef atomic64_t atomic64_unchecked_t;
1146 +#endif
1147 +
1148 #define ATOMIC64_INIT(i) { (i) }
1149
1150 #ifdef CONFIG_ARM_LPAE
1151 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1152 return result;
1153 }
1154
1155 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1156 +{
1157 + u64 result;
1158 +
1159 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1160 +" ldrd %0, %H0, [%1]"
1161 + : "=&r" (result)
1162 + : "r" (&v->counter), "Qo" (v->counter)
1163 + );
1164 +
1165 + return result;
1166 +}
1167 +
1168 static inline void atomic64_set(atomic64_t *v, u64 i)
1169 {
1170 __asm__ __volatile__("@ atomic64_set\n"
1171 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1172 : "r" (&v->counter), "r" (i)
1173 );
1174 }
1175 +
1176 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1177 +{
1178 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1179 +" strd %2, %H2, [%1]"
1180 + : "=Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + );
1183 +}
1184 #else
1185 static inline u64 atomic64_read(const atomic64_t *v)
1186 {
1187 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1188 return result;
1189 }
1190
1191 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1192 +{
1193 + u64 result;
1194 +
1195 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1196 +" ldrexd %0, %H0, [%1]"
1197 + : "=&r" (result)
1198 + : "r" (&v->counter), "Qo" (v->counter)
1199 + );
1200 +
1201 + return result;
1202 +}
1203 +
1204 static inline void atomic64_set(atomic64_t *v, u64 i)
1205 {
1206 u64 tmp;
1207 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1208 : "r" (&v->counter), "r" (i)
1209 : "cc");
1210 }
1211 +
1212 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1213 +{
1214 + u64 tmp;
1215 +
1216 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1217 +"1: ldrexd %0, %H0, [%2]\n"
1218 +" strexd %0, %3, %H3, [%2]\n"
1219 +" teq %0, #0\n"
1220 +" bne 1b"
1221 + : "=&r" (tmp), "=Qo" (v->counter)
1222 + : "r" (&v->counter), "r" (i)
1223 + : "cc");
1224 +}
1225 +
1226 #endif
1227
1228 static inline void atomic64_add(u64 i, atomic64_t *v)
1229 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1230 __asm__ __volatile__("@ atomic64_add\n"
1231 "1: ldrexd %0, %H0, [%3]\n"
1232 " adds %0, %0, %4\n"
1233 +" adcs %H0, %H0, %H4\n"
1234 +
1235 +#ifdef CONFIG_PAX_REFCOUNT
1236 +" bvc 3f\n"
1237 +"2: bkpt 0xf103\n"
1238 +"3:\n"
1239 +#endif
1240 +
1241 +" strexd %1, %0, %H0, [%3]\n"
1242 +" teq %1, #0\n"
1243 +" bne 1b"
1244 +
1245 +#ifdef CONFIG_PAX_REFCOUNT
1246 +"\n4:\n"
1247 + _ASM_EXTABLE(2b, 4b)
1248 +#endif
1249 +
1250 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1251 + : "r" (&v->counter), "r" (i)
1252 + : "cc");
1253 +}
1254 +
1255 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1256 +{
1257 + u64 result;
1258 + unsigned long tmp;
1259 +
1260 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1261 +"1: ldrexd %0, %H0, [%3]\n"
1262 +" adds %0, %0, %4\n"
1263 " adc %H0, %H0, %H4\n"
1264 " strexd %1, %0, %H0, [%3]\n"
1265 " teq %1, #0\n"
1266 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1267
1268 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1269 {
1270 - u64 result;
1271 - unsigned long tmp;
1272 + u64 result, tmp;
1273
1274 smp_mb();
1275
1276 __asm__ __volatile__("@ atomic64_add_return\n"
1277 +"1: ldrexd %1, %H1, [%3]\n"
1278 +" adds %0, %1, %4\n"
1279 +" adcs %H0, %H1, %H4\n"
1280 +
1281 +#ifdef CONFIG_PAX_REFCOUNT
1282 +" bvc 3f\n"
1283 +" mov %0, %1\n"
1284 +" mov %H0, %H1\n"
1285 +"2: bkpt 0xf103\n"
1286 +"3:\n"
1287 +#endif
1288 +
1289 +" strexd %1, %0, %H0, [%3]\n"
1290 +" teq %1, #0\n"
1291 +" bne 1b"
1292 +
1293 +#ifdef CONFIG_PAX_REFCOUNT
1294 +"\n4:\n"
1295 + _ASM_EXTABLE(2b, 4b)
1296 +#endif
1297 +
1298 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1299 + : "r" (&v->counter), "r" (i)
1300 + : "cc");
1301 +
1302 + smp_mb();
1303 +
1304 + return result;
1305 +}
1306 +
1307 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1308 +{
1309 + u64 result;
1310 + unsigned long tmp;
1311 +
1312 + smp_mb();
1313 +
1314 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1315 "1: ldrexd %0, %H0, [%3]\n"
1316 " adds %0, %0, %4\n"
1317 " adc %H0, %H0, %H4\n"
1318 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1319 __asm__ __volatile__("@ atomic64_sub\n"
1320 "1: ldrexd %0, %H0, [%3]\n"
1321 " subs %0, %0, %4\n"
1322 +" sbcs %H0, %H0, %H4\n"
1323 +
1324 +#ifdef CONFIG_PAX_REFCOUNT
1325 +" bvc 3f\n"
1326 +"2: bkpt 0xf103\n"
1327 +"3:\n"
1328 +#endif
1329 +
1330 +" strexd %1, %0, %H0, [%3]\n"
1331 +" teq %1, #0\n"
1332 +" bne 1b"
1333 +
1334 +#ifdef CONFIG_PAX_REFCOUNT
1335 +"\n4:\n"
1336 + _ASM_EXTABLE(2b, 4b)
1337 +#endif
1338 +
1339 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1340 + : "r" (&v->counter), "r" (i)
1341 + : "cc");
1342 +}
1343 +
1344 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1345 +{
1346 + u64 result;
1347 + unsigned long tmp;
1348 +
1349 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1350 +"1: ldrexd %0, %H0, [%3]\n"
1351 +" subs %0, %0, %4\n"
1352 " sbc %H0, %H0, %H4\n"
1353 " strexd %1, %0, %H0, [%3]\n"
1354 " teq %1, #0\n"
1355 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1356
1357 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1358 {
1359 - u64 result;
1360 - unsigned long tmp;
1361 + u64 result, tmp;
1362
1363 smp_mb();
1364
1365 __asm__ __volatile__("@ atomic64_sub_return\n"
1366 -"1: ldrexd %0, %H0, [%3]\n"
1367 -" subs %0, %0, %4\n"
1368 -" sbc %H0, %H0, %H4\n"
1369 +"1: ldrexd %1, %H1, [%3]\n"
1370 +" subs %0, %1, %4\n"
1371 +" sbcs %H0, %H1, %H4\n"
1372 +
1373 +#ifdef CONFIG_PAX_REFCOUNT
1374 +" bvc 3f\n"
1375 +" mov %0, %1\n"
1376 +" mov %H0, %H1\n"
1377 +"2: bkpt 0xf103\n"
1378 +"3:\n"
1379 +#endif
1380 +
1381 " strexd %1, %0, %H0, [%3]\n"
1382 " teq %1, #0\n"
1383 " bne 1b"
1384 +
1385 +#ifdef CONFIG_PAX_REFCOUNT
1386 +"\n4:\n"
1387 + _ASM_EXTABLE(2b, 4b)
1388 +#endif
1389 +
1390 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1391 : "r" (&v->counter), "r" (i)
1392 : "cc");
1393 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1394 return oldval;
1395 }
1396
1397 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1398 +{
1399 + u64 oldval;
1400 + unsigned long res;
1401 +
1402 + smp_mb();
1403 +
1404 + do {
1405 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1406 + "ldrexd %1, %H1, [%3]\n"
1407 + "mov %0, #0\n"
1408 + "teq %1, %4\n"
1409 + "teqeq %H1, %H4\n"
1410 + "strexdeq %0, %5, %H5, [%3]"
1411 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1412 + : "r" (&ptr->counter), "r" (old), "r" (new)
1413 + : "cc");
1414 + } while (res);
1415 +
1416 + smp_mb();
1417 +
1418 + return oldval;
1419 +}
1420 +
1421 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1422 {
1423 u64 result;
1424 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1425
1426 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1427 {
1428 - u64 result;
1429 - unsigned long tmp;
1430 + u64 result, tmp;
1431
1432 smp_mb();
1433
1434 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1435 -"1: ldrexd %0, %H0, [%3]\n"
1436 -" subs %0, %0, #1\n"
1437 -" sbc %H0, %H0, #0\n"
1438 +"1: ldrexd %1, %H1, [%3]\n"
1439 +" subs %0, %1, #1\n"
1440 +" sbcs %H0, %H1, #0\n"
1441 +
1442 +#ifdef CONFIG_PAX_REFCOUNT
1443 +" bvc 3f\n"
1444 +" mov %0, %1\n"
1445 +" mov %H0, %H1\n"
1446 +"2: bkpt 0xf103\n"
1447 +"3:\n"
1448 +#endif
1449 +
1450 " teq %H0, #0\n"
1451 -" bmi 2f\n"
1452 +" bmi 4f\n"
1453 " strexd %1, %0, %H0, [%3]\n"
1454 " teq %1, #0\n"
1455 " bne 1b\n"
1456 -"2:"
1457 +"4:\n"
1458 +
1459 +#ifdef CONFIG_PAX_REFCOUNT
1460 + _ASM_EXTABLE(2b, 4b)
1461 +#endif
1462 +
1463 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1464 : "r" (&v->counter)
1465 : "cc");
1466 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1467 " teq %0, %5\n"
1468 " teqeq %H0, %H5\n"
1469 " moveq %1, #0\n"
1470 -" beq 2f\n"
1471 +" beq 4f\n"
1472 " adds %0, %0, %6\n"
1473 -" adc %H0, %H0, %H6\n"
1474 +" adcs %H0, %H0, %H6\n"
1475 +
1476 +#ifdef CONFIG_PAX_REFCOUNT
1477 +" bvc 3f\n"
1478 +"2: bkpt 0xf103\n"
1479 +"3:\n"
1480 +#endif
1481 +
1482 " strexd %2, %0, %H0, [%4]\n"
1483 " teq %2, #0\n"
1484 " bne 1b\n"
1485 -"2:"
1486 +"4:\n"
1487 +
1488 +#ifdef CONFIG_PAX_REFCOUNT
1489 + _ASM_EXTABLE(2b, 4b)
1490 +#endif
1491 +
1492 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1493 : "r" (&v->counter), "r" (u), "r" (a)
1494 : "cc");
1495 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1496
1497 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1498 #define atomic64_inc(v) atomic64_add(1LL, (v))
1499 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1500 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1501 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1502 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1503 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1504 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1505 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1506 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1507 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1508 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1509 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1510 index 75fe66b..ba3dee4 100644
1511 --- a/arch/arm/include/asm/cache.h
1512 +++ b/arch/arm/include/asm/cache.h
1513 @@ -4,8 +4,10 @@
1514 #ifndef __ASMARM_CACHE_H
1515 #define __ASMARM_CACHE_H
1516
1517 +#include <linux/const.h>
1518 +
1519 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1520 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1521 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1522
1523 /*
1524 * Memory returned by kmalloc() may be used for DMA, so we must make
1525 @@ -24,5 +26,6 @@
1526 #endif
1527
1528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1529 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1530
1531 #endif
1532 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1533 index 17d0ae8..014e350 100644
1534 --- a/arch/arm/include/asm/cacheflush.h
1535 +++ b/arch/arm/include/asm/cacheflush.h
1536 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1537 void (*dma_unmap_area)(const void *, size_t, int);
1538
1539 void (*dma_flush_range)(const void *, const void *);
1540 -};
1541 +} __no_const;
1542
1543 /*
1544 * Select the calling method
1545 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1546 index 6dcc164..b14d917 100644
1547 --- a/arch/arm/include/asm/checksum.h
1548 +++ b/arch/arm/include/asm/checksum.h
1549 @@ -37,7 +37,19 @@ __wsum
1550 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1551
1552 __wsum
1553 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1554 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1555 +
1556 +static inline __wsum
1557 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1558 +{
1559 + __wsum ret;
1560 + pax_open_userland();
1561 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1562 + pax_close_userland();
1563 + return ret;
1564 +}
1565 +
1566 +
1567
1568 /*
1569 * Fold a partial checksum without adding pseudo headers
1570 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1571 index 4f009c1..466c59b 100644
1572 --- a/arch/arm/include/asm/cmpxchg.h
1573 +++ b/arch/arm/include/asm/cmpxchg.h
1574 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1575
1576 #define xchg(ptr,x) \
1577 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1578 +#define xchg_unchecked(ptr,x) \
1579 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1580
1581 #include <asm-generic/cmpxchg-local.h>
1582
1583 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1584 index 6ddbe44..b5e38b1 100644
1585 --- a/arch/arm/include/asm/domain.h
1586 +++ b/arch/arm/include/asm/domain.h
1587 @@ -48,18 +48,37 @@
1588 * Domain types
1589 */
1590 #define DOMAIN_NOACCESS 0
1591 -#define DOMAIN_CLIENT 1
1592 #ifdef CONFIG_CPU_USE_DOMAINS
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_KERNELCLIENT 1
1595 #define DOMAIN_MANAGER 3
1596 +#define DOMAIN_VECTORS DOMAIN_USER
1597 #else
1598 +
1599 +#ifdef CONFIG_PAX_KERNEXEC
1600 #define DOMAIN_MANAGER 1
1601 +#define DOMAIN_KERNEXEC 3
1602 +#else
1603 +#define DOMAIN_MANAGER 1
1604 +#endif
1605 +
1606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1607 +#define DOMAIN_USERCLIENT 0
1608 +#define DOMAIN_UDEREF 1
1609 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1610 +#else
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_VECTORS DOMAIN_USER
1613 +#endif
1614 +#define DOMAIN_KERNELCLIENT 1
1615 +
1616 #endif
1617
1618 #define domain_val(dom,type) ((type) << (2*(dom)))
1619
1620 #ifndef __ASSEMBLY__
1621
1622 -#ifdef CONFIG_CPU_USE_DOMAINS
1623 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1624 static inline void set_domain(unsigned val)
1625 {
1626 asm volatile(
1627 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1628 isb();
1629 }
1630
1631 -#define modify_domain(dom,type) \
1632 - do { \
1633 - struct thread_info *thread = current_thread_info(); \
1634 - unsigned int domain = thread->cpu_domain; \
1635 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1636 - thread->cpu_domain = domain | domain_val(dom, type); \
1637 - set_domain(thread->cpu_domain); \
1638 - } while (0)
1639 -
1640 +extern void modify_domain(unsigned int dom, unsigned int type);
1641 #else
1642 static inline void set_domain(unsigned val) { }
1643 static inline void modify_domain(unsigned dom, unsigned type) { }
1644 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1645 index 56211f2..17e8a25 100644
1646 --- a/arch/arm/include/asm/elf.h
1647 +++ b/arch/arm/include/asm/elf.h
1648 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1649 the loader. We need to make sure that it is out of the way of the program
1650 that it will "exec", and that there is sufficient room for the brk. */
1651
1652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1654 +
1655 +#ifdef CONFIG_PAX_ASLR
1656 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1657 +
1658 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1659 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1660 +#endif
1661
1662 /* When the program starts, a1 contains a pointer to a function to be
1663 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1664 @@ -126,10 +133,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1665 extern void elf_set_personality(const struct elf32_hdr *);
1666 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1667
1668 -struct mm_struct;
1669 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1670 -#define arch_randomize_brk arch_randomize_brk
1671 -
1672 #ifdef CONFIG_MMU
1673 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1674 struct linux_binprm;
1675 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1676 index de53547..52b9a28 100644
1677 --- a/arch/arm/include/asm/fncpy.h
1678 +++ b/arch/arm/include/asm/fncpy.h
1679 @@ -81,7 +81,9 @@
1680 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1681 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1682 \
1683 + pax_open_kernel(); \
1684 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1685 + pax_close_kernel(); \
1686 flush_icache_range((unsigned long)(dest_buf), \
1687 (unsigned long)(dest_buf) + (size)); \
1688 \
1689 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1690 index e42cf59..7b94b8f 100644
1691 --- a/arch/arm/include/asm/futex.h
1692 +++ b/arch/arm/include/asm/futex.h
1693 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1694 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1695 return -EFAULT;
1696
1697 + pax_open_userland();
1698 +
1699 smp_mb();
1700 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1701 "1: ldrex %1, [%4]\n"
1702 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1703 : "cc", "memory");
1704 smp_mb();
1705
1706 + pax_close_userland();
1707 +
1708 *uval = val;
1709 return ret;
1710 }
1711 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1718 "1: " TUSER(ldr) " %1, [%4]\n"
1719 " teq %1, %2\n"
1720 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1722 : "cc", "memory");
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1730 return -EFAULT;
1731
1732 pagefault_disable(); /* implies preempt_disable() */
1733 + pax_open_userland();
1734
1735 switch (op) {
1736 case FUTEX_OP_SET:
1737 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 ret = -ENOSYS;
1739 }
1740
1741 + pax_close_userland();
1742 pagefault_enable(); /* subsumes preempt_enable() */
1743
1744 if (!ret) {
1745 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1746 index 83eb2f7..ed77159 100644
1747 --- a/arch/arm/include/asm/kmap_types.h
1748 +++ b/arch/arm/include/asm/kmap_types.h
1749 @@ -4,6 +4,6 @@
1750 /*
1751 * This is the "bare minimum". AIO seems to require this.
1752 */
1753 -#define KM_TYPE_NR 16
1754 +#define KM_TYPE_NR 17
1755
1756 #endif
1757 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1758 index 9e614a1..3302cca 100644
1759 --- a/arch/arm/include/asm/mach/dma.h
1760 +++ b/arch/arm/include/asm/mach/dma.h
1761 @@ -22,7 +22,7 @@ struct dma_ops {
1762 int (*residue)(unsigned int, dma_t *); /* optional */
1763 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1764 const char *type;
1765 -};
1766 +} __do_const;
1767
1768 struct dma_struct {
1769 void *addr; /* single DMA address */
1770 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1771 index 2fe141f..192dc01 100644
1772 --- a/arch/arm/include/asm/mach/map.h
1773 +++ b/arch/arm/include/asm/mach/map.h
1774 @@ -27,13 +27,16 @@ struct map_desc {
1775 #define MT_MINICLEAN 6
1776 #define MT_LOW_VECTORS 7
1777 #define MT_HIGH_VECTORS 8
1778 -#define MT_MEMORY 9
1779 +#define MT_MEMORY_RWX 9
1780 #define MT_ROM 10
1781 -#define MT_MEMORY_NONCACHED 11
1782 +#define MT_MEMORY_NONCACHED_RX 11
1783 #define MT_MEMORY_DTCM 12
1784 #define MT_MEMORY_ITCM 13
1785 #define MT_MEMORY_SO 14
1786 #define MT_MEMORY_DMA_READY 15
1787 +#define MT_MEMORY_RW 16
1788 +#define MT_MEMORY_RX 17
1789 +#define MT_MEMORY_NONCACHED_RW 18
1790
1791 #ifdef CONFIG_MMU
1792 extern void iotable_init(struct map_desc *, int);
1793 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1794 index 12f71a1..04e063c 100644
1795 --- a/arch/arm/include/asm/outercache.h
1796 +++ b/arch/arm/include/asm/outercache.h
1797 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1798 #endif
1799 void (*set_debug)(unsigned long);
1800 void (*resume)(void);
1801 -};
1802 +} __no_const;
1803
1804 #ifdef CONFIG_OUTER_CACHE
1805
1806 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1807 index cbdc7a2..32f44fe 100644
1808 --- a/arch/arm/include/asm/page.h
1809 +++ b/arch/arm/include/asm/page.h
1810 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1811 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1812 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1813 unsigned long vaddr, struct vm_area_struct *vma);
1814 -};
1815 +} __no_const;
1816
1817 #ifdef MULTI_USER
1818 extern struct cpu_user_fns cpu_user;
1819 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1820 index 943504f..c37a730 100644
1821 --- a/arch/arm/include/asm/pgalloc.h
1822 +++ b/arch/arm/include/asm/pgalloc.h
1823 @@ -17,6 +17,7 @@
1824 #include <asm/processor.h>
1825 #include <asm/cacheflush.h>
1826 #include <asm/tlbflush.h>
1827 +#include <asm/system_info.h>
1828
1829 #define check_pgt_cache() do { } while (0)
1830
1831 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1832 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1833 }
1834
1835 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1836 +{
1837 + pud_populate(mm, pud, pmd);
1838 +}
1839 +
1840 #else /* !CONFIG_ARM_LPAE */
1841
1842 /*
1843 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1845 #define pmd_free(mm, pmd) do { } while (0)
1846 #define pud_populate(mm,pmd,pte) BUG()
1847 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1848
1849 #endif /* CONFIG_ARM_LPAE */
1850
1851 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1852 __free_page(pte);
1853 }
1854
1855 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1856 +{
1857 +#ifdef CONFIG_ARM_LPAE
1858 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1859 +#else
1860 + if (addr & SECTION_SIZE)
1861 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1862 + else
1863 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1864 +#endif
1865 + flush_pmd_entry(pmdp);
1866 +}
1867 +
1868 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1869 pmdval_t prot)
1870 {
1871 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1872 static inline void
1873 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1874 {
1875 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1876 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1877 }
1878 #define pmd_pgtable(pmd) pmd_page(pmd)
1879
1880 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1881 index 5cfba15..f415e1a 100644
1882 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1883 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 @@ -20,12 +20,15 @@
1885 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1886 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1887 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1888 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1889 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1890 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1891 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1892 +
1893 /*
1894 * - section
1895 */
1896 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1897 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1898 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1899 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1900 @@ -37,6 +40,7 @@
1901 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1902 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1903 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1904 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1905
1906 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1907 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1908 @@ -66,6 +70,7 @@
1909 * - extended small page/tiny page
1910 */
1911 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1912 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1913 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1914 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1915 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1916 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1917 index f97ee02..cc9fe9e 100644
1918 --- a/arch/arm/include/asm/pgtable-2level.h
1919 +++ b/arch/arm/include/asm/pgtable-2level.h
1920 @@ -126,6 +126,9 @@
1921 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1922 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1923
1924 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1925 +#define L_PTE_PXN (_AT(pteval_t, 0))
1926 +
1927 /*
1928 * These are the memory types, defined to be compatible with
1929 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1930 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1931 index 18f5cef..25b8f43 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -41,6 +41,7 @@
1935 */
1936 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1937 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1938 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1939 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1940 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1941 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1942 @@ -71,6 +72,7 @@
1943 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1944 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1945 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1946 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1947 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1948
1949 /*
1950 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1951 index 86b8fe3..e25f975 100644
1952 --- a/arch/arm/include/asm/pgtable-3level.h
1953 +++ b/arch/arm/include/asm/pgtable-3level.h
1954 @@ -74,6 +74,7 @@
1955 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1956 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1957 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1958 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1959 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1960 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1961 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1962 @@ -82,6 +83,7 @@
1963 /*
1964 * To be used in assembly code with the upper page attributes.
1965 */
1966 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1967 #define L_PTE_XN_HIGH (1 << (54 - 32))
1968 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1969
1970 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1971 index 9bcd262..fba731c 100644
1972 --- a/arch/arm/include/asm/pgtable.h
1973 +++ b/arch/arm/include/asm/pgtable.h
1974 @@ -30,6 +30,9 @@
1975 #include <asm/pgtable-2level.h>
1976 #endif
1977
1978 +#define ktla_ktva(addr) (addr)
1979 +#define ktva_ktla(addr) (addr)
1980 +
1981 /*
1982 * Just any arbitrary offset to the start of the vmalloc VM area: the
1983 * current 8MB value just means that there will be a 8MB "hole" after the
1984 @@ -45,6 +48,9 @@
1985 #define LIBRARY_TEXT_START 0x0c000000
1986
1987 #ifndef __ASSEMBLY__
1988 +extern pteval_t __supported_pte_mask;
1989 +extern pmdval_t __supported_pmd_mask;
1990 +
1991 extern void __pte_error(const char *file, int line, pte_t);
1992 extern void __pmd_error(const char *file, int line, pmd_t);
1993 extern void __pgd_error(const char *file, int line, pgd_t);
1994 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1995 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1996 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1997
1998 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1999 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2000 +
2001 +#ifdef CONFIG_PAX_KERNEXEC
2002 +#include <asm/domain.h>
2003 +#include <linux/thread_info.h>
2004 +#include <linux/preempt.h>
2005 +#endif
2006 +
2007 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2008 +static inline int test_domain(int domain, int domaintype)
2009 +{
2010 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2011 +}
2012 +#endif
2013 +
2014 +#ifdef CONFIG_PAX_KERNEXEC
2015 +static inline unsigned long pax_open_kernel(void) {
2016 +#ifdef CONFIG_ARM_LPAE
2017 + /* TODO */
2018 +#else
2019 + preempt_disable();
2020 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2021 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2022 +#endif
2023 + return 0;
2024 +}
2025 +
2026 +static inline unsigned long pax_close_kernel(void) {
2027 +#ifdef CONFIG_ARM_LPAE
2028 + /* TODO */
2029 +#else
2030 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2031 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2032 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2033 + preempt_enable_no_resched();
2034 +#endif
2035 + return 0;
2036 +}
2037 +#else
2038 +static inline unsigned long pax_open_kernel(void) { return 0; }
2039 +static inline unsigned long pax_close_kernel(void) { return 0; }
2040 +#endif
2041 +
2042 /*
2043 * This is the lowest virtual address we can permit any user space
2044 * mapping to be mapped at. This is particularly important for
2045 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2046 /*
2047 * The pgprot_* and protection_map entries will be fixed up in runtime
2048 * to include the cachable and bufferable bits based on memory policy,
2049 - * as well as any architecture dependent bits like global/ASID and SMP
2050 - * shared mapping bits.
2051 + * as well as any architecture dependent bits like global/ASID, PXN,
2052 + * and SMP shared mapping bits.
2053 */
2054 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2055
2056 @@ -257,7 +307,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2057 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2058 {
2059 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2060 - L_PTE_NONE | L_PTE_VALID;
2061 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2062 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2063 return pte;
2064 }
2065 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2066 index f3628fb..a0672dd 100644
2067 --- a/arch/arm/include/asm/proc-fns.h
2068 +++ b/arch/arm/include/asm/proc-fns.h
2069 @@ -75,7 +75,7 @@ extern struct processor {
2070 unsigned int suspend_size;
2071 void (*do_suspend)(void *);
2072 void (*do_resume)(void *);
2073 -} processor;
2074 +} __do_const processor;
2075
2076 #ifndef MULTI_CPU
2077 extern void cpu_proc_init(void);
2078 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2079 index ce0dbe7..c085b6f 100644
2080 --- a/arch/arm/include/asm/psci.h
2081 +++ b/arch/arm/include/asm/psci.h
2082 @@ -29,7 +29,7 @@ struct psci_operations {
2083 int (*cpu_off)(struct psci_power_state state);
2084 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2085 int (*migrate)(unsigned long cpuid);
2086 -};
2087 +} __no_const;
2088
2089 extern struct psci_operations psci_ops;
2090
2091 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2092 index d3a22be..3a69ad5 100644
2093 --- a/arch/arm/include/asm/smp.h
2094 +++ b/arch/arm/include/asm/smp.h
2095 @@ -107,7 +107,7 @@ struct smp_operations {
2096 int (*cpu_disable)(unsigned int cpu);
2097 #endif
2098 #endif
2099 -};
2100 +} __no_const;
2101
2102 /*
2103 * set platform specific SMP operations
2104 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2105 index f00b569..aa5bb41 100644
2106 --- a/arch/arm/include/asm/thread_info.h
2107 +++ b/arch/arm/include/asm/thread_info.h
2108 @@ -77,9 +77,9 @@ struct thread_info {
2109 .flags = 0, \
2110 .preempt_count = INIT_PREEMPT_COUNT, \
2111 .addr_limit = KERNEL_DS, \
2112 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2113 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2114 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2115 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2116 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2117 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2118 .restart_block = { \
2119 .fn = do_no_restart_syscall, \
2120 }, \
2121 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2122 #define TIF_SYSCALL_AUDIT 9
2123 #define TIF_SYSCALL_TRACEPOINT 10
2124 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2125 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2126 +/* within 8 bits of TIF_SYSCALL_TRACE
2127 + * to meet flexible second operand requirements
2128 + */
2129 +#define TIF_GRSEC_SETXID 12
2130 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2131 #define TIF_USING_IWMMXT 17
2132 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2133 #define TIF_RESTORE_SIGMASK 20
2134 @@ -165,10 +169,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2135 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2136 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2137 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2138 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2139
2140 /* Checks for any syscall work in entry-common.S */
2141 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2142 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2143 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2144
2145 /*
2146 * Change these and you break ASM code in entry-common.S
2147 diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h
2148 index bdf2b84..aa9b4ac 100644
2149 --- a/arch/arm/include/asm/tlb.h
2150 +++ b/arch/arm/include/asm/tlb.h
2151 @@ -43,6 +43,7 @@ struct mmu_gather {
2152 struct mm_struct *mm;
2153 unsigned int fullmm;
2154 struct vm_area_struct *vma;
2155 + unsigned long start, end;
2156 unsigned long range_start;
2157 unsigned long range_end;
2158 unsigned int nr;
2159 @@ -107,10 +108,12 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb)
2160 }
2161
2162 static inline void
2163 -tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int fullmm)
2164 +tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
2165 {
2166 tlb->mm = mm;
2167 - tlb->fullmm = fullmm;
2168 + tlb->fullmm = !(start | (end+1));
2169 + tlb->start = start;
2170 + tlb->end = end;
2171 tlb->vma = NULL;
2172 tlb->max = ARRAY_SIZE(tlb->local);
2173 tlb->pages = tlb->local;
2174 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2175 index 7e1f760..de33b13 100644
2176 --- a/arch/arm/include/asm/uaccess.h
2177 +++ b/arch/arm/include/asm/uaccess.h
2178 @@ -18,6 +18,7 @@
2179 #include <asm/domain.h>
2180 #include <asm/unified.h>
2181 #include <asm/compiler.h>
2182 +#include <asm/pgtable.h>
2183
2184 #define VERIFY_READ 0
2185 #define VERIFY_WRITE 1
2186 @@ -63,11 +64,38 @@ extern int __put_user_bad(void);
2187 static inline void set_fs(mm_segment_t fs)
2188 {
2189 current_thread_info()->addr_limit = fs;
2190 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2191 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2192 }
2193
2194 #define segment_eq(a,b) ((a) == (b))
2195
2196 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2197 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2198 +
2199 +static inline void pax_open_userland(void)
2200 +{
2201 +
2202 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2203 + if (segment_eq(get_fs(), USER_DS)) {
2204 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2205 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2206 + }
2207 +#endif
2208 +
2209 +}
2210 +
2211 +static inline void pax_close_userland(void)
2212 +{
2213 +
2214 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2215 + if (segment_eq(get_fs(), USER_DS)) {
2216 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2217 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2218 + }
2219 +#endif
2220 +
2221 +}
2222 +
2223 #define __addr_ok(addr) ({ \
2224 unsigned long flag; \
2225 __asm__("cmp %2, %0; movlo %0, #0" \
2226 @@ -143,8 +171,12 @@ extern int __get_user_4(void *);
2227
2228 #define get_user(x,p) \
2229 ({ \
2230 + int __e; \
2231 might_fault(); \
2232 - __get_user_check(x,p); \
2233 + pax_open_userland(); \
2234 + __e = __get_user_check(x,p); \
2235 + pax_close_userland(); \
2236 + __e; \
2237 })
2238
2239 extern int __put_user_1(void *, unsigned int);
2240 @@ -188,8 +220,12 @@ extern int __put_user_8(void *, unsigned long long);
2241
2242 #define put_user(x,p) \
2243 ({ \
2244 + int __e; \
2245 might_fault(); \
2246 - __put_user_check(x,p); \
2247 + pax_open_userland(); \
2248 + __e = __put_user_check(x,p); \
2249 + pax_close_userland(); \
2250 + __e; \
2251 })
2252
2253 #else /* CONFIG_MMU */
2254 @@ -230,13 +266,17 @@ static inline void set_fs(mm_segment_t fs)
2255 #define __get_user(x,ptr) \
2256 ({ \
2257 long __gu_err = 0; \
2258 + pax_open_userland(); \
2259 __get_user_err((x),(ptr),__gu_err); \
2260 + pax_close_userland(); \
2261 __gu_err; \
2262 })
2263
2264 #define __get_user_error(x,ptr,err) \
2265 ({ \
2266 + pax_open_userland(); \
2267 __get_user_err((x),(ptr),err); \
2268 + pax_close_userland(); \
2269 (void) 0; \
2270 })
2271
2272 @@ -312,13 +352,17 @@ do { \
2273 #define __put_user(x,ptr) \
2274 ({ \
2275 long __pu_err = 0; \
2276 + pax_open_userland(); \
2277 __put_user_err((x),(ptr),__pu_err); \
2278 + pax_close_userland(); \
2279 __pu_err; \
2280 })
2281
2282 #define __put_user_error(x,ptr,err) \
2283 ({ \
2284 + pax_open_userland(); \
2285 __put_user_err((x),(ptr),err); \
2286 + pax_close_userland(); \
2287 (void) 0; \
2288 })
2289
2290 @@ -418,11 +462,44 @@ do { \
2291
2292
2293 #ifdef CONFIG_MMU
2294 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2295 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2296 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2297 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2298 +
2299 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2300 +{
2301 + unsigned long ret;
2302 +
2303 + check_object_size(to, n, false);
2304 + pax_open_userland();
2305 + ret = ___copy_from_user(to, from, n);
2306 + pax_close_userland();
2307 + return ret;
2308 +}
2309 +
2310 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2311 +{
2312 + unsigned long ret;
2313 +
2314 + check_object_size(from, n, true);
2315 + pax_open_userland();
2316 + ret = ___copy_to_user(to, from, n);
2317 + pax_close_userland();
2318 + return ret;
2319 +}
2320 +
2321 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2322 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2323 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2324 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2325 +
2326 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2327 +{
2328 + unsigned long ret;
2329 + pax_open_userland();
2330 + ret = ___clear_user(addr, n);
2331 + pax_close_userland();
2332 + return ret;
2333 +}
2334 +
2335 #else
2336 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2337 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2338 @@ -431,6 +508,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2339
2340 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2341 {
2342 + if ((long)n < 0)
2343 + return n;
2344 +
2345 if (access_ok(VERIFY_READ, from, n))
2346 n = __copy_from_user(to, from, n);
2347 else /* security hole - plug it */
2348 @@ -440,6 +520,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2349
2350 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2351 {
2352 + if ((long)n < 0)
2353 + return n;
2354 +
2355 if (access_ok(VERIFY_WRITE, to, n))
2356 n = __copy_to_user(to, from, n);
2357 return n;
2358 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2359 index 96ee092..37f1844 100644
2360 --- a/arch/arm/include/uapi/asm/ptrace.h
2361 +++ b/arch/arm/include/uapi/asm/ptrace.h
2362 @@ -73,7 +73,7 @@
2363 * ARMv7 groups of PSR bits
2364 */
2365 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2366 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2367 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2368 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2369 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2370
2371 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2372 index 60d3b73..e5a0f22 100644
2373 --- a/arch/arm/kernel/armksyms.c
2374 +++ b/arch/arm/kernel/armksyms.c
2375 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2376
2377 /* networking */
2378 EXPORT_SYMBOL(csum_partial);
2379 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2380 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2381 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2382 EXPORT_SYMBOL(__csum_ipv6_magic);
2383
2384 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2385 #ifdef CONFIG_MMU
2386 EXPORT_SYMBOL(copy_page);
2387
2388 -EXPORT_SYMBOL(__copy_from_user);
2389 -EXPORT_SYMBOL(__copy_to_user);
2390 -EXPORT_SYMBOL(__clear_user);
2391 +EXPORT_SYMBOL(___copy_from_user);
2392 +EXPORT_SYMBOL(___copy_to_user);
2393 +EXPORT_SYMBOL(___clear_user);
2394
2395 EXPORT_SYMBOL(__get_user_1);
2396 EXPORT_SYMBOL(__get_user_2);
2397 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2398 index d43c7e5..257c050 100644
2399 --- a/arch/arm/kernel/entry-armv.S
2400 +++ b/arch/arm/kernel/entry-armv.S
2401 @@ -47,6 +47,87 @@
2402 9997:
2403 .endm
2404
2405 + .macro pax_enter_kernel
2406 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2407 + @ make aligned space for saved DACR
2408 + sub sp, sp, #8
2409 + @ save regs
2410 + stmdb sp!, {r1, r2}
2411 + @ read DACR from cpu_domain into r1
2412 + mov r2, sp
2413 + @ assume 8K pages, since we have to split the immediate in two
2414 + bic r2, r2, #(0x1fc0)
2415 + bic r2, r2, #(0x3f)
2416 + ldr r1, [r2, #TI_CPU_DOMAIN]
2417 + @ store old DACR on stack
2418 + str r1, [sp, #8]
2419 +#ifdef CONFIG_PAX_KERNEXEC
2420 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2421 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2422 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2423 +#endif
2424 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2425 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2426 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2427 +#endif
2428 + @ write r1 to current_thread_info()->cpu_domain
2429 + str r1, [r2, #TI_CPU_DOMAIN]
2430 + @ write r1 to DACR
2431 + mcr p15, 0, r1, c3, c0, 0
2432 + @ instruction sync
2433 + instr_sync
2434 + @ restore regs
2435 + ldmia sp!, {r1, r2}
2436 +#endif
2437 + .endm
2438 +
2439 + .macro pax_open_userland
2440 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2441 + @ save regs
2442 + stmdb sp!, {r0, r1}
2443 + @ read DACR from cpu_domain into r1
2444 + mov r0, sp
2445 + @ assume 8K pages, since we have to split the immediate in two
2446 + bic r0, r0, #(0x1fc0)
2447 + bic r0, r0, #(0x3f)
2448 + ldr r1, [r0, #TI_CPU_DOMAIN]
2449 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2450 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2451 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2452 + @ write r1 to current_thread_info()->cpu_domain
2453 + str r1, [r0, #TI_CPU_DOMAIN]
2454 + @ write r1 to DACR
2455 + mcr p15, 0, r1, c3, c0, 0
2456 + @ instruction sync
2457 + instr_sync
2458 + @ restore regs
2459 + ldmia sp!, {r0, r1}
2460 +#endif
2461 + .endm
2462 +
2463 + .macro pax_close_userland
2464 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2465 + @ save regs
2466 + stmdb sp!, {r0, r1}
2467 + @ read DACR from cpu_domain into r1
2468 + mov r0, sp
2469 + @ assume 8K pages, since we have to split the immediate in two
2470 + bic r0, r0, #(0x1fc0)
2471 + bic r0, r0, #(0x3f)
2472 + ldr r1, [r0, #TI_CPU_DOMAIN]
2473 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2474 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2475 + @ write r1 to current_thread_info()->cpu_domain
2476 + str r1, [r0, #TI_CPU_DOMAIN]
2477 + @ write r1 to DACR
2478 + mcr p15, 0, r1, c3, c0, 0
2479 + @ instruction sync
2480 + instr_sync
2481 + @ restore regs
2482 + ldmia sp!, {r0, r1}
2483 +#endif
2484 + .endm
2485 +
2486 .macro pabt_helper
2487 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2488 #ifdef MULTI_PABORT
2489 @@ -89,11 +170,15 @@
2490 * Invalid mode handlers
2491 */
2492 .macro inv_entry, reason
2493 +
2494 + pax_enter_kernel
2495 +
2496 sub sp, sp, #S_FRAME_SIZE
2497 ARM( stmib sp, {r1 - lr} )
2498 THUMB( stmia sp, {r0 - r12} )
2499 THUMB( str sp, [sp, #S_SP] )
2500 THUMB( str lr, [sp, #S_LR] )
2501 +
2502 mov r1, #\reason
2503 .endm
2504
2505 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2506 .macro svc_entry, stack_hole=0
2507 UNWIND(.fnstart )
2508 UNWIND(.save {r0 - pc} )
2509 +
2510 + pax_enter_kernel
2511 +
2512 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2513 +
2514 #ifdef CONFIG_THUMB2_KERNEL
2515 SPFIX( str r0, [sp] ) @ temporarily saved
2516 SPFIX( mov r0, sp )
2517 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2518 ldmia r0, {r3 - r5}
2519 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2520 mov r6, #-1 @ "" "" "" ""
2521 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2522 + @ offset sp by 8 as done in pax_enter_kernel
2523 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2524 +#else
2525 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2526 +#endif
2527 SPFIX( addeq r2, r2, #4 )
2528 str r3, [sp, #-4]! @ save the "real" r0 copied
2529 @ from the exception stack
2530 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2531 .macro usr_entry
2532 UNWIND(.fnstart )
2533 UNWIND(.cantunwind ) @ don't unwind the user space
2534 +
2535 + pax_enter_kernel_user
2536 +
2537 sub sp, sp, #S_FRAME_SIZE
2538 ARM( stmib sp, {r1 - r12} )
2539 THUMB( stmia sp, {r0 - r12} )
2540 @@ -357,7 +454,8 @@ ENDPROC(__pabt_svc)
2541 .endm
2542
2543 .macro kuser_cmpxchg_check
2544 -#if !defined(CONFIG_CPU_32v6K) && !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
2545 +#if !defined(CONFIG_CPU_32v6K) && defined(CONFIG_KUSER_HELPERS) && \
2546 + !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
2547 #ifndef CONFIG_MMU
2548 #warning "NPTL on non MMU needs fixing"
2549 #else
2550 @@ -414,7 +512,9 @@ __und_usr:
2551 tst r3, #PSR_T_BIT @ Thumb mode?
2552 bne __und_usr_thumb
2553 sub r4, r2, #4 @ ARM instr at LR - 4
2554 + pax_open_userland
2555 1: ldrt r0, [r4]
2556 + pax_close_userland
2557 #ifdef CONFIG_CPU_ENDIAN_BE8
2558 rev r0, r0 @ little endian instruction
2559 #endif
2560 @@ -449,10 +549,14 @@ __und_usr_thumb:
2561 */
2562 .arch armv6t2
2563 #endif
2564 + pax_open_userland
2565 2: ldrht r5, [r4]
2566 + pax_close_userland
2567 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2568 blo __und_usr_fault_16 @ 16bit undefined instruction
2569 + pax_open_userland
2570 3: ldrht r0, [r2]
2571 + pax_close_userland
2572 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2573 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2574 orr r0, r0, r5, lsl #16
2575 @@ -481,7 +585,8 @@ ENDPROC(__und_usr)
2576 */
2577 .pushsection .fixup, "ax"
2578 .align 2
2579 -4: mov pc, r9
2580 +4: pax_close_userland
2581 + mov pc, r9
2582 .popsection
2583 .pushsection __ex_table,"a"
2584 .long 1b, 4b
2585 @@ -690,7 +795,7 @@ ENTRY(__switch_to)
2586 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2587 THUMB( str sp, [ip], #4 )
2588 THUMB( str lr, [ip], #4 )
2589 -#ifdef CONFIG_CPU_USE_DOMAINS
2590 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2591 ldr r6, [r2, #TI_CPU_DOMAIN]
2592 #endif
2593 set_tls r3, r4, r5
2594 @@ -699,7 +804,7 @@ ENTRY(__switch_to)
2595 ldr r8, =__stack_chk_guard
2596 ldr r7, [r7, #TSK_STACK_CANARY]
2597 #endif
2598 -#ifdef CONFIG_CPU_USE_DOMAINS
2599 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2600 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2601 #endif
2602 mov r5, r0
2603 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2604 index bc5bc0a..d0998ca 100644
2605 --- a/arch/arm/kernel/entry-common.S
2606 +++ b/arch/arm/kernel/entry-common.S
2607 @@ -10,18 +10,46 @@
2608
2609 #include <asm/unistd.h>
2610 #include <asm/ftrace.h>
2611 +#include <asm/domain.h>
2612 #include <asm/unwind.h>
2613
2614 +#include "entry-header.S"
2615 +
2616 #ifdef CONFIG_NEED_RET_TO_USER
2617 #include <mach/entry-macro.S>
2618 #else
2619 .macro arch_ret_to_user, tmp1, tmp2
2620 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2621 + @ save regs
2622 + stmdb sp!, {r1, r2}
2623 + @ read DACR from cpu_domain into r1
2624 + mov r2, sp
2625 + @ assume 8K pages, since we have to split the immediate in two
2626 + bic r2, r2, #(0x1fc0)
2627 + bic r2, r2, #(0x3f)
2628 + ldr r1, [r2, #TI_CPU_DOMAIN]
2629 +#ifdef CONFIG_PAX_KERNEXEC
2630 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2631 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2632 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2633 +#endif
2634 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2635 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2636 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2637 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2638 +#endif
2639 + @ write r1 to current_thread_info()->cpu_domain
2640 + str r1, [r2, #TI_CPU_DOMAIN]
2641 + @ write r1 to DACR
2642 + mcr p15, 0, r1, c3, c0, 0
2643 + @ instruction sync
2644 + instr_sync
2645 + @ restore regs
2646 + ldmia sp!, {r1, r2}
2647 +#endif
2648 .endm
2649 #endif
2650
2651 -#include "entry-header.S"
2652 -
2653 -
2654 .align 5
2655 /*
2656 * This is the fast syscall return path. We do as little as
2657 @@ -350,6 +378,7 @@ ENDPROC(ftrace_stub)
2658
2659 .align 5
2660 ENTRY(vector_swi)
2661 +
2662 sub sp, sp, #S_FRAME_SIZE
2663 stmia sp, {r0 - r12} @ Calling r0 - r12
2664 ARM( add r8, sp, #S_PC )
2665 @@ -399,6 +428,12 @@ ENTRY(vector_swi)
2666 ldr scno, [lr, #-4] @ get SWI instruction
2667 #endif
2668
2669 + /*
2670 + * do this here to avoid a performance hit of wrapping the code above
2671 + * that directly dereferences userland to parse the SWI instruction
2672 + */
2673 + pax_enter_kernel_user
2674 +
2675 #ifdef CONFIG_ALIGNMENT_TRAP
2676 ldr ip, __cr_alignment
2677 ldr ip, [ip]
2678 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2679 index 160f337..db67ee4 100644
2680 --- a/arch/arm/kernel/entry-header.S
2681 +++ b/arch/arm/kernel/entry-header.S
2682 @@ -73,6 +73,60 @@
2683 msr cpsr_c, \rtemp @ switch back to the SVC mode
2684 .endm
2685
2686 + .macro pax_enter_kernel_user
2687 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2688 + @ save regs
2689 + stmdb sp!, {r0, r1}
2690 + @ read DACR from cpu_domain into r1
2691 + mov r0, sp
2692 + @ assume 8K pages, since we have to split the immediate in two
2693 + bic r0, r0, #(0x1fc0)
2694 + bic r0, r0, #(0x3f)
2695 + ldr r1, [r0, #TI_CPU_DOMAIN]
2696 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2697 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2698 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2699 +#endif
2700 +#ifdef CONFIG_PAX_KERNEXEC
2701 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2702 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2703 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2704 +#endif
2705 + @ write r1 to current_thread_info()->cpu_domain
2706 + str r1, [r0, #TI_CPU_DOMAIN]
2707 + @ write r1 to DACR
2708 + mcr p15, 0, r1, c3, c0, 0
2709 + @ instruction sync
2710 + instr_sync
2711 + @ restore regs
2712 + ldmia sp!, {r0, r1}
2713 +#endif
2714 + .endm
2715 +
2716 + .macro pax_exit_kernel
2717 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2718 + @ save regs
2719 + stmdb sp!, {r0, r1}
2720 + @ read old DACR from stack into r1
2721 + ldr r1, [sp, #(8 + S_SP)]
2722 + sub r1, r1, #8
2723 + ldr r1, [r1]
2724 +
2725 + @ write r1 to current_thread_info()->cpu_domain
2726 + mov r0, sp
2727 + @ assume 8K pages, since we have to split the immediate in two
2728 + bic r0, r0, #(0x1fc0)
2729 + bic r0, r0, #(0x3f)
2730 + str r1, [r0, #TI_CPU_DOMAIN]
2731 + @ write r1 to DACR
2732 + mcr p15, 0, r1, c3, c0, 0
2733 + @ instruction sync
2734 + instr_sync
2735 + @ restore regs
2736 + ldmia sp!, {r0, r1}
2737 +#endif
2738 + .endm
2739 +
2740 #ifndef CONFIG_THUMB2_KERNEL
2741 .macro svc_exit, rpsr, irq = 0
2742 .if \irq != 0
2743 @@ -92,6 +146,9 @@
2744 blne trace_hardirqs_off
2745 #endif
2746 .endif
2747 +
2748 + pax_exit_kernel
2749 +
2750 msr spsr_cxsf, \rpsr
2751 #if defined(CONFIG_CPU_V6)
2752 ldr r0, [sp]
2753 @@ -155,6 +212,9 @@
2754 blne trace_hardirqs_off
2755 #endif
2756 .endif
2757 +
2758 + pax_exit_kernel
2759 +
2760 ldr lr, [sp, #S_SP] @ top of the stack
2761 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2762 clrex @ clear the exclusive monitor
2763 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2764 index 25442f4..d4948fc 100644
2765 --- a/arch/arm/kernel/fiq.c
2766 +++ b/arch/arm/kernel/fiq.c
2767 @@ -84,17 +84,16 @@ int show_fiq_list(struct seq_file *p, int prec)
2768
2769 void set_fiq_handler(void *start, unsigned int length)
2770 {
2771 -#if defined(CONFIG_CPU_USE_DOMAINS)
2772 - void *base = (void *)0xffff0000;
2773 -#else
2774 void *base = vectors_page;
2775 -#endif
2776 unsigned offset = FIQ_OFFSET;
2777
2778 + pax_open_kernel();
2779 memcpy(base + offset, start, length);
2780 + pax_close_kernel();
2781 +
2782 + if (!cache_is_vipt_nonaliasing())
2783 + flush_icache_range(base + offset, offset + length);
2784 flush_icache_range(0xffff0000 + offset, 0xffff0000 + offset + length);
2785 - if (!vectors_high())
2786 - flush_icache_range(offset, offset + length);
2787 }
2788
2789 int claim_fiq(struct fiq_handler *f)
2790 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2791 index 8bac553..caee108 100644
2792 --- a/arch/arm/kernel/head.S
2793 +++ b/arch/arm/kernel/head.S
2794 @@ -52,7 +52,9 @@
2795 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2796
2797 .macro pgtbl, rd, phys
2798 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2799 + mov \rd, #TEXT_OFFSET
2800 + sub \rd, #PG_DIR_SIZE
2801 + add \rd, \rd, \phys
2802 .endm
2803
2804 /*
2805 @@ -434,7 +436,7 @@ __enable_mmu:
2806 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2807 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2808 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2809 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2810 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2811 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2812 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2813 #endif
2814 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2815 index 1fd749e..47adb08 100644
2816 --- a/arch/arm/kernel/hw_breakpoint.c
2817 +++ b/arch/arm/kernel/hw_breakpoint.c
2818 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2819 return NOTIFY_OK;
2820 }
2821
2822 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2823 +static struct notifier_block dbg_reset_nb = {
2824 .notifier_call = dbg_reset_notify,
2825 };
2826
2827 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2828 index 1e9be5d..03edbc2 100644
2829 --- a/arch/arm/kernel/module.c
2830 +++ b/arch/arm/kernel/module.c
2831 @@ -37,12 +37,37 @@
2832 #endif
2833
2834 #ifdef CONFIG_MMU
2835 -void *module_alloc(unsigned long size)
2836 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2837 {
2838 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2839 + return NULL;
2840 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2841 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2842 + GFP_KERNEL, prot, -1,
2843 __builtin_return_address(0));
2844 }
2845 +
2846 +void *module_alloc(unsigned long size)
2847 +{
2848 +
2849 +#ifdef CONFIG_PAX_KERNEXEC
2850 + return __module_alloc(size, PAGE_KERNEL);
2851 +#else
2852 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2853 +#endif
2854 +
2855 +}
2856 +
2857 +#ifdef CONFIG_PAX_KERNEXEC
2858 +void module_free_exec(struct module *mod, void *module_region)
2859 +{
2860 + module_free(mod, module_region);
2861 +}
2862 +
2863 +void *module_alloc_exec(unsigned long size)
2864 +{
2865 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2866 +}
2867 +#endif
2868 #endif
2869
2870 int
2871 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2872 index 07314af..c46655c 100644
2873 --- a/arch/arm/kernel/patch.c
2874 +++ b/arch/arm/kernel/patch.c
2875 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2876 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2877 int size;
2878
2879 + pax_open_kernel();
2880 if (thumb2 && __opcode_is_thumb16(insn)) {
2881 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2882 size = sizeof(u16);
2883 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2884 *(u32 *)addr = insn;
2885 size = sizeof(u32);
2886 }
2887 + pax_close_kernel();
2888
2889 flush_icache_range((uintptr_t)(addr),
2890 (uintptr_t)(addr) + size);
2891 diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
2892 index d9f5cd4..e186ee1 100644
2893 --- a/arch/arm/kernel/perf_event.c
2894 +++ b/arch/arm/kernel/perf_event.c
2895 @@ -53,7 +53,12 @@ armpmu_map_cache_event(const unsigned (*cache_map)
2896 static int
2897 armpmu_map_hw_event(const unsigned (*event_map)[PERF_COUNT_HW_MAX], u64 config)
2898 {
2899 - int mapping = (*event_map)[config];
2900 + int mapping;
2901 +
2902 + if (config >= PERF_COUNT_HW_MAX)
2903 + return -EINVAL;
2904 +
2905 + mapping = (*event_map)[config];
2906 return mapping == HW_OP_UNSUPPORTED ? -ENOENT : mapping;
2907 }
2908
2909 @@ -253,6 +258,9 @@ validate_event(struct pmu_hw_events *hw_events,
2910 struct arm_pmu *armpmu = to_arm_pmu(event->pmu);
2911 struct pmu *leader_pmu = event->group_leader->pmu;
2912
2913 + if (is_software_event(event))
2914 + return 1;
2915 +
2916 if (event->pmu != leader_pmu || event->state < PERF_EVENT_STATE_OFF)
2917 return 1;
2918
2919 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2920 index 1f2740e..b36e225 100644
2921 --- a/arch/arm/kernel/perf_event_cpu.c
2922 +++ b/arch/arm/kernel/perf_event_cpu.c
2923 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2924 return NOTIFY_OK;
2925 }
2926
2927 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2928 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2929 .notifier_call = cpu_pmu_notify,
2930 };
2931
2932 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2933 index 5bc2615..4f1a0c2 100644
2934 --- a/arch/arm/kernel/process.c
2935 +++ b/arch/arm/kernel/process.c
2936 @@ -28,10 +28,10 @@
2937 #include <linux/tick.h>
2938 #include <linux/utsname.h>
2939 #include <linux/uaccess.h>
2940 -#include <linux/random.h>
2941 #include <linux/hw_breakpoint.h>
2942 #include <linux/cpuidle.h>
2943 #include <linux/leds.h>
2944 +#include <linux/random.h>
2945
2946 #include <asm/cacheflush.h>
2947 #include <asm/idmap.h>
2948 @@ -223,6 +223,7 @@ void machine_power_off(void)
2949
2950 if (pm_power_off)
2951 pm_power_off();
2952 + BUG();
2953 }
2954
2955 /*
2956 @@ -236,7 +237,7 @@ void machine_power_off(void)
2957 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2958 * to use. Implementing such co-ordination would be essentially impossible.
2959 */
2960 -void machine_restart(char *cmd)
2961 +__noreturn void machine_restart(char *cmd)
2962 {
2963 smp_send_stop();
2964
2965 @@ -258,8 +259,8 @@ void __show_regs(struct pt_regs *regs)
2966
2967 show_regs_print_info(KERN_DEFAULT);
2968
2969 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2970 - print_symbol("LR is at %s\n", regs->ARM_lr);
2971 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2972 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2973 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2974 "sp : %08lx ip : %08lx fp : %08lx\n",
2975 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2976 @@ -426,12 +427,6 @@ unsigned long get_wchan(struct task_struct *p)
2977 return 0;
2978 }
2979
2980 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2981 -{
2982 - unsigned long range_end = mm->brk + 0x02000000;
2983 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2984 -}
2985 -
2986 #ifdef CONFIG_MMU
2987 #ifdef CONFIG_KUSER_HELPERS
2988 /*
2989 @@ -447,7 +442,7 @@ static struct vm_area_struct gate_vma = {
2990
2991 static int __init gate_vma_init(void)
2992 {
2993 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2994 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2995 return 0;
2996 }
2997 arch_initcall(gate_vma_init);
2998 @@ -466,48 +461,23 @@ int in_gate_area_no_mm(unsigned long addr)
2999 {
3000 return in_gate_area(NULL, addr);
3001 }
3002 -#define is_gate_vma(vma) ((vma) = &gate_vma)
3003 +#define is_gate_vma(vma) ((vma) == &gate_vma)
3004 #else
3005 #define is_gate_vma(vma) 0
3006 #endif
3007
3008 const char *arch_vma_name(struct vm_area_struct *vma)
3009 {
3010 - return is_gate_vma(vma) ? "[vectors]" :
3011 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
3012 - "[sigpage]" : NULL;
3013 + return is_gate_vma(vma) ? "[vectors]" : NULL;
3014 }
3015
3016 -static struct page *signal_page;
3017 -extern struct page *get_signal_page(void);
3018 -
3019 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
3020 {
3021 struct mm_struct *mm = current->mm;
3022 - unsigned long addr;
3023 - int ret;
3024 -
3025 - if (!signal_page)
3026 - signal_page = get_signal_page();
3027 - if (!signal_page)
3028 - return -ENOMEM;
3029
3030 down_write(&mm->mmap_sem);
3031 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
3032 - if (IS_ERR_VALUE(addr)) {
3033 - ret = addr;
3034 - goto up_fail;
3035 - }
3036 -
3037 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
3038 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
3039 - &signal_page);
3040 -
3041 - if (ret == 0)
3042 - mm->context.sigpage = addr;
3043 -
3044 - up_fail:
3045 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
3046 up_write(&mm->mmap_sem);
3047 - return ret;
3048 + return 0;
3049 }
3050 #endif
3051 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
3052 index 3653164..d83e55d 100644
3053 --- a/arch/arm/kernel/psci.c
3054 +++ b/arch/arm/kernel/psci.c
3055 @@ -24,7 +24,7 @@
3056 #include <asm/opcodes-virt.h>
3057 #include <asm/psci.h>
3058
3059 -struct psci_operations psci_ops;
3060 +struct psci_operations psci_ops __read_only;
3061
3062 static int (*invoke_psci_fn)(u32, u32, u32, u32);
3063
3064 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
3065 index 03deeff..741ce88 100644
3066 --- a/arch/arm/kernel/ptrace.c
3067 +++ b/arch/arm/kernel/ptrace.c
3068 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
3069 return current_thread_info()->syscall;
3070 }
3071
3072 +#ifdef CONFIG_GRKERNSEC_SETXID
3073 +extern void gr_delayed_cred_worker(void);
3074 +#endif
3075 +
3076 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
3077 {
3078 current_thread_info()->syscall = scno;
3079
3080 +#ifdef CONFIG_GRKERNSEC_SETXID
3081 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3082 + gr_delayed_cred_worker();
3083 +#endif
3084 +
3085 /* Do the secure computing check first; failures should be fast. */
3086 if (secure_computing(scno) == -1)
3087 return -1;
3088 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3089 index b4b1d39..efdc9be 100644
3090 --- a/arch/arm/kernel/setup.c
3091 +++ b/arch/arm/kernel/setup.c
3092 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
3093 unsigned int elf_hwcap __read_mostly;
3094 EXPORT_SYMBOL(elf_hwcap);
3095
3096 +pteval_t __supported_pte_mask __read_only;
3097 +pmdval_t __supported_pmd_mask __read_only;
3098
3099 #ifdef MULTI_CPU
3100 -struct processor processor __read_mostly;
3101 +struct processor processor;
3102 #endif
3103 #ifdef MULTI_TLB
3104 -struct cpu_tlb_fns cpu_tlb __read_mostly;
3105 +struct cpu_tlb_fns cpu_tlb __read_only;
3106 #endif
3107 #ifdef MULTI_USER
3108 -struct cpu_user_fns cpu_user __read_mostly;
3109 +struct cpu_user_fns cpu_user __read_only;
3110 #endif
3111 #ifdef MULTI_CACHE
3112 -struct cpu_cache_fns cpu_cache __read_mostly;
3113 +struct cpu_cache_fns cpu_cache __read_only;
3114 #endif
3115 #ifdef CONFIG_OUTER_CACHE
3116 -struct outer_cache_fns outer_cache __read_mostly;
3117 +struct outer_cache_fns outer_cache __read_only;
3118 EXPORT_SYMBOL(outer_cache);
3119 #endif
3120
3121 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
3122 asm("mrc p15, 0, %0, c0, c1, 4"
3123 : "=r" (mmfr0));
3124 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3125 - (mmfr0 & 0x000000f0) >= 0x00000030)
3126 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3127 cpu_arch = CPU_ARCH_ARMv7;
3128 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3129 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3130 + __supported_pte_mask |= L_PTE_PXN;
3131 + __supported_pmd_mask |= PMD_PXNTABLE;
3132 + }
3133 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3134 (mmfr0 & 0x000000f0) == 0x00000020)
3135 cpu_arch = CPU_ARCH_ARMv6;
3136 else
3137 @@ -479,7 +485,7 @@ static void __init setup_processor(void)
3138 __cpu_architecture = __get_cpu_architecture();
3139
3140 #ifdef MULTI_CPU
3141 - processor = *list->proc;
3142 + memcpy((void *)&processor, list->proc, sizeof processor);
3143 #endif
3144 #ifdef MULTI_TLB
3145 cpu_tlb = *list->tlb;
3146 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3147 index 5a42c12..a2bb7c6 100644
3148 --- a/arch/arm/kernel/signal.c
3149 +++ b/arch/arm/kernel/signal.c
3150 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3151 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3152 };
3153
3154 -static unsigned long signal_return_offset;
3155 -
3156 #ifdef CONFIG_CRUNCH
3157 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3158 {
3159 @@ -406,8 +404,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3160 * except when the MPU has protected the vectors
3161 * page from PL0
3162 */
3163 - retcode = mm->context.sigpage + signal_return_offset +
3164 - (idx << 2) + thumb;
3165 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3166 } else
3167 #endif
3168 {
3169 @@ -611,33 +608,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3170 } while (thread_flags & _TIF_WORK_MASK);
3171 return 0;
3172 }
3173 -
3174 -struct page *get_signal_page(void)
3175 -{
3176 - unsigned long ptr;
3177 - unsigned offset;
3178 - struct page *page;
3179 - void *addr;
3180 -
3181 - page = alloc_pages(GFP_KERNEL, 0);
3182 -
3183 - if (!page)
3184 - return NULL;
3185 -
3186 - addr = page_address(page);
3187 -
3188 - /* Give the signal return code some randomness */
3189 - offset = 0x200 + (get_random_int() & 0x7fc);
3190 - signal_return_offset = offset;
3191 -
3192 - /*
3193 - * Copy signal return handlers into the vector page, and
3194 - * set sigreturn to be a pointer to these.
3195 - */
3196 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3197 -
3198 - ptr = (unsigned long)addr + offset;
3199 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3200 -
3201 - return page;
3202 -}
3203 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3204 index 5919eb4..b5d6dfe 100644
3205 --- a/arch/arm/kernel/smp.c
3206 +++ b/arch/arm/kernel/smp.c
3207 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3208
3209 static DECLARE_COMPLETION(cpu_running);
3210
3211 -static struct smp_operations smp_ops;
3212 +static struct smp_operations smp_ops __read_only;
3213
3214 void __init smp_set_ops(struct smp_operations *ops)
3215 {
3216 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3217 index 6b9567e..b8af2d6 100644
3218 --- a/arch/arm/kernel/traps.c
3219 +++ b/arch/arm/kernel/traps.c
3220 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3221 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3222 {
3223 #ifdef CONFIG_KALLSYMS
3224 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3225 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3226 #else
3227 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3228 #endif
3229 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3230 static int die_owner = -1;
3231 static unsigned int die_nest_count;
3232
3233 +extern void gr_handle_kernel_exploit(void);
3234 +
3235 static unsigned long oops_begin(void)
3236 {
3237 int cpu;
3238 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3239 panic("Fatal exception in interrupt");
3240 if (panic_on_oops)
3241 panic("Fatal exception");
3242 +
3243 + gr_handle_kernel_exploit();
3244 +
3245 if (signr)
3246 do_exit(signr);
3247 }
3248 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3249 * The user helper at 0xffff0fe0 must be used instead.
3250 * (see entry-armv.S for details)
3251 */
3252 + pax_open_kernel();
3253 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3254 + pax_close_kernel();
3255 }
3256 return 0;
3257
3258 @@ -848,5 +855,9 @@ void __init early_trap_init(void *vectors_base)
3259 kuser_init(vectors_base);
3260
3261 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3262 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3263 +
3264 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3265 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3266 +#endif
3267 +
3268 }
3269 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3270 index 33f2ea3..0b91824 100644
3271 --- a/arch/arm/kernel/vmlinux.lds.S
3272 +++ b/arch/arm/kernel/vmlinux.lds.S
3273 @@ -8,7 +8,11 @@
3274 #include <asm/thread_info.h>
3275 #include <asm/memory.h>
3276 #include <asm/page.h>
3277 -
3278 +
3279 +#ifdef CONFIG_PAX_KERNEXEC
3280 +#include <asm/pgtable.h>
3281 +#endif
3282 +
3283 #define PROC_INFO \
3284 . = ALIGN(4); \
3285 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3286 @@ -94,6 +98,11 @@ SECTIONS
3287 _text = .;
3288 HEAD_TEXT
3289 }
3290 +
3291 +#ifdef CONFIG_PAX_KERNEXEC
3292 + . = ALIGN(1<<SECTION_SHIFT);
3293 +#endif
3294 +
3295 .text : { /* Real text segment */
3296 _stext = .; /* Text and read-only data */
3297 __exception_text_start = .;
3298 @@ -116,6 +125,8 @@ SECTIONS
3299 ARM_CPU_KEEP(PROC_INFO)
3300 }
3301
3302 + _etext = .; /* End of text section */
3303 +
3304 RO_DATA(PAGE_SIZE)
3305
3306 . = ALIGN(4);
3307 @@ -146,7 +157,9 @@ SECTIONS
3308
3309 NOTES
3310
3311 - _etext = .; /* End of text and rodata section */
3312 +#ifdef CONFIG_PAX_KERNEXEC
3313 + . = ALIGN(1<<SECTION_SHIFT);
3314 +#endif
3315
3316 #ifndef CONFIG_XIP_KERNEL
3317 . = ALIGN(PAGE_SIZE);
3318 @@ -224,6 +237,11 @@ SECTIONS
3319 . = PAGE_OFFSET + TEXT_OFFSET;
3320 #else
3321 __init_end = .;
3322 +
3323 +#ifdef CONFIG_PAX_KERNEXEC
3324 + . = ALIGN(1<<SECTION_SHIFT);
3325 +#endif
3326 +
3327 . = ALIGN(THREAD_SIZE);
3328 __data_loc = .;
3329 #endif
3330 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3331 index 14a0d98..7771a7d 100644
3332 --- a/arch/arm/lib/clear_user.S
3333 +++ b/arch/arm/lib/clear_user.S
3334 @@ -12,14 +12,14 @@
3335
3336 .text
3337
3338 -/* Prototype: int __clear_user(void *addr, size_t sz)
3339 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3340 * Purpose : clear some user memory
3341 * Params : addr - user memory address to clear
3342 * : sz - number of bytes to clear
3343 * Returns : number of bytes NOT cleared
3344 */
3345 ENTRY(__clear_user_std)
3346 -WEAK(__clear_user)
3347 +WEAK(___clear_user)
3348 stmfd sp!, {r1, lr}
3349 mov r2, #0
3350 cmp r1, #4
3351 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3352 USER( strnebt r2, [r0])
3353 mov r0, #0
3354 ldmfd sp!, {r1, pc}
3355 -ENDPROC(__clear_user)
3356 +ENDPROC(___clear_user)
3357 ENDPROC(__clear_user_std)
3358
3359 .pushsection .fixup,"ax"
3360 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3361 index 66a477a..bee61d3 100644
3362 --- a/arch/arm/lib/copy_from_user.S
3363 +++ b/arch/arm/lib/copy_from_user.S
3364 @@ -16,7 +16,7 @@
3365 /*
3366 * Prototype:
3367 *
3368 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3369 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3370 *
3371 * Purpose:
3372 *
3373 @@ -84,11 +84,11 @@
3374
3375 .text
3376
3377 -ENTRY(__copy_from_user)
3378 +ENTRY(___copy_from_user)
3379
3380 #include "copy_template.S"
3381
3382 -ENDPROC(__copy_from_user)
3383 +ENDPROC(___copy_from_user)
3384
3385 .pushsection .fixup,"ax"
3386 .align 0
3387 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3388 index 6ee2f67..d1cce76 100644
3389 --- a/arch/arm/lib/copy_page.S
3390 +++ b/arch/arm/lib/copy_page.S
3391 @@ -10,6 +10,7 @@
3392 * ASM optimised string functions
3393 */
3394 #include <linux/linkage.h>
3395 +#include <linux/const.h>
3396 #include <asm/assembler.h>
3397 #include <asm/asm-offsets.h>
3398 #include <asm/cache.h>
3399 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3400 index d066df6..df28194 100644
3401 --- a/arch/arm/lib/copy_to_user.S
3402 +++ b/arch/arm/lib/copy_to_user.S
3403 @@ -16,7 +16,7 @@
3404 /*
3405 * Prototype:
3406 *
3407 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3408 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3409 *
3410 * Purpose:
3411 *
3412 @@ -88,11 +88,11 @@
3413 .text
3414
3415 ENTRY(__copy_to_user_std)
3416 -WEAK(__copy_to_user)
3417 +WEAK(___copy_to_user)
3418
3419 #include "copy_template.S"
3420
3421 -ENDPROC(__copy_to_user)
3422 +ENDPROC(___copy_to_user)
3423 ENDPROC(__copy_to_user_std)
3424
3425 .pushsection .fixup,"ax"
3426 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3427 index 7d08b43..f7ca7ea 100644
3428 --- a/arch/arm/lib/csumpartialcopyuser.S
3429 +++ b/arch/arm/lib/csumpartialcopyuser.S
3430 @@ -57,8 +57,8 @@
3431 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3432 */
3433
3434 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3435 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3436 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3437 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3438
3439 #include "csumpartialcopygeneric.S"
3440
3441 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3442 index 64dbfa5..84a3fd9 100644
3443 --- a/arch/arm/lib/delay.c
3444 +++ b/arch/arm/lib/delay.c
3445 @@ -28,7 +28,7 @@
3446 /*
3447 * Default to the loop-based delay implementation.
3448 */
3449 -struct arm_delay_ops arm_delay_ops = {
3450 +struct arm_delay_ops arm_delay_ops __read_only = {
3451 .delay = __loop_delay,
3452 .const_udelay = __loop_const_udelay,
3453 .udelay = __loop_udelay,
3454 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3455 index 025f742..8432b08 100644
3456 --- a/arch/arm/lib/uaccess_with_memcpy.c
3457 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3458 @@ -104,7 +104,7 @@ out:
3459 }
3460
3461 unsigned long
3462 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3463 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3464 {
3465 /*
3466 * This test is stubbed out of the main function above to keep
3467 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3468 index f389228..592ef66 100644
3469 --- a/arch/arm/mach-kirkwood/common.c
3470 +++ b/arch/arm/mach-kirkwood/common.c
3471 @@ -149,7 +149,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3472 clk_gate_ops.disable(hw);
3473 }
3474
3475 -static struct clk_ops clk_gate_fn_ops;
3476 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3477 +{
3478 + return clk_gate_ops.is_enabled(hw);
3479 +}
3480 +
3481 +static struct clk_ops clk_gate_fn_ops = {
3482 + .enable = clk_gate_fn_enable,
3483 + .disable = clk_gate_fn_disable,
3484 + .is_enabled = clk_gate_fn_is_enabled,
3485 +};
3486
3487 static struct clk __init *clk_register_gate_fn(struct device *dev,
3488 const char *name,
3489 @@ -183,14 +192,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3490 gate_fn->fn_en = fn_en;
3491 gate_fn->fn_dis = fn_dis;
3492
3493 - /* ops is the gate ops, but with our enable/disable functions */
3494 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3495 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3496 - clk_gate_fn_ops = clk_gate_ops;
3497 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3498 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3499 - }
3500 -
3501 clk = clk_register(dev, &gate_fn->gate.hw);
3502
3503 if (IS_ERR(clk))
3504 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3505 index f6eeb87..cc90868 100644
3506 --- a/arch/arm/mach-omap2/board-n8x0.c
3507 +++ b/arch/arm/mach-omap2/board-n8x0.c
3508 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3509 }
3510 #endif
3511
3512 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3513 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3514 .late_init = n8x0_menelaus_late_init,
3515 };
3516
3517 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3518 index 6c4da12..d9ca72d 100644
3519 --- a/arch/arm/mach-omap2/gpmc.c
3520 +++ b/arch/arm/mach-omap2/gpmc.c
3521 @@ -147,7 +147,6 @@ struct omap3_gpmc_regs {
3522 };
3523
3524 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3525 -static struct irq_chip gpmc_irq_chip;
3526 static unsigned gpmc_irq_start;
3527
3528 static struct resource gpmc_mem_root;
3529 @@ -711,6 +710,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3530
3531 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3532
3533 +static struct irq_chip gpmc_irq_chip = {
3534 + .name = "gpmc",
3535 + .irq_startup = gpmc_irq_noop_ret,
3536 + .irq_enable = gpmc_irq_enable,
3537 + .irq_disable = gpmc_irq_disable,
3538 + .irq_shutdown = gpmc_irq_noop,
3539 + .irq_ack = gpmc_irq_noop,
3540 + .irq_mask = gpmc_irq_noop,
3541 + .irq_unmask = gpmc_irq_noop,
3542 +
3543 +};
3544 +
3545 static int gpmc_setup_irq(void)
3546 {
3547 int i;
3548 @@ -725,15 +736,6 @@ static int gpmc_setup_irq(void)
3549 return gpmc_irq_start;
3550 }
3551
3552 - gpmc_irq_chip.name = "gpmc";
3553 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3554 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3555 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3556 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3557 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3558 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3559 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3560 -
3561 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3562 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3563
3564 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3565 index f8bb3b9..831e7b8 100644
3566 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3567 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3568 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3569 return NOTIFY_OK;
3570 }
3571
3572 -static struct notifier_block __refdata irq_hotplug_notifier = {
3573 +static struct notifier_block irq_hotplug_notifier = {
3574 .notifier_call = irq_cpu_hotplug_notify,
3575 };
3576
3577 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3578 index e6d2307..d057195 100644
3579 --- a/arch/arm/mach-omap2/omap_device.c
3580 +++ b/arch/arm/mach-omap2/omap_device.c
3581 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3582 struct platform_device __init *omap_device_build(const char *pdev_name,
3583 int pdev_id,
3584 struct omap_hwmod *oh,
3585 - void *pdata, int pdata_len)
3586 + const void *pdata, int pdata_len)
3587 {
3588 struct omap_hwmod *ohs[] = { oh };
3589
3590 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3591 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3592 int pdev_id,
3593 struct omap_hwmod **ohs,
3594 - int oh_cnt, void *pdata,
3595 + int oh_cnt, const void *pdata,
3596 int pdata_len)
3597 {
3598 int ret = -ENOMEM;
3599 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3600 index 044c31d..2ee0861 100644
3601 --- a/arch/arm/mach-omap2/omap_device.h
3602 +++ b/arch/arm/mach-omap2/omap_device.h
3603 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3604 /* Core code interface */
3605
3606 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3607 - struct omap_hwmod *oh, void *pdata,
3608 + struct omap_hwmod *oh, const void *pdata,
3609 int pdata_len);
3610
3611 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3612 struct omap_hwmod **oh, int oh_cnt,
3613 - void *pdata, int pdata_len);
3614 + const void *pdata, int pdata_len);
3615
3616 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3617 struct omap_hwmod **ohs, int oh_cnt);
3618 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3619 index 7341eff..fd75e34 100644
3620 --- a/arch/arm/mach-omap2/omap_hwmod.c
3621 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3622 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3623 int (*init_clkdm)(struct omap_hwmod *oh);
3624 void (*update_context_lost)(struct omap_hwmod *oh);
3625 int (*get_context_lost)(struct omap_hwmod *oh);
3626 -};
3627 +} __no_const;
3628
3629 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3630 -static struct omap_hwmod_soc_ops soc_ops;
3631 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3632
3633 /* omap_hwmod_list contains all registered struct omap_hwmods */
3634 static LIST_HEAD(omap_hwmod_list);
3635 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3636 index d15c7bb..b2d1f0c 100644
3637 --- a/arch/arm/mach-omap2/wd_timer.c
3638 +++ b/arch/arm/mach-omap2/wd_timer.c
3639 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3640 struct omap_hwmod *oh;
3641 char *oh_name = "wd_timer2";
3642 char *dev_name = "omap_wdt";
3643 - struct omap_wd_timer_platform_data pdata;
3644 + static struct omap_wd_timer_platform_data pdata = {
3645 + .read_reset_sources = prm_read_reset_sources
3646 + };
3647
3648 if (!cpu_class_is_omap2() || of_have_populated_dt())
3649 return 0;
3650 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3651 return -EINVAL;
3652 }
3653
3654 - pdata.read_reset_sources = prm_read_reset_sources;
3655 -
3656 pdev = omap_device_build(dev_name, id, oh, &pdata,
3657 sizeof(struct omap_wd_timer_platform_data));
3658 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3659 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3660 index 0cdba8d..297993e 100644
3661 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3662 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3663 @@ -181,7 +181,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3664 bool entered_lp2 = false;
3665
3666 if (tegra_pending_sgi())
3667 - ACCESS_ONCE(abort_flag) = true;
3668 + ACCESS_ONCE_RW(abort_flag) = true;
3669
3670 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3671
3672 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3673 index cad3ca86..1d79e0f 100644
3674 --- a/arch/arm/mach-ux500/setup.h
3675 +++ b/arch/arm/mach-ux500/setup.h
3676 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3677 .type = MT_DEVICE, \
3678 }
3679
3680 -#define __MEM_DEV_DESC(x, sz) { \
3681 - .virtual = IO_ADDRESS(x), \
3682 - .pfn = __phys_to_pfn(x), \
3683 - .length = sz, \
3684 - .type = MT_MEMORY, \
3685 -}
3686 -
3687 extern struct smp_operations ux500_smp_ops;
3688 extern void ux500_cpu_die(unsigned int cpu);
3689
3690 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3691 index 2950082..d0f0782 100644
3692 --- a/arch/arm/mm/Kconfig
3693 +++ b/arch/arm/mm/Kconfig
3694 @@ -436,7 +436,7 @@ config CPU_32v5
3695
3696 config CPU_32v6
3697 bool
3698 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3699 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3700 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3701
3702 config CPU_32v6K
3703 @@ -585,6 +585,7 @@ config CPU_CP15_MPU
3704
3705 config CPU_USE_DOMAINS
3706 bool
3707 + depends on !ARM_LPAE && !PAX_KERNEXEC
3708 help
3709 This option enables or disables the use of domain switching
3710 via the set_fs() function.
3711 @@ -780,6 +781,7 @@ config NEED_KUSER_HELPERS
3712 config KUSER_HELPERS
3713 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3714 default y
3715 + depends on !(CPU_V6 || CPU_V6K || CPU_V7)
3716 help
3717 Warning: disabling this option may break user programs.
3718
3719 @@ -790,7 +792,7 @@ config KUSER_HELPERS
3720 run on ARMv4 through to ARMv7 without modification.
3721
3722 However, the fixed address nature of these helpers can be used
3723 - by ROP (return orientated programming) authors when creating
3724 + by ROP (Return Oriented Programming) authors when creating
3725 exploits.
3726
3727 If all of the binaries and libraries which run on your platform
3728 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3729 index 6f4585b..7b6f52b 100644
3730 --- a/arch/arm/mm/alignment.c
3731 +++ b/arch/arm/mm/alignment.c
3732 @@ -211,10 +211,12 @@ union offset_union {
3733 #define __get16_unaligned_check(ins,val,addr) \
3734 do { \
3735 unsigned int err = 0, v, a = addr; \
3736 + pax_open_userland(); \
3737 __get8_unaligned_check(ins,v,a,err); \
3738 val = v << ((BE) ? 8 : 0); \
3739 __get8_unaligned_check(ins,v,a,err); \
3740 val |= v << ((BE) ? 0 : 8); \
3741 + pax_close_userland(); \
3742 if (err) \
3743 goto fault; \
3744 } while (0)
3745 @@ -228,6 +230,7 @@ union offset_union {
3746 #define __get32_unaligned_check(ins,val,addr) \
3747 do { \
3748 unsigned int err = 0, v, a = addr; \
3749 + pax_open_userland(); \
3750 __get8_unaligned_check(ins,v,a,err); \
3751 val = v << ((BE) ? 24 : 0); \
3752 __get8_unaligned_check(ins,v,a,err); \
3753 @@ -236,6 +239,7 @@ union offset_union {
3754 val |= v << ((BE) ? 8 : 16); \
3755 __get8_unaligned_check(ins,v,a,err); \
3756 val |= v << ((BE) ? 0 : 24); \
3757 + pax_close_userland(); \
3758 if (err) \
3759 goto fault; \
3760 } while (0)
3761 @@ -249,6 +253,7 @@ union offset_union {
3762 #define __put16_unaligned_check(ins,val,addr) \
3763 do { \
3764 unsigned int err = 0, v = val, a = addr; \
3765 + pax_open_userland(); \
3766 __asm__( FIRST_BYTE_16 \
3767 ARM( "1: "ins" %1, [%2], #1\n" ) \
3768 THUMB( "1: "ins" %1, [%2]\n" ) \
3769 @@ -268,6 +273,7 @@ union offset_union {
3770 " .popsection\n" \
3771 : "=r" (err), "=&r" (v), "=&r" (a) \
3772 : "0" (err), "1" (v), "2" (a)); \
3773 + pax_close_userland(); \
3774 if (err) \
3775 goto fault; \
3776 } while (0)
3777 @@ -281,6 +287,7 @@ union offset_union {
3778 #define __put32_unaligned_check(ins,val,addr) \
3779 do { \
3780 unsigned int err = 0, v = val, a = addr; \
3781 + pax_open_userland(); \
3782 __asm__( FIRST_BYTE_32 \
3783 ARM( "1: "ins" %1, [%2], #1\n" ) \
3784 THUMB( "1: "ins" %1, [%2]\n" ) \
3785 @@ -310,6 +317,7 @@ union offset_union {
3786 " .popsection\n" \
3787 : "=r" (err), "=&r" (v), "=&r" (a) \
3788 : "0" (err), "1" (v), "2" (a)); \
3789 + pax_close_userland(); \
3790 if (err) \
3791 goto fault; \
3792 } while (0)
3793 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3794 index 5dbf13f..ee1ec24 100644
3795 --- a/arch/arm/mm/fault.c
3796 +++ b/arch/arm/mm/fault.c
3797 @@ -25,6 +25,7 @@
3798 #include <asm/system_misc.h>
3799 #include <asm/system_info.h>
3800 #include <asm/tlbflush.h>
3801 +#include <asm/sections.h>
3802
3803 #include "fault.h"
3804
3805 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3806 if (fixup_exception(regs))
3807 return;
3808
3809 +#ifdef CONFIG_PAX_KERNEXEC
3810 + if ((fsr & FSR_WRITE) &&
3811 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3812 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3813 + {
3814 + if (current->signal->curr_ip)
3815 + 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),
3816 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3817 + else
3818 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3819 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3820 + }
3821 +#endif
3822 +
3823 /*
3824 * No handler, we'll have to terminate things with extreme prejudice.
3825 */
3826 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3827 }
3828 #endif
3829
3830 +#ifdef CONFIG_PAX_PAGEEXEC
3831 + if (fsr & FSR_LNX_PF) {
3832 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3833 + do_group_exit(SIGKILL);
3834 + }
3835 +#endif
3836 +
3837 tsk->thread.address = addr;
3838 tsk->thread.error_code = fsr;
3839 tsk->thread.trap_no = 14;
3840 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3841 }
3842 #endif /* CONFIG_MMU */
3843
3844 +#ifdef CONFIG_PAX_PAGEEXEC
3845 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3846 +{
3847 + long i;
3848 +
3849 + printk(KERN_ERR "PAX: bytes at PC: ");
3850 + for (i = 0; i < 20; i++) {
3851 + unsigned char c;
3852 + if (get_user(c, (__force unsigned char __user *)pc+i))
3853 + printk(KERN_CONT "?? ");
3854 + else
3855 + printk(KERN_CONT "%02x ", c);
3856 + }
3857 + printk("\n");
3858 +
3859 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3860 + for (i = -1; i < 20; i++) {
3861 + unsigned long c;
3862 + if (get_user(c, (__force unsigned long __user *)sp+i))
3863 + printk(KERN_CONT "???????? ");
3864 + else
3865 + printk(KERN_CONT "%08lx ", c);
3866 + }
3867 + printk("\n");
3868 +}
3869 +#endif
3870 +
3871 /*
3872 * First Level Translation Fault Handler
3873 *
3874 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3875 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3876 struct siginfo info;
3877
3878 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3879 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3880 + if (current->signal->curr_ip)
3881 + 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),
3882 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3883 + else
3884 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3885 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3886 + goto die;
3887 + }
3888 +#endif
3889 +
3890 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3891 return;
3892
3893 +die:
3894 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3895 inf->name, fsr, addr);
3896
3897 @@ -569,15 +631,67 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3898 ifsr_info[nr].name = name;
3899 }
3900
3901 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3902 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3903 +
3904 asmlinkage void __exception
3905 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3906 {
3907 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3908 struct siginfo info;
3909
3910 + if (user_mode(regs)) {
3911 + unsigned long sigpage = current->mm->context.sigpage;
3912 +
3913 + if (sigpage <= addr && addr < sigpage + 7*4) {
3914 + if (addr < sigpage + 3*4)
3915 + sys_sigreturn(regs);
3916 + else
3917 + sys_rt_sigreturn(regs);
3918 + return;
3919 + }
3920 + if (addr == 0xffff0fe0UL) {
3921 + /*
3922 + * PaX: __kuser_get_tls emulation
3923 + */
3924 + regs->ARM_r0 = current_thread_info()->tp_value;
3925 + regs->ARM_pc = regs->ARM_lr;
3926 + return;
3927 + }
3928 + }
3929 +
3930 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3931 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3932 + if (current->signal->curr_ip)
3933 + 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),
3934 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3935 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3936 + else
3937 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3938 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3939 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3940 + goto die;
3941 + }
3942 +#endif
3943 +
3944 +#ifdef CONFIG_PAX_REFCOUNT
3945 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3946 + unsigned int bkpt;
3947 +
3948 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3949 + current->thread.error_code = ifsr;
3950 + current->thread.trap_no = 0;
3951 + pax_report_refcount_overflow(regs);
3952 + fixup_exception(regs);
3953 + return;
3954 + }
3955 + }
3956 +#endif
3957 +
3958 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3959 return;
3960
3961 +die:
3962 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3963 inf->name, ifsr, addr);
3964
3965 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3966 index cf08bdf..772656c 100644
3967 --- a/arch/arm/mm/fault.h
3968 +++ b/arch/arm/mm/fault.h
3969 @@ -3,6 +3,7 @@
3970
3971 /*
3972 * Fault status register encodings. We steal bit 31 for our own purposes.
3973 + * Set when the FSR value is from an instruction fault.
3974 */
3975 #define FSR_LNX_PF (1 << 31)
3976 #define FSR_WRITE (1 << 11)
3977 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3978 }
3979 #endif
3980
3981 +/* valid for LPAE and !LPAE */
3982 +static inline int is_xn_fault(unsigned int fsr)
3983 +{
3984 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3985 +}
3986 +
3987 +static inline int is_domain_fault(unsigned int fsr)
3988 +{
3989 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3990 +}
3991 +
3992 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3993 unsigned long search_exception_table(unsigned long addr);
3994
3995 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3996 index 0ecc43f..190b956 100644
3997 --- a/arch/arm/mm/init.c
3998 +++ b/arch/arm/mm/init.c
3999 @@ -30,6 +30,8 @@
4000 #include <asm/setup.h>
4001 #include <asm/tlb.h>
4002 #include <asm/fixmap.h>
4003 +#include <asm/system_info.h>
4004 +#include <asm/cp15.h>
4005
4006 #include <asm/mach/arch.h>
4007 #include <asm/mach/map.h>
4008 @@ -726,7 +728,46 @@ void free_initmem(void)
4009 {
4010 #ifdef CONFIG_HAVE_TCM
4011 extern char __tcm_start, __tcm_end;
4012 +#endif
4013
4014 +#ifdef CONFIG_PAX_KERNEXEC
4015 + unsigned long addr;
4016 + pgd_t *pgd;
4017 + pud_t *pud;
4018 + pmd_t *pmd;
4019 + int cpu_arch = cpu_architecture();
4020 + unsigned int cr = get_cr();
4021 +
4022 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4023 + /* make pages tables, etc before .text NX */
4024 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4025 + pgd = pgd_offset_k(addr);
4026 + pud = pud_offset(pgd, addr);
4027 + pmd = pmd_offset(pud, addr);
4028 + __section_update(pmd, addr, PMD_SECT_XN);
4029 + }
4030 + /* make init NX */
4031 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4032 + pgd = pgd_offset_k(addr);
4033 + pud = pud_offset(pgd, addr);
4034 + pmd = pmd_offset(pud, addr);
4035 + __section_update(pmd, addr, PMD_SECT_XN);
4036 + }
4037 + /* make kernel code/rodata RX */
4038 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4039 + pgd = pgd_offset_k(addr);
4040 + pud = pud_offset(pgd, addr);
4041 + pmd = pmd_offset(pud, addr);
4042 +#ifdef CONFIG_ARM_LPAE
4043 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4044 +#else
4045 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4046 +#endif
4047 + }
4048 + }
4049 +#endif
4050 +
4051 +#ifdef CONFIG_HAVE_TCM
4052 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4053 free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
4054 #endif
4055 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4056 index 04d9006..c547d85 100644
4057 --- a/arch/arm/mm/ioremap.c
4058 +++ b/arch/arm/mm/ioremap.c
4059 @@ -392,9 +392,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
4060 unsigned int mtype;
4061
4062 if (cached)
4063 - mtype = MT_MEMORY;
4064 + mtype = MT_MEMORY_RX;
4065 else
4066 - mtype = MT_MEMORY_NONCACHED;
4067 + mtype = MT_MEMORY_NONCACHED_RX;
4068
4069 return __arm_ioremap_caller(phys_addr, size, mtype,
4070 __builtin_return_address(0));
4071 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4072 index 10062ce..8695745 100644
4073 --- a/arch/arm/mm/mmap.c
4074 +++ b/arch/arm/mm/mmap.c
4075 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4076 struct vm_area_struct *vma;
4077 int do_align = 0;
4078 int aliasing = cache_is_vipt_aliasing();
4079 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4080 struct vm_unmapped_area_info info;
4081
4082 /*
4083 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4084 if (len > TASK_SIZE)
4085 return -ENOMEM;
4086
4087 +#ifdef CONFIG_PAX_RANDMMAP
4088 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4089 +#endif
4090 +
4091 if (addr) {
4092 if (do_align)
4093 addr = COLOUR_ALIGN(addr, pgoff);
4094 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4095 addr = PAGE_ALIGN(addr);
4096
4097 vma = find_vma(mm, addr);
4098 - if (TASK_SIZE - len >= addr &&
4099 - (!vma || addr + len <= vma->vm_start))
4100 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4101 return addr;
4102 }
4103
4104 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4105 info.high_limit = TASK_SIZE;
4106 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4107 info.align_offset = pgoff << PAGE_SHIFT;
4108 + info.threadstack_offset = offset;
4109 return vm_unmapped_area(&info);
4110 }
4111
4112 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4113 unsigned long addr = addr0;
4114 int do_align = 0;
4115 int aliasing = cache_is_vipt_aliasing();
4116 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4117 struct vm_unmapped_area_info info;
4118
4119 /*
4120 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4121 return addr;
4122 }
4123
4124 +#ifdef CONFIG_PAX_RANDMMAP
4125 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4126 +#endif
4127 +
4128 /* requesting a specific address */
4129 if (addr) {
4130 if (do_align)
4131 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4132 else
4133 addr = PAGE_ALIGN(addr);
4134 vma = find_vma(mm, addr);
4135 - if (TASK_SIZE - len >= addr &&
4136 - (!vma || addr + len <= vma->vm_start))
4137 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4138 return addr;
4139 }
4140
4141 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4142 info.high_limit = mm->mmap_base;
4143 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4144 info.align_offset = pgoff << PAGE_SHIFT;
4145 + info.threadstack_offset = offset;
4146 addr = vm_unmapped_area(&info);
4147
4148 /*
4149 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4150 {
4151 unsigned long random_factor = 0UL;
4152
4153 +#ifdef CONFIG_PAX_RANDMMAP
4154 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4155 +#endif
4156 +
4157 /* 8 bits of randomness in 20 address space bits */
4158 if ((current->flags & PF_RANDOMIZE) &&
4159 !(current->personality & ADDR_NO_RANDOMIZE))
4160 @@ -180,10 +194,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4161
4162 if (mmap_is_legacy()) {
4163 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4164 +
4165 +#ifdef CONFIG_PAX_RANDMMAP
4166 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4167 + mm->mmap_base += mm->delta_mmap;
4168 +#endif
4169 +
4170 mm->get_unmapped_area = arch_get_unmapped_area;
4171 mm->unmap_area = arch_unmap_area;
4172 } else {
4173 mm->mmap_base = mmap_base(random_factor);
4174 +
4175 +#ifdef CONFIG_PAX_RANDMMAP
4176 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4177 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4178 +#endif
4179 +
4180 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4181 mm->unmap_area = arch_unmap_area_topdown;
4182 }
4183 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4184 index daf336f..4e6392c 100644
4185 --- a/arch/arm/mm/mmu.c
4186 +++ b/arch/arm/mm/mmu.c
4187 @@ -36,6 +36,22 @@
4188 #include "mm.h"
4189 #include "tcm.h"
4190
4191 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4192 +void modify_domain(unsigned int dom, unsigned int type)
4193 +{
4194 + struct thread_info *thread = current_thread_info();
4195 + unsigned int domain = thread->cpu_domain;
4196 + /*
4197 + * DOMAIN_MANAGER might be defined to some other value,
4198 + * use the arch-defined constant
4199 + */
4200 + domain &= ~domain_val(dom, 3);
4201 + thread->cpu_domain = domain | domain_val(dom, type);
4202 + set_domain(thread->cpu_domain);
4203 +}
4204 +EXPORT_SYMBOL(modify_domain);
4205 +#endif
4206 +
4207 /*
4208 * empty_zero_page is a special page that is used for
4209 * zero-initialized data and COW.
4210 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4211
4212 #endif /* ifdef CONFIG_CPU_CP15 / else */
4213
4214 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4215 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4216 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4217
4218 -static struct mem_type mem_types[] = {
4219 +#ifdef CONFIG_PAX_KERNEXEC
4220 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4221 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4222 +#else
4223 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4224 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4225 +#endif
4226 +
4227 +static struct mem_type mem_types[] __read_only = {
4228 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4229 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4230 L_PTE_SHARED,
4231 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4232 [MT_UNCACHED] = {
4233 .prot_pte = PROT_PTE_DEVICE,
4234 .prot_l1 = PMD_TYPE_TABLE,
4235 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4236 + .prot_sect = PROT_SECT_DEVICE,
4237 .domain = DOMAIN_IO,
4238 },
4239 [MT_CACHECLEAN] = {
4240 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4241 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4242 .domain = DOMAIN_KERNEL,
4243 },
4244 #ifndef CONFIG_ARM_LPAE
4245 [MT_MINICLEAN] = {
4246 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4247 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4248 .domain = DOMAIN_KERNEL,
4249 },
4250 #endif
4251 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4252 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4253 L_PTE_RDONLY,
4254 .prot_l1 = PMD_TYPE_TABLE,
4255 - .domain = DOMAIN_USER,
4256 + .domain = DOMAIN_VECTORS,
4257 },
4258 [MT_HIGH_VECTORS] = {
4259 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4260 L_PTE_USER | L_PTE_RDONLY,
4261 .prot_l1 = PMD_TYPE_TABLE,
4262 - .domain = DOMAIN_USER,
4263 + .domain = DOMAIN_VECTORS,
4264 },
4265 - [MT_MEMORY] = {
4266 + [MT_MEMORY_RWX] = {
4267 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4268 .prot_l1 = PMD_TYPE_TABLE,
4269 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4270 .domain = DOMAIN_KERNEL,
4271 },
4272 + [MT_MEMORY_RW] = {
4273 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4274 + .prot_l1 = PMD_TYPE_TABLE,
4275 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4276 + .domain = DOMAIN_KERNEL,
4277 + },
4278 + [MT_MEMORY_RX] = {
4279 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4280 + .prot_l1 = PMD_TYPE_TABLE,
4281 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4282 + .domain = DOMAIN_KERNEL,
4283 + },
4284 [MT_ROM] = {
4285 - .prot_sect = PMD_TYPE_SECT,
4286 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4287 .domain = DOMAIN_KERNEL,
4288 },
4289 - [MT_MEMORY_NONCACHED] = {
4290 + [MT_MEMORY_NONCACHED_RW] = {
4291 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4292 L_PTE_MT_BUFFERABLE,
4293 .prot_l1 = PMD_TYPE_TABLE,
4294 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4295 .domain = DOMAIN_KERNEL,
4296 },
4297 + [MT_MEMORY_NONCACHED_RX] = {
4298 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4299 + L_PTE_MT_BUFFERABLE,
4300 + .prot_l1 = PMD_TYPE_TABLE,
4301 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4302 + .domain = DOMAIN_KERNEL,
4303 + },
4304 [MT_MEMORY_DTCM] = {
4305 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4306 - L_PTE_XN,
4307 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4308 .prot_l1 = PMD_TYPE_TABLE,
4309 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4310 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4311 .domain = DOMAIN_KERNEL,
4312 },
4313 [MT_MEMORY_ITCM] = {
4314 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4315 },
4316 [MT_MEMORY_SO] = {
4317 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4318 - L_PTE_MT_UNCACHED | L_PTE_XN,
4319 + L_PTE_MT_UNCACHED,
4320 .prot_l1 = PMD_TYPE_TABLE,
4321 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4322 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4323 + PMD_SECT_UNCACHED,
4324 .domain = DOMAIN_KERNEL,
4325 },
4326 [MT_MEMORY_DMA_READY] = {
4327 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4328 * to prevent speculative instruction fetches.
4329 */
4330 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4331 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4332 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4333 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4334 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4335 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4336 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4337 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4338 +
4339 + /* Mark other regions on ARMv6+ as execute-never */
4340 +
4341 +#ifdef CONFIG_PAX_KERNEXEC
4342 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4343 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4344 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4345 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4346 +#ifndef CONFIG_ARM_LPAE
4347 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4348 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4349 +#endif
4350 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4351 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4352 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4353 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4354 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4355 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4356 +#endif
4357 +
4358 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4359 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4360 }
4361 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4362 /*
4363 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4364 * from SVC mode and no access from userspace.
4365 */
4366 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4367 +#ifdef CONFIG_PAX_KERNEXEC
4368 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4369 +#endif
4370 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4371 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4372 #endif
4373 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4374 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4375 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4376 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4377 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4378 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4379 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4380 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4381 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4382 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4383 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4384 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4385 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4386 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4387 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4388 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4389 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4390 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4391 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4392 }
4393 }
4394
4395 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4396 if (cpu_arch >= CPU_ARCH_ARMv6) {
4397 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4398 /* Non-cacheable Normal is XCB = 001 */
4399 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4400 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4401 + PMD_SECT_BUFFERED;
4402 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4403 PMD_SECT_BUFFERED;
4404 } else {
4405 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4406 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4407 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4408 + PMD_SECT_TEX(1);
4409 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4410 PMD_SECT_TEX(1);
4411 }
4412 } else {
4413 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4414 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4415 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4416 }
4417
4418 #ifdef CONFIG_ARM_LPAE
4419 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4420 vecs_pgprot |= PTE_EXT_AF;
4421 #endif
4422
4423 + user_pgprot |= __supported_pte_mask;
4424 +
4425 for (i = 0; i < 16; i++) {
4426 pteval_t v = pgprot_val(protection_map[i]);
4427 protection_map[i] = __pgprot(v | user_pgprot);
4428 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4429
4430 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4431 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4432 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4433 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4434 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4435 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4436 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4437 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4438 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4439 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4440 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4441 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4442 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4443 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4444 mem_types[MT_ROM].prot_sect |= cp->pmd;
4445
4446 switch (cp->pmd) {
4447 @@ -1166,18 +1255,15 @@ void __init arm_mm_memblock_reserve(void)
4448 * called function. This means you can't use any function or debugging
4449 * method which may touch any device, otherwise the kernel _will_ crash.
4450 */
4451 +
4452 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4453 +
4454 static void __init devicemaps_init(struct machine_desc *mdesc)
4455 {
4456 struct map_desc map;
4457 unsigned long addr;
4458 - void *vectors;
4459
4460 - /*
4461 - * Allocate the vector page early.
4462 - */
4463 - vectors = early_alloc(PAGE_SIZE * 2);
4464 -
4465 - early_trap_init(vectors);
4466 + early_trap_init(&vectors);
4467
4468 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4469 pmd_clear(pmd_off_k(addr));
4470 @@ -1217,7 +1303,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4471 * location (0xffff0000). If we aren't using high-vectors, also
4472 * create a mapping at the low-vectors virtual address.
4473 */
4474 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4475 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4476 map.virtual = 0xffff0000;
4477 map.length = PAGE_SIZE;
4478 #ifdef CONFIG_KUSER_HELPERS
4479 @@ -1287,8 +1373,39 @@ static void __init map_lowmem(void)
4480 map.pfn = __phys_to_pfn(start);
4481 map.virtual = __phys_to_virt(start);
4482 map.length = end - start;
4483 - map.type = MT_MEMORY;
4484
4485 +#ifdef CONFIG_PAX_KERNEXEC
4486 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4487 + struct map_desc kernel;
4488 + struct map_desc initmap;
4489 +
4490 + /* when freeing initmem we will make this RW */
4491 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4492 + initmap.virtual = (unsigned long)__init_begin;
4493 + initmap.length = _sdata - __init_begin;
4494 + initmap.type = MT_MEMORY_RWX;
4495 + create_mapping(&initmap);
4496 +
4497 + /* when freeing initmem we will make this RX */
4498 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4499 + kernel.virtual = (unsigned long)_stext;
4500 + kernel.length = __init_begin - _stext;
4501 + kernel.type = MT_MEMORY_RWX;
4502 + create_mapping(&kernel);
4503 +
4504 + if (map.virtual < (unsigned long)_stext) {
4505 + map.length = (unsigned long)_stext - map.virtual;
4506 + map.type = MT_MEMORY_RWX;
4507 + create_mapping(&map);
4508 + }
4509 +
4510 + map.pfn = __phys_to_pfn(__pa(_sdata));
4511 + map.virtual = (unsigned long)_sdata;
4512 + map.length = end - __pa(_sdata);
4513 + }
4514 +#endif
4515 +
4516 + map.type = MT_MEMORY_RW;
4517 create_mapping(&map);
4518 }
4519 }
4520 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4521 index a5bc92d..0bb4730 100644
4522 --- a/arch/arm/plat-omap/sram.c
4523 +++ b/arch/arm/plat-omap/sram.c
4524 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4525 * Looks like we need to preserve some bootloader code at the
4526 * beginning of SRAM for jumping to flash for reboot to work...
4527 */
4528 + pax_open_kernel();
4529 memset_io(omap_sram_base + omap_sram_skip, 0,
4530 omap_sram_size - omap_sram_skip);
4531 + pax_close_kernel();
4532 }
4533 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4534 index ce6d763..cfea917 100644
4535 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4536 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4537 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4538 int (*started)(unsigned ch);
4539 int (*flush)(unsigned ch);
4540 int (*stop)(unsigned ch);
4541 -};
4542 +} __no_const;
4543
4544 extern void *samsung_dmadev_get_ops(void);
4545 extern void *s3c_dma_get_ops(void);
4546 diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
4547 index 654f096..5546653 100644
4548 --- a/arch/arm64/include/asm/tlb.h
4549 +++ b/arch/arm64/include/asm/tlb.h
4550 @@ -35,6 +35,7 @@ struct mmu_gather {
4551 struct mm_struct *mm;
4552 unsigned int fullmm;
4553 struct vm_area_struct *vma;
4554 + unsigned long start, end;
4555 unsigned long range_start;
4556 unsigned long range_end;
4557 unsigned int nr;
4558 @@ -97,10 +98,12 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb)
4559 }
4560
4561 static inline void
4562 -tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int fullmm)
4563 +tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
4564 {
4565 tlb->mm = mm;
4566 - tlb->fullmm = fullmm;
4567 + tlb->fullmm = !(start | (end+1));
4568 + tlb->start = start;
4569 + tlb->end = end;
4570 tlb->vma = NULL;
4571 tlb->max = ARRAY_SIZE(tlb->local);
4572 tlb->pages = tlb->local;
4573 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4574 index f4726dc..39ed646 100644
4575 --- a/arch/arm64/kernel/debug-monitors.c
4576 +++ b/arch/arm64/kernel/debug-monitors.c
4577 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4578 return NOTIFY_OK;
4579 }
4580
4581 -static struct notifier_block __cpuinitdata os_lock_nb = {
4582 +static struct notifier_block os_lock_nb = {
4583 .notifier_call = os_lock_notify,
4584 };
4585
4586 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4587 index 5ab825c..96aaec8 100644
4588 --- a/arch/arm64/kernel/hw_breakpoint.c
4589 +++ b/arch/arm64/kernel/hw_breakpoint.c
4590 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4591 return NOTIFY_OK;
4592 }
4593
4594 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4595 +static struct notifier_block hw_breakpoint_reset_nb = {
4596 .notifier_call = hw_breakpoint_reset_notify,
4597 };
4598
4599 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4600 index c3a58a1..78fbf54 100644
4601 --- a/arch/avr32/include/asm/cache.h
4602 +++ b/arch/avr32/include/asm/cache.h
4603 @@ -1,8 +1,10 @@
4604 #ifndef __ASM_AVR32_CACHE_H
4605 #define __ASM_AVR32_CACHE_H
4606
4607 +#include <linux/const.h>
4608 +
4609 #define L1_CACHE_SHIFT 5
4610 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4611 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4612
4613 /*
4614 * Memory returned by kmalloc() may be used for DMA, so we must make
4615 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4616 index d232888..87c8df1 100644
4617 --- a/arch/avr32/include/asm/elf.h
4618 +++ b/arch/avr32/include/asm/elf.h
4619 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4620 the loader. We need to make sure that it is out of the way of the program
4621 that it will "exec", and that there is sufficient room for the brk. */
4622
4623 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4624 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4625
4626 +#ifdef CONFIG_PAX_ASLR
4627 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4628 +
4629 +#define PAX_DELTA_MMAP_LEN 15
4630 +#define PAX_DELTA_STACK_LEN 15
4631 +#endif
4632
4633 /* This yields a mask that user programs can use to figure out what
4634 instruction set this CPU supports. This could be done in user space,
4635 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4636 index 479330b..53717a8 100644
4637 --- a/arch/avr32/include/asm/kmap_types.h
4638 +++ b/arch/avr32/include/asm/kmap_types.h
4639 @@ -2,9 +2,9 @@
4640 #define __ASM_AVR32_KMAP_TYPES_H
4641
4642 #ifdef CONFIG_DEBUG_HIGHMEM
4643 -# define KM_TYPE_NR 29
4644 +# define KM_TYPE_NR 30
4645 #else
4646 -# define KM_TYPE_NR 14
4647 +# define KM_TYPE_NR 15
4648 #endif
4649
4650 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4651 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4652 index b2f2d2d..d1c85cb 100644
4653 --- a/arch/avr32/mm/fault.c
4654 +++ b/arch/avr32/mm/fault.c
4655 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4656
4657 int exception_trace = 1;
4658
4659 +#ifdef CONFIG_PAX_PAGEEXEC
4660 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4661 +{
4662 + unsigned long i;
4663 +
4664 + printk(KERN_ERR "PAX: bytes at PC: ");
4665 + for (i = 0; i < 20; i++) {
4666 + unsigned char c;
4667 + if (get_user(c, (unsigned char *)pc+i))
4668 + printk(KERN_CONT "???????? ");
4669 + else
4670 + printk(KERN_CONT "%02x ", c);
4671 + }
4672 + printk("\n");
4673 +}
4674 +#endif
4675 +
4676 /*
4677 * This routine handles page faults. It determines the address and the
4678 * problem, and then passes it off to one of the appropriate routines.
4679 @@ -174,6 +191,16 @@ bad_area:
4680 up_read(&mm->mmap_sem);
4681
4682 if (user_mode(regs)) {
4683 +
4684 +#ifdef CONFIG_PAX_PAGEEXEC
4685 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4686 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4687 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4688 + do_group_exit(SIGKILL);
4689 + }
4690 + }
4691 +#endif
4692 +
4693 if (exception_trace && printk_ratelimit())
4694 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4695 "sp %08lx ecr %lu\n",
4696 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4697 index 568885a..f8008df 100644
4698 --- a/arch/blackfin/include/asm/cache.h
4699 +++ b/arch/blackfin/include/asm/cache.h
4700 @@ -7,6 +7,7 @@
4701 #ifndef __ARCH_BLACKFIN_CACHE_H
4702 #define __ARCH_BLACKFIN_CACHE_H
4703
4704 +#include <linux/const.h>
4705 #include <linux/linkage.h> /* for asmlinkage */
4706
4707 /*
4708 @@ -14,7 +15,7 @@
4709 * Blackfin loads 32 bytes for cache
4710 */
4711 #define L1_CACHE_SHIFT 5
4712 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4713 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4714 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4715
4716 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4717 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4718 index aea2718..3639a60 100644
4719 --- a/arch/cris/include/arch-v10/arch/cache.h
4720 +++ b/arch/cris/include/arch-v10/arch/cache.h
4721 @@ -1,8 +1,9 @@
4722 #ifndef _ASM_ARCH_CACHE_H
4723 #define _ASM_ARCH_CACHE_H
4724
4725 +#include <linux/const.h>
4726 /* Etrax 100LX have 32-byte cache-lines. */
4727 -#define L1_CACHE_BYTES 32
4728 #define L1_CACHE_SHIFT 5
4729 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4730
4731 #endif /* _ASM_ARCH_CACHE_H */
4732 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4733 index 7caf25d..ee65ac5 100644
4734 --- a/arch/cris/include/arch-v32/arch/cache.h
4735 +++ b/arch/cris/include/arch-v32/arch/cache.h
4736 @@ -1,11 +1,12 @@
4737 #ifndef _ASM_CRIS_ARCH_CACHE_H
4738 #define _ASM_CRIS_ARCH_CACHE_H
4739
4740 +#include <linux/const.h>
4741 #include <arch/hwregs/dma.h>
4742
4743 /* A cache-line is 32 bytes. */
4744 -#define L1_CACHE_BYTES 32
4745 #define L1_CACHE_SHIFT 5
4746 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4747
4748 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4749
4750 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4751 index b86329d..6709906 100644
4752 --- a/arch/frv/include/asm/atomic.h
4753 +++ b/arch/frv/include/asm/atomic.h
4754 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4755 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4756 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4757
4758 +#define atomic64_read_unchecked(v) atomic64_read(v)
4759 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4760 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4761 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4762 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4763 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4764 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4765 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4766 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4767 +
4768 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4769 {
4770 int c, old;
4771 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4772 index 2797163..c2a401d 100644
4773 --- a/arch/frv/include/asm/cache.h
4774 +++ b/arch/frv/include/asm/cache.h
4775 @@ -12,10 +12,11 @@
4776 #ifndef __ASM_CACHE_H
4777 #define __ASM_CACHE_H
4778
4779 +#include <linux/const.h>
4780
4781 /* bytes per L1 cache line */
4782 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4783 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4784 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4785
4786 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4787 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4788 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4789 index 43901f2..0d8b865 100644
4790 --- a/arch/frv/include/asm/kmap_types.h
4791 +++ b/arch/frv/include/asm/kmap_types.h
4792 @@ -2,6 +2,6 @@
4793 #ifndef _ASM_KMAP_TYPES_H
4794 #define _ASM_KMAP_TYPES_H
4795
4796 -#define KM_TYPE_NR 17
4797 +#define KM_TYPE_NR 18
4798
4799 #endif
4800 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4801 index 836f147..4cf23f5 100644
4802 --- a/arch/frv/mm/elf-fdpic.c
4803 +++ b/arch/frv/mm/elf-fdpic.c
4804 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4805 {
4806 struct vm_area_struct *vma;
4807 struct vm_unmapped_area_info info;
4808 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4809
4810 if (len > TASK_SIZE)
4811 return -ENOMEM;
4812 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4813 if (addr) {
4814 addr = PAGE_ALIGN(addr);
4815 vma = find_vma(current->mm, addr);
4816 - if (TASK_SIZE - len >= addr &&
4817 - (!vma || addr + len <= vma->vm_start))
4818 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4819 goto success;
4820 }
4821
4822 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4823 info.high_limit = (current->mm->start_stack - 0x00200000);
4824 info.align_mask = 0;
4825 info.align_offset = 0;
4826 + info.threadstack_offset = offset;
4827 addr = vm_unmapped_area(&info);
4828 if (!(addr & ~PAGE_MASK))
4829 goto success;
4830 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4831 index f4ca594..adc72fd6 100644
4832 --- a/arch/hexagon/include/asm/cache.h
4833 +++ b/arch/hexagon/include/asm/cache.h
4834 @@ -21,9 +21,11 @@
4835 #ifndef __ASM_CACHE_H
4836 #define __ASM_CACHE_H
4837
4838 +#include <linux/const.h>
4839 +
4840 /* Bytes per L1 cache line */
4841 -#define L1_CACHE_SHIFT (5)
4842 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4843 +#define L1_CACHE_SHIFT 5
4844 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4845
4846 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4847 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4848 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4849 index 6e6fe18..a6ae668 100644
4850 --- a/arch/ia64/include/asm/atomic.h
4851 +++ b/arch/ia64/include/asm/atomic.h
4852 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4853 #define atomic64_inc(v) atomic64_add(1, (v))
4854 #define atomic64_dec(v) atomic64_sub(1, (v))
4855
4856 +#define atomic64_read_unchecked(v) atomic64_read(v)
4857 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4858 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4859 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4860 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4861 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4862 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4863 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4864 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4865 +
4866 /* Atomic operations are already serializing */
4867 #define smp_mb__before_atomic_dec() barrier()
4868 #define smp_mb__after_atomic_dec() barrier()
4869 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4870 index 988254a..e1ee885 100644
4871 --- a/arch/ia64/include/asm/cache.h
4872 +++ b/arch/ia64/include/asm/cache.h
4873 @@ -1,6 +1,7 @@
4874 #ifndef _ASM_IA64_CACHE_H
4875 #define _ASM_IA64_CACHE_H
4876
4877 +#include <linux/const.h>
4878
4879 /*
4880 * Copyright (C) 1998-2000 Hewlett-Packard Co
4881 @@ -9,7 +10,7 @@
4882
4883 /* Bytes per L1 (data) cache line. */
4884 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4885 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4886 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4887
4888 #ifdef CONFIG_SMP
4889 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4890 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4891 index 5a83c5c..4d7f553 100644
4892 --- a/arch/ia64/include/asm/elf.h
4893 +++ b/arch/ia64/include/asm/elf.h
4894 @@ -42,6 +42,13 @@
4895 */
4896 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4897
4898 +#ifdef CONFIG_PAX_ASLR
4899 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4900 +
4901 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4902 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4903 +#endif
4904 +
4905 #define PT_IA_64_UNWIND 0x70000001
4906
4907 /* IA-64 relocations: */
4908 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4909 index 96a8d92..617a1cf 100644
4910 --- a/arch/ia64/include/asm/pgalloc.h
4911 +++ b/arch/ia64/include/asm/pgalloc.h
4912 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4913 pgd_val(*pgd_entry) = __pa(pud);
4914 }
4915
4916 +static inline void
4917 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4918 +{
4919 + pgd_populate(mm, pgd_entry, pud);
4920 +}
4921 +
4922 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4923 {
4924 return quicklist_alloc(0, GFP_KERNEL, NULL);
4925 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4926 pud_val(*pud_entry) = __pa(pmd);
4927 }
4928
4929 +static inline void
4930 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4931 +{
4932 + pud_populate(mm, pud_entry, pmd);
4933 +}
4934 +
4935 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4936 {
4937 return quicklist_alloc(0, GFP_KERNEL, NULL);
4938 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4939 index 815810c..d60bd4c 100644
4940 --- a/arch/ia64/include/asm/pgtable.h
4941 +++ b/arch/ia64/include/asm/pgtable.h
4942 @@ -12,7 +12,7 @@
4943 * David Mosberger-Tang <davidm@hpl.hp.com>
4944 */
4945
4946 -
4947 +#include <linux/const.h>
4948 #include <asm/mman.h>
4949 #include <asm/page.h>
4950 #include <asm/processor.h>
4951 @@ -142,6 +142,17 @@
4952 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4953 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4954 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4955 +
4956 +#ifdef CONFIG_PAX_PAGEEXEC
4957 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4958 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4959 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4960 +#else
4961 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4962 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4963 +# define PAGE_COPY_NOEXEC PAGE_COPY
4964 +#endif
4965 +
4966 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4967 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4968 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4969 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4970 index 54ff557..70c88b7 100644
4971 --- a/arch/ia64/include/asm/spinlock.h
4972 +++ b/arch/ia64/include/asm/spinlock.h
4973 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4974 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4975
4976 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4977 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4978 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4979 }
4980
4981 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4982 diff --git a/arch/ia64/include/asm/tlb.h b/arch/ia64/include/asm/tlb.h
4983 index ef3a9de..bc5efc7 100644
4984 --- a/arch/ia64/include/asm/tlb.h
4985 +++ b/arch/ia64/include/asm/tlb.h
4986 @@ -22,7 +22,7 @@
4987 * unmapping a portion of the virtual address space, these hooks are called according to
4988 * the following template:
4989 *
4990 - * tlb <- tlb_gather_mmu(mm, full_mm_flush); // start unmap for address space MM
4991 + * tlb <- tlb_gather_mmu(mm, start, end); // start unmap for address space MM
4992 * {
4993 * for each vma that needs a shootdown do {
4994 * tlb_start_vma(tlb, vma);
4995 @@ -58,6 +58,7 @@ struct mmu_gather {
4996 unsigned int max;
4997 unsigned char fullmm; /* non-zero means full mm flush */
4998 unsigned char need_flush; /* really unmapped some PTEs? */
4999 + unsigned long start, end;
5000 unsigned long start_addr;
5001 unsigned long end_addr;
5002 struct page **pages;
5003 @@ -155,13 +156,15 @@ static inline void __tlb_alloc_page(struct mmu_gather *tlb)
5004
5005
5006 static inline void
5007 -tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int full_mm_flush)
5008 +tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
5009 {
5010 tlb->mm = mm;
5011 tlb->max = ARRAY_SIZE(tlb->local);
5012 tlb->pages = tlb->local;
5013 tlb->nr = 0;
5014 - tlb->fullmm = full_mm_flush;
5015 + tlb->fullmm = !(start | (end+1));
5016 + tlb->start = start;
5017 + tlb->end = end;
5018 tlb->start_addr = ~0UL;
5019 }
5020
5021 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5022 index 449c8c0..18965fb 100644
5023 --- a/arch/ia64/include/asm/uaccess.h
5024 +++ b/arch/ia64/include/asm/uaccess.h
5025 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5026 static inline unsigned long
5027 __copy_to_user (void __user *to, const void *from, unsigned long count)
5028 {
5029 + if (count > INT_MAX)
5030 + return count;
5031 +
5032 + if (!__builtin_constant_p(count))
5033 + check_object_size(from, count, true);
5034 +
5035 return __copy_user(to, (__force void __user *) from, count);
5036 }
5037
5038 static inline unsigned long
5039 __copy_from_user (void *to, const void __user *from, unsigned long count)
5040 {
5041 + if (count > INT_MAX)
5042 + return count;
5043 +
5044 + if (!__builtin_constant_p(count))
5045 + check_object_size(to, count, false);
5046 +
5047 return __copy_user((__force void __user *) to, from, count);
5048 }
5049
5050 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5051 ({ \
5052 void __user *__cu_to = (to); \
5053 const void *__cu_from = (from); \
5054 - long __cu_len = (n); \
5055 + unsigned long __cu_len = (n); \
5056 \
5057 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5058 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5059 + if (!__builtin_constant_p(n)) \
5060 + check_object_size(__cu_from, __cu_len, true); \
5061 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5062 + } \
5063 __cu_len; \
5064 })
5065
5066 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5067 ({ \
5068 void *__cu_to = (to); \
5069 const void __user *__cu_from = (from); \
5070 - long __cu_len = (n); \
5071 + unsigned long __cu_len = (n); \
5072 \
5073 __chk_user_ptr(__cu_from); \
5074 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5075 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5076 + if (!__builtin_constant_p(n)) \
5077 + check_object_size(__cu_to, __cu_len, false); \
5078 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5079 + } \
5080 __cu_len; \
5081 })
5082
5083 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
5084 index 2d67317..07d8bfa 100644
5085 --- a/arch/ia64/kernel/err_inject.c
5086 +++ b/arch/ia64/kernel/err_inject.c
5087 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
5088 return NOTIFY_OK;
5089 }
5090
5091 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
5092 +static struct notifier_block err_inject_cpu_notifier =
5093 {
5094 .notifier_call = err_inject_cpu_callback,
5095 };
5096 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
5097 index d7396db..b33e873 100644
5098 --- a/arch/ia64/kernel/mca.c
5099 +++ b/arch/ia64/kernel/mca.c
5100 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
5101 return NOTIFY_OK;
5102 }
5103
5104 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
5105 +static struct notifier_block mca_cpu_notifier = {
5106 .notifier_call = mca_cpu_callback
5107 };
5108
5109 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5110 index 24603be..948052d 100644
5111 --- a/arch/ia64/kernel/module.c
5112 +++ b/arch/ia64/kernel/module.c
5113 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5114 void
5115 module_free (struct module *mod, void *module_region)
5116 {
5117 - if (mod && mod->arch.init_unw_table &&
5118 - module_region == mod->module_init) {
5119 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5120 unw_remove_unwind_table(mod->arch.init_unw_table);
5121 mod->arch.init_unw_table = NULL;
5122 }
5123 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5124 }
5125
5126 static inline int
5127 +in_init_rx (const struct module *mod, uint64_t addr)
5128 +{
5129 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5130 +}
5131 +
5132 +static inline int
5133 +in_init_rw (const struct module *mod, uint64_t addr)
5134 +{
5135 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5136 +}
5137 +
5138 +static inline int
5139 in_init (const struct module *mod, uint64_t addr)
5140 {
5141 - return addr - (uint64_t) mod->module_init < mod->init_size;
5142 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5143 +}
5144 +
5145 +static inline int
5146 +in_core_rx (const struct module *mod, uint64_t addr)
5147 +{
5148 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5149 +}
5150 +
5151 +static inline int
5152 +in_core_rw (const struct module *mod, uint64_t addr)
5153 +{
5154 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5155 }
5156
5157 static inline int
5158 in_core (const struct module *mod, uint64_t addr)
5159 {
5160 - return addr - (uint64_t) mod->module_core < mod->core_size;
5161 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5162 }
5163
5164 static inline int
5165 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5166 break;
5167
5168 case RV_BDREL:
5169 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5170 + if (in_init_rx(mod, val))
5171 + val -= (uint64_t) mod->module_init_rx;
5172 + else if (in_init_rw(mod, val))
5173 + val -= (uint64_t) mod->module_init_rw;
5174 + else if (in_core_rx(mod, val))
5175 + val -= (uint64_t) mod->module_core_rx;
5176 + else if (in_core_rw(mod, val))
5177 + val -= (uint64_t) mod->module_core_rw;
5178 break;
5179
5180 case RV_LTV:
5181 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5182 * addresses have been selected...
5183 */
5184 uint64_t gp;
5185 - if (mod->core_size > MAX_LTOFF)
5186 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5187 /*
5188 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5189 * at the end of the module.
5190 */
5191 - gp = mod->core_size - MAX_LTOFF / 2;
5192 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5193 else
5194 - gp = mod->core_size / 2;
5195 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5196 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5197 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5198 mod->arch.gp = gp;
5199 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5200 }
5201 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5202 index 2b3c2d7..a318d84 100644
5203 --- a/arch/ia64/kernel/palinfo.c
5204 +++ b/arch/ia64/kernel/palinfo.c
5205 @@ -980,7 +980,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
5206 return NOTIFY_OK;
5207 }
5208
5209 -static struct notifier_block __refdata palinfo_cpu_notifier =
5210 +static struct notifier_block palinfo_cpu_notifier =
5211 {
5212 .notifier_call = palinfo_cpu_callback,
5213 .priority = 0,
5214 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
5215 index 4bc580a..7767f24 100644
5216 --- a/arch/ia64/kernel/salinfo.c
5217 +++ b/arch/ia64/kernel/salinfo.c
5218 @@ -609,7 +609,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
5219 return NOTIFY_OK;
5220 }
5221
5222 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5223 +static struct notifier_block salinfo_cpu_notifier =
5224 {
5225 .notifier_call = salinfo_cpu_callback,
5226 .priority = 0,
5227 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5228 index 41e33f8..65180b2 100644
5229 --- a/arch/ia64/kernel/sys_ia64.c
5230 +++ b/arch/ia64/kernel/sys_ia64.c
5231 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5232 unsigned long align_mask = 0;
5233 struct mm_struct *mm = current->mm;
5234 struct vm_unmapped_area_info info;
5235 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5236
5237 if (len > RGN_MAP_LIMIT)
5238 return -ENOMEM;
5239 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5240 if (REGION_NUMBER(addr) == RGN_HPAGE)
5241 addr = 0;
5242 #endif
5243 +
5244 +#ifdef CONFIG_PAX_RANDMMAP
5245 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5246 + addr = mm->free_area_cache;
5247 + else
5248 +#endif
5249 +
5250 if (!addr)
5251 addr = TASK_UNMAPPED_BASE;
5252
5253 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5254 info.high_limit = TASK_SIZE;
5255 info.align_mask = align_mask;
5256 info.align_offset = 0;
5257 + info.threadstack_offset = offset;
5258 return vm_unmapped_area(&info);
5259 }
5260
5261 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5262 index dc00b2c..cce53c2 100644
5263 --- a/arch/ia64/kernel/topology.c
5264 +++ b/arch/ia64/kernel/topology.c
5265 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5266 return NOTIFY_OK;
5267 }
5268
5269 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5270 +static struct notifier_block cache_cpu_notifier =
5271 {
5272 .notifier_call = cache_cpu_callback
5273 };
5274 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5275 index 0ccb28f..8992469 100644
5276 --- a/arch/ia64/kernel/vmlinux.lds.S
5277 +++ b/arch/ia64/kernel/vmlinux.lds.S
5278 @@ -198,7 +198,7 @@ SECTIONS {
5279 /* Per-cpu data: */
5280 . = ALIGN(PERCPU_PAGE_SIZE);
5281 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5282 - __phys_per_cpu_start = __per_cpu_load;
5283 + __phys_per_cpu_start = per_cpu_load;
5284 /*
5285 * ensure percpu data fits
5286 * into percpu page size
5287 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5288 index 6cf0341..d352594 100644
5289 --- a/arch/ia64/mm/fault.c
5290 +++ b/arch/ia64/mm/fault.c
5291 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5292 return pte_present(pte);
5293 }
5294
5295 +#ifdef CONFIG_PAX_PAGEEXEC
5296 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5297 +{
5298 + unsigned long i;
5299 +
5300 + printk(KERN_ERR "PAX: bytes at PC: ");
5301 + for (i = 0; i < 8; i++) {
5302 + unsigned int c;
5303 + if (get_user(c, (unsigned int *)pc+i))
5304 + printk(KERN_CONT "???????? ");
5305 + else
5306 + printk(KERN_CONT "%08x ", c);
5307 + }
5308 + printk("\n");
5309 +}
5310 +#endif
5311 +
5312 # define VM_READ_BIT 0
5313 # define VM_WRITE_BIT 1
5314 # define VM_EXEC_BIT 2
5315 @@ -149,8 +166,21 @@ retry:
5316 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5317 goto bad_area;
5318
5319 - if ((vma->vm_flags & mask) != mask)
5320 + if ((vma->vm_flags & mask) != mask) {
5321 +
5322 +#ifdef CONFIG_PAX_PAGEEXEC
5323 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5324 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5325 + goto bad_area;
5326 +
5327 + up_read(&mm->mmap_sem);
5328 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5329 + do_group_exit(SIGKILL);
5330 + }
5331 +#endif
5332 +
5333 goto bad_area;
5334 + }
5335
5336 /*
5337 * If for any reason at all we couldn't handle the fault, make
5338 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5339 index 76069c1..c2aa816 100644
5340 --- a/arch/ia64/mm/hugetlbpage.c
5341 +++ b/arch/ia64/mm/hugetlbpage.c
5342 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5343 unsigned long pgoff, unsigned long flags)
5344 {
5345 struct vm_unmapped_area_info info;
5346 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5347
5348 if (len > RGN_MAP_LIMIT)
5349 return -ENOMEM;
5350 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5351 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5352 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5353 info.align_offset = 0;
5354 + info.threadstack_offset = offset;
5355 return vm_unmapped_area(&info);
5356 }
5357
5358 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5359 index d1fe4b4..2628f37 100644
5360 --- a/arch/ia64/mm/init.c
5361 +++ b/arch/ia64/mm/init.c
5362 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5363 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5364 vma->vm_end = vma->vm_start + PAGE_SIZE;
5365 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5366 +
5367 +#ifdef CONFIG_PAX_PAGEEXEC
5368 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5369 + vma->vm_flags &= ~VM_EXEC;
5370 +
5371 +#ifdef CONFIG_PAX_MPROTECT
5372 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5373 + vma->vm_flags &= ~VM_MAYEXEC;
5374 +#endif
5375 +
5376 + }
5377 +#endif
5378 +
5379 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5380 down_write(&current->mm->mmap_sem);
5381 if (insert_vm_struct(current->mm, vma)) {
5382 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5383 index 40b3ee9..8c2c112 100644
5384 --- a/arch/m32r/include/asm/cache.h
5385 +++ b/arch/m32r/include/asm/cache.h
5386 @@ -1,8 +1,10 @@
5387 #ifndef _ASM_M32R_CACHE_H
5388 #define _ASM_M32R_CACHE_H
5389
5390 +#include <linux/const.h>
5391 +
5392 /* L1 cache line size */
5393 #define L1_CACHE_SHIFT 4
5394 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5395 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5396
5397 #endif /* _ASM_M32R_CACHE_H */
5398 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5399 index 82abd15..d95ae5d 100644
5400 --- a/arch/m32r/lib/usercopy.c
5401 +++ b/arch/m32r/lib/usercopy.c
5402 @@ -14,6 +14,9 @@
5403 unsigned long
5404 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5405 {
5406 + if ((long)n < 0)
5407 + return n;
5408 +
5409 prefetch(from);
5410 if (access_ok(VERIFY_WRITE, to, n))
5411 __copy_user(to,from,n);
5412 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5413 unsigned long
5414 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5415 {
5416 + if ((long)n < 0)
5417 + return n;
5418 +
5419 prefetchw(to);
5420 if (access_ok(VERIFY_READ, from, n))
5421 __copy_user_zeroing(to,from,n);
5422 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5423 index 0395c51..5f26031 100644
5424 --- a/arch/m68k/include/asm/cache.h
5425 +++ b/arch/m68k/include/asm/cache.h
5426 @@ -4,9 +4,11 @@
5427 #ifndef __ARCH_M68K_CACHE_H
5428 #define __ARCH_M68K_CACHE_H
5429
5430 +#include <linux/const.h>
5431 +
5432 /* bytes per L1 cache line */
5433 #define L1_CACHE_SHIFT 4
5434 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5435 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5436
5437 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5438
5439 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5440 index 3c52fa6..11b2ad8 100644
5441 --- a/arch/metag/mm/hugetlbpage.c
5442 +++ b/arch/metag/mm/hugetlbpage.c
5443 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5444 info.high_limit = TASK_SIZE;
5445 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5446 info.align_offset = 0;
5447 + info.threadstack_offset = 0;
5448 return vm_unmapped_area(&info);
5449 }
5450
5451 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5452 index 4efe96a..60e8699 100644
5453 --- a/arch/microblaze/include/asm/cache.h
5454 +++ b/arch/microblaze/include/asm/cache.h
5455 @@ -13,11 +13,12 @@
5456 #ifndef _ASM_MICROBLAZE_CACHE_H
5457 #define _ASM_MICROBLAZE_CACHE_H
5458
5459 +#include <linux/const.h>
5460 #include <asm/registers.h>
5461
5462 #define L1_CACHE_SHIFT 5
5463 /* word-granular cache in microblaze */
5464 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5465 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5466
5467 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5468
5469 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5470 index 08b6079..eb272cf 100644
5471 --- a/arch/mips/include/asm/atomic.h
5472 +++ b/arch/mips/include/asm/atomic.h
5473 @@ -21,6 +21,10 @@
5474 #include <asm/cmpxchg.h>
5475 #include <asm/war.h>
5476
5477 +#ifdef CONFIG_GENERIC_ATOMIC64
5478 +#include <asm-generic/atomic64.h>
5479 +#endif
5480 +
5481 #define ATOMIC_INIT(i) { (i) }
5482
5483 /*
5484 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5485 */
5486 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5487
5488 +#define atomic64_read_unchecked(v) atomic64_read(v)
5489 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5490 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5491 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5492 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5493 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5494 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5495 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5496 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5497 +
5498 #endif /* CONFIG_64BIT */
5499
5500 /*
5501 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5502 index b4db69f..8f3b093 100644
5503 --- a/arch/mips/include/asm/cache.h
5504 +++ b/arch/mips/include/asm/cache.h
5505 @@ -9,10 +9,11 @@
5506 #ifndef _ASM_CACHE_H
5507 #define _ASM_CACHE_H
5508
5509 +#include <linux/const.h>
5510 #include <kmalloc.h>
5511
5512 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5513 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5514 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5515
5516 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5517 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5518 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5519 index cf3ae24..238d22f 100644
5520 --- a/arch/mips/include/asm/elf.h
5521 +++ b/arch/mips/include/asm/elf.h
5522 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5523 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5524 #endif
5525
5526 +#ifdef CONFIG_PAX_ASLR
5527 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5528 +
5529 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5530 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5531 +#endif
5532 +
5533 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5534 struct linux_binprm;
5535 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5536 int uses_interp);
5537
5538 -struct mm_struct;
5539 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5540 -#define arch_randomize_brk arch_randomize_brk
5541 -
5542 #endif /* _ASM_ELF_H */
5543 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5544 index c1f6afa..38cc6e9 100644
5545 --- a/arch/mips/include/asm/exec.h
5546 +++ b/arch/mips/include/asm/exec.h
5547 @@ -12,6 +12,6 @@
5548 #ifndef _ASM_EXEC_H
5549 #define _ASM_EXEC_H
5550
5551 -extern unsigned long arch_align_stack(unsigned long sp);
5552 +#define arch_align_stack(x) ((x) & ~0xfUL)
5553
5554 #endif /* _ASM_EXEC_H */
5555 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
5556 index d44622c..64990d2 100644
5557 --- a/arch/mips/include/asm/local.h
5558 +++ b/arch/mips/include/asm/local.h
5559 @@ -12,15 +12,25 @@ typedef struct
5560 atomic_long_t a;
5561 } local_t;
5562
5563 +typedef struct {
5564 + atomic_long_unchecked_t a;
5565 +} local_unchecked_t;
5566 +
5567 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
5568
5569 #define local_read(l) atomic_long_read(&(l)->a)
5570 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
5571 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
5572 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
5573
5574 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
5575 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
5576 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
5577 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
5578 #define local_inc(l) atomic_long_inc(&(l)->a)
5579 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
5580 #define local_dec(l) atomic_long_dec(&(l)->a)
5581 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
5582
5583 /*
5584 * Same as above, but return the result value
5585 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
5586 return result;
5587 }
5588
5589 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
5590 +{
5591 + unsigned long result;
5592 +
5593 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5594 + unsigned long temp;
5595 +
5596 + __asm__ __volatile__(
5597 + " .set mips3 \n"
5598 + "1:" __LL "%1, %2 # local_add_return \n"
5599 + " addu %0, %1, %3 \n"
5600 + __SC "%0, %2 \n"
5601 + " beqzl %0, 1b \n"
5602 + " addu %0, %1, %3 \n"
5603 + " .set mips0 \n"
5604 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
5605 + : "Ir" (i), "m" (l->a.counter)
5606 + : "memory");
5607 + } else if (kernel_uses_llsc) {
5608 + unsigned long temp;
5609 +
5610 + __asm__ __volatile__(
5611 + " .set mips3 \n"
5612 + "1:" __LL "%1, %2 # local_add_return \n"
5613 + " addu %0, %1, %3 \n"
5614 + __SC "%0, %2 \n"
5615 + " beqz %0, 1b \n"
5616 + " addu %0, %1, %3 \n"
5617 + " .set mips0 \n"
5618 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
5619 + : "Ir" (i), "m" (l->a.counter)
5620 + : "memory");
5621 + } else {
5622 + unsigned long flags;
5623 +
5624 + local_irq_save(flags);
5625 + result = l->a.counter;
5626 + result += i;
5627 + l->a.counter = result;
5628 + local_irq_restore(flags);
5629 + }
5630 +
5631 + return result;
5632 +}
5633 +
5634 static __inline__ long local_sub_return(long i, local_t * l)
5635 {
5636 unsigned long result;
5637 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
5638
5639 #define local_cmpxchg(l, o, n) \
5640 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
5641 +#define local_cmpxchg_unchecked(l, o, n) \
5642 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
5643 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
5644
5645 /**
5646 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5647 index f59552f..3abe9b9 100644
5648 --- a/arch/mips/include/asm/page.h
5649 +++ b/arch/mips/include/asm/page.h
5650 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5651 #ifdef CONFIG_CPU_MIPS32
5652 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5653 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5654 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5655 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5656 #else
5657 typedef struct { unsigned long long pte; } pte_t;
5658 #define pte_val(x) ((x).pte)
5659 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5660 index 881d18b..cea38bc 100644
5661 --- a/arch/mips/include/asm/pgalloc.h
5662 +++ b/arch/mips/include/asm/pgalloc.h
5663 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5664 {
5665 set_pud(pud, __pud((unsigned long)pmd));
5666 }
5667 +
5668 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5669 +{
5670 + pud_populate(mm, pud, pmd);
5671 +}
5672 #endif
5673
5674 /*
5675 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5676 index 895320e..bf63e10 100644
5677 --- a/arch/mips/include/asm/thread_info.h
5678 +++ b/arch/mips/include/asm/thread_info.h
5679 @@ -115,6 +115,8 @@ static inline struct thread_info *current_thread_info(void)
5680 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5681 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5682 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5683 +/* li takes a 32bit immediate */
5684 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5685 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5686
5687 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5688 @@ -130,15 +132,18 @@ static inline struct thread_info *current_thread_info(void)
5689 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5690 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5691 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5692 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5693 +
5694 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5695
5696 /* work to do in syscall_trace_leave() */
5697 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5698 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5699
5700 /* work to do on interrupt/exception return */
5701 #define _TIF_WORK_MASK \
5702 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5703 /* work to do on any return to u-space */
5704 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5705 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5706
5707 #endif /* __KERNEL__ */
5708
5709 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5710 index 1188e00..41cf144 100644
5711 --- a/arch/mips/kernel/binfmt_elfn32.c
5712 +++ b/arch/mips/kernel/binfmt_elfn32.c
5713 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5714 #undef ELF_ET_DYN_BASE
5715 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5716
5717 +#ifdef CONFIG_PAX_ASLR
5718 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5719 +
5720 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5721 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5722 +#endif
5723 +
5724 #include <asm/processor.h>
5725 #include <linux/module.h>
5726 #include <linux/elfcore.h>
5727 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5728 index 202e581..689ca79 100644
5729 --- a/arch/mips/kernel/binfmt_elfo32.c
5730 +++ b/arch/mips/kernel/binfmt_elfo32.c
5731 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5732 #undef ELF_ET_DYN_BASE
5733 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5734
5735 +#ifdef CONFIG_PAX_ASLR
5736 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5737 +
5738 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5739 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5740 +#endif
5741 +
5742 #include <asm/processor.h>
5743
5744 /*
5745 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5746 index c6a041d..b3e7318 100644
5747 --- a/arch/mips/kernel/process.c
5748 +++ b/arch/mips/kernel/process.c
5749 @@ -563,15 +563,3 @@ unsigned long get_wchan(struct task_struct *task)
5750 out:
5751 return pc;
5752 }
5753 -
5754 -/*
5755 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5756 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5757 - */
5758 -unsigned long arch_align_stack(unsigned long sp)
5759 -{
5760 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5761 - sp -= get_random_int() & ~PAGE_MASK;
5762 -
5763 - return sp & ALMASK;
5764 -}
5765 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5766 index 9c6299c..2fb4c22 100644
5767 --- a/arch/mips/kernel/ptrace.c
5768 +++ b/arch/mips/kernel/ptrace.c
5769 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5770 return arch;
5771 }
5772
5773 +#ifdef CONFIG_GRKERNSEC_SETXID
5774 +extern void gr_delayed_cred_worker(void);
5775 +#endif
5776 +
5777 /*
5778 * Notification of system call entry/exit
5779 * - triggered by current->work.syscall_trace
5780 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5781 /* do the secure computing check first */
5782 secure_computing_strict(regs->regs[2]);
5783
5784 +#ifdef CONFIG_GRKERNSEC_SETXID
5785 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5786 + gr_delayed_cred_worker();
5787 +#endif
5788 +
5789 if (!(current->ptrace & PT_PTRACED))
5790 goto out;
5791
5792 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5793 index 9b36424..e7f4154 100644
5794 --- a/arch/mips/kernel/scall32-o32.S
5795 +++ b/arch/mips/kernel/scall32-o32.S
5796 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5797
5798 stack_done:
5799 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5800 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5801 + li t1, _TIF_SYSCALL_WORK
5802 and t0, t1
5803 bnez t0, syscall_trace_entry # -> yes
5804
5805 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5806 index 97a5909..59622f8 100644
5807 --- a/arch/mips/kernel/scall64-64.S
5808 +++ b/arch/mips/kernel/scall64-64.S
5809 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5810
5811 sd a3, PT_R26(sp) # save a3 for syscall restarting
5812
5813 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5814 + li t1, _TIF_SYSCALL_WORK
5815 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5816 and t0, t1, t0
5817 bnez t0, syscall_trace_entry
5818 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5819 index edcb659..fb2ab09 100644
5820 --- a/arch/mips/kernel/scall64-n32.S
5821 +++ b/arch/mips/kernel/scall64-n32.S
5822 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5823
5824 sd a3, PT_R26(sp) # save a3 for syscall restarting
5825
5826 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5827 + li t1, _TIF_SYSCALL_WORK
5828 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5829 and t0, t1, t0
5830 bnez t0, n32_syscall_trace_entry
5831 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5832 index 74f485d..47d2c38 100644
5833 --- a/arch/mips/kernel/scall64-o32.S
5834 +++ b/arch/mips/kernel/scall64-o32.S
5835 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5836 PTR 4b, bad_stack
5837 .previous
5838
5839 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5840 + li t1, _TIF_SYSCALL_WORK
5841 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5842 and t0, t1, t0
5843 bnez t0, trace_a_syscall
5844 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5845 index 0fead53..eeb00a6 100644
5846 --- a/arch/mips/mm/fault.c
5847 +++ b/arch/mips/mm/fault.c
5848 @@ -27,6 +27,23 @@
5849 #include <asm/highmem.h> /* For VMALLOC_END */
5850 #include <linux/kdebug.h>
5851
5852 +#ifdef CONFIG_PAX_PAGEEXEC
5853 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5854 +{
5855 + unsigned long i;
5856 +
5857 + printk(KERN_ERR "PAX: bytes at PC: ");
5858 + for (i = 0; i < 5; i++) {
5859 + unsigned int c;
5860 + if (get_user(c, (unsigned int *)pc+i))
5861 + printk(KERN_CONT "???????? ");
5862 + else
5863 + printk(KERN_CONT "%08x ", c);
5864 + }
5865 + printk("\n");
5866 +}
5867 +#endif
5868 +
5869 /*
5870 * This routine handles page faults. It determines the address,
5871 * and the problem, and then passes it off to one of the appropriate
5872 @@ -196,6 +213,14 @@ bad_area:
5873 bad_area_nosemaphore:
5874 /* User mode accesses just cause a SIGSEGV */
5875 if (user_mode(regs)) {
5876 +
5877 +#ifdef CONFIG_PAX_PAGEEXEC
5878 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
5879 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
5880 + do_group_exit(SIGKILL);
5881 + }
5882 +#endif
5883 +
5884 tsk->thread.cp0_badvaddr = address;
5885 tsk->thread.error_code = write;
5886 #if 0
5887 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5888 index 7e5fe27..9656513 100644
5889 --- a/arch/mips/mm/mmap.c
5890 +++ b/arch/mips/mm/mmap.c
5891 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5892 struct vm_area_struct *vma;
5893 unsigned long addr = addr0;
5894 int do_color_align;
5895 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5896 struct vm_unmapped_area_info info;
5897
5898 if (unlikely(len > TASK_SIZE))
5899 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5900 do_color_align = 1;
5901
5902 /* requesting a specific address */
5903 +
5904 +#ifdef CONFIG_PAX_RANDMMAP
5905 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5906 +#endif
5907 +
5908 if (addr) {
5909 if (do_color_align)
5910 addr = COLOUR_ALIGN(addr, pgoff);
5911 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5912 addr = PAGE_ALIGN(addr);
5913
5914 vma = find_vma(mm, addr);
5915 - if (TASK_SIZE - len >= addr &&
5916 - (!vma || addr + len <= vma->vm_start))
5917 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5918 return addr;
5919 }
5920
5921 info.length = len;
5922 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5923 info.align_offset = pgoff << PAGE_SHIFT;
5924 + info.threadstack_offset = offset;
5925
5926 if (dir == DOWN) {
5927 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5928 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5929 {
5930 unsigned long random_factor = 0UL;
5931
5932 +#ifdef CONFIG_PAX_RANDMMAP
5933 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5934 +#endif
5935 +
5936 if (current->flags & PF_RANDOMIZE) {
5937 random_factor = get_random_int();
5938 random_factor = random_factor << PAGE_SHIFT;
5939 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5940
5941 if (mmap_is_legacy()) {
5942 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5943 +
5944 +#ifdef CONFIG_PAX_RANDMMAP
5945 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5946 + mm->mmap_base += mm->delta_mmap;
5947 +#endif
5948 +
5949 mm->get_unmapped_area = arch_get_unmapped_area;
5950 mm->unmap_area = arch_unmap_area;
5951 } else {
5952 mm->mmap_base = mmap_base(random_factor);
5953 +
5954 +#ifdef CONFIG_PAX_RANDMMAP
5955 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5956 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5957 +#endif
5958 +
5959 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5960 mm->unmap_area = arch_unmap_area_topdown;
5961 }
5962 }
5963
5964 -static inline unsigned long brk_rnd(void)
5965 -{
5966 - unsigned long rnd = get_random_int();
5967 -
5968 - rnd = rnd << PAGE_SHIFT;
5969 - /* 8MB for 32bit, 256MB for 64bit */
5970 - if (TASK_IS_32BIT_ADDR)
5971 - rnd = rnd & 0x7ffffful;
5972 - else
5973 - rnd = rnd & 0xffffffful;
5974 -
5975 - return rnd;
5976 -}
5977 -
5978 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5979 -{
5980 - unsigned long base = mm->brk;
5981 - unsigned long ret;
5982 -
5983 - ret = PAGE_ALIGN(base + brk_rnd());
5984 -
5985 - if (ret < mm->brk)
5986 - return mm->brk;
5987 -
5988 - return ret;
5989 -}
5990 -
5991 int __virt_addr_valid(const volatile void *kaddr)
5992 {
5993 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5994 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5995 index 967d144..db12197 100644
5996 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5997 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5998 @@ -11,12 +11,14 @@
5999 #ifndef _ASM_PROC_CACHE_H
6000 #define _ASM_PROC_CACHE_H
6001
6002 +#include <linux/const.h>
6003 +
6004 /* L1 cache */
6005
6006 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6007 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6008 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6009 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6010 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6011 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6012
6013 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6014 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6015 index bcb5df2..84fabd2 100644
6016 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6017 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6018 @@ -16,13 +16,15 @@
6019 #ifndef _ASM_PROC_CACHE_H
6020 #define _ASM_PROC_CACHE_H
6021
6022 +#include <linux/const.h>
6023 +
6024 /*
6025 * L1 cache
6026 */
6027 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6028 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6029 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6030 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6031 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6032 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6033
6034 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6035 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6036 index 4ce7a01..449202a 100644
6037 --- a/arch/openrisc/include/asm/cache.h
6038 +++ b/arch/openrisc/include/asm/cache.h
6039 @@ -19,11 +19,13 @@
6040 #ifndef __ASM_OPENRISC_CACHE_H
6041 #define __ASM_OPENRISC_CACHE_H
6042
6043 +#include <linux/const.h>
6044 +
6045 /* FIXME: How can we replace these with values from the CPU...
6046 * they shouldn't be hard-coded!
6047 */
6048
6049 -#define L1_CACHE_BYTES 16
6050 #define L1_CACHE_SHIFT 4
6051 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6052
6053 #endif /* __ASM_OPENRISC_CACHE_H */
6054 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6055 index 472886c..00e7df9 100644
6056 --- a/arch/parisc/include/asm/atomic.h
6057 +++ b/arch/parisc/include/asm/atomic.h
6058 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6059 return dec;
6060 }
6061
6062 +#define atomic64_read_unchecked(v) atomic64_read(v)
6063 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6064 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6065 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6066 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6067 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6068 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6069 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6070 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6071 +
6072 #endif /* !CONFIG_64BIT */
6073
6074
6075 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6076 index 47f11c7..3420df2 100644
6077 --- a/arch/parisc/include/asm/cache.h
6078 +++ b/arch/parisc/include/asm/cache.h
6079 @@ -5,6 +5,7 @@
6080 #ifndef __ARCH_PARISC_CACHE_H
6081 #define __ARCH_PARISC_CACHE_H
6082
6083 +#include <linux/const.h>
6084
6085 /*
6086 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
6087 @@ -15,13 +16,13 @@
6088 * just ruin performance.
6089 */
6090 #ifdef CONFIG_PA20
6091 -#define L1_CACHE_BYTES 64
6092 #define L1_CACHE_SHIFT 6
6093 #else
6094 -#define L1_CACHE_BYTES 32
6095 #define L1_CACHE_SHIFT 5
6096 #endif
6097
6098 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6099 +
6100 #ifndef __ASSEMBLY__
6101
6102 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6103 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
6104 index ad2b503..bdf1651 100644
6105 --- a/arch/parisc/include/asm/elf.h
6106 +++ b/arch/parisc/include/asm/elf.h
6107 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
6108
6109 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
6110
6111 +#ifdef CONFIG_PAX_ASLR
6112 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
6113 +
6114 +#define PAX_DELTA_MMAP_LEN 16
6115 +#define PAX_DELTA_STACK_LEN 16
6116 +#endif
6117 +
6118 /* This yields a mask that user programs can use to figure out what
6119 instruction set this CPU supports. This could be done in user space,
6120 but it's not easy, and we've already done it here. */
6121 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
6122 index fc987a1..6e068ef 100644
6123 --- a/arch/parisc/include/asm/pgalloc.h
6124 +++ b/arch/parisc/include/asm/pgalloc.h
6125 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6126 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
6127 }
6128
6129 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6130 +{
6131 + pgd_populate(mm, pgd, pmd);
6132 +}
6133 +
6134 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
6135 {
6136 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
6137 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
6138 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
6139 #define pmd_free(mm, x) do { } while (0)
6140 #define pgd_populate(mm, pmd, pte) BUG()
6141 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
6142
6143 #endif
6144
6145 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
6146 index 1e40d7f..a3eb445 100644
6147 --- a/arch/parisc/include/asm/pgtable.h
6148 +++ b/arch/parisc/include/asm/pgtable.h
6149 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6150 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
6151 #define PAGE_COPY PAGE_EXECREAD
6152 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
6153 +
6154 +#ifdef CONFIG_PAX_PAGEEXEC
6155 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
6156 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6157 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6158 +#else
6159 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
6160 +# define PAGE_COPY_NOEXEC PAGE_COPY
6161 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
6162 +#endif
6163 +
6164 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
6165 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
6166 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
6167 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
6168 index e0a8235..ce2f1e1 100644
6169 --- a/arch/parisc/include/asm/uaccess.h
6170 +++ b/arch/parisc/include/asm/uaccess.h
6171 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
6172 const void __user *from,
6173 unsigned long n)
6174 {
6175 - int sz = __compiletime_object_size(to);
6176 + size_t sz = __compiletime_object_size(to);
6177 int ret = -EFAULT;
6178
6179 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
6180 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
6181 ret = __copy_from_user(to, from, n);
6182 else
6183 copy_from_user_overflow();
6184 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
6185 index 2a625fb..9908930 100644
6186 --- a/arch/parisc/kernel/module.c
6187 +++ b/arch/parisc/kernel/module.c
6188 @@ -98,16 +98,38 @@
6189
6190 /* three functions to determine where in the module core
6191 * or init pieces the location is */
6192 +static inline int in_init_rx(struct module *me, void *loc)
6193 +{
6194 + return (loc >= me->module_init_rx &&
6195 + loc < (me->module_init_rx + me->init_size_rx));
6196 +}
6197 +
6198 +static inline int in_init_rw(struct module *me, void *loc)
6199 +{
6200 + return (loc >= me->module_init_rw &&
6201 + loc < (me->module_init_rw + me->init_size_rw));
6202 +}
6203 +
6204 static inline int in_init(struct module *me, void *loc)
6205 {
6206 - return (loc >= me->module_init &&
6207 - loc <= (me->module_init + me->init_size));
6208 + return in_init_rx(me, loc) || in_init_rw(me, loc);
6209 +}
6210 +
6211 +static inline int in_core_rx(struct module *me, void *loc)
6212 +{
6213 + return (loc >= me->module_core_rx &&
6214 + loc < (me->module_core_rx + me->core_size_rx));
6215 +}
6216 +
6217 +static inline int in_core_rw(struct module *me, void *loc)
6218 +{
6219 + return (loc >= me->module_core_rw &&
6220 + loc < (me->module_core_rw + me->core_size_rw));
6221 }
6222
6223 static inline int in_core(struct module *me, void *loc)
6224 {
6225 - return (loc >= me->module_core &&
6226 - loc <= (me->module_core + me->core_size));
6227 + return in_core_rx(me, loc) || in_core_rw(me, loc);
6228 }
6229
6230 static inline int in_local(struct module *me, void *loc)
6231 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
6232 }
6233
6234 /* align things a bit */
6235 - me->core_size = ALIGN(me->core_size, 16);
6236 - me->arch.got_offset = me->core_size;
6237 - me->core_size += gots * sizeof(struct got_entry);
6238 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6239 + me->arch.got_offset = me->core_size_rw;
6240 + me->core_size_rw += gots * sizeof(struct got_entry);
6241
6242 - me->core_size = ALIGN(me->core_size, 16);
6243 - me->arch.fdesc_offset = me->core_size;
6244 - me->core_size += fdescs * sizeof(Elf_Fdesc);
6245 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6246 + me->arch.fdesc_offset = me->core_size_rw;
6247 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
6248
6249 me->arch.got_max = gots;
6250 me->arch.fdesc_max = fdescs;
6251 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6252
6253 BUG_ON(value == 0);
6254
6255 - got = me->module_core + me->arch.got_offset;
6256 + got = me->module_core_rw + me->arch.got_offset;
6257 for (i = 0; got[i].addr; i++)
6258 if (got[i].addr == value)
6259 goto out;
6260 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6261 #ifdef CONFIG_64BIT
6262 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6263 {
6264 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
6265 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
6266
6267 if (!value) {
6268 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
6269 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6270
6271 /* Create new one */
6272 fdesc->addr = value;
6273 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6274 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6275 return (Elf_Addr)fdesc;
6276 }
6277 #endif /* CONFIG_64BIT */
6278 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
6279
6280 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
6281 end = table + sechdrs[me->arch.unwind_section].sh_size;
6282 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6283 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6284
6285 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
6286 me->arch.unwind_section, table, end, gp);
6287 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
6288 index 5dfd248..64914ac 100644
6289 --- a/arch/parisc/kernel/sys_parisc.c
6290 +++ b/arch/parisc/kernel/sys_parisc.c
6291 @@ -33,9 +33,11 @@
6292 #include <linux/utsname.h>
6293 #include <linux/personality.h>
6294
6295 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6296 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
6297 + unsigned long flags)
6298 {
6299 struct vm_unmapped_area_info info;
6300 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6301
6302 info.flags = 0;
6303 info.length = len;
6304 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6305 info.high_limit = TASK_SIZE;
6306 info.align_mask = 0;
6307 info.align_offset = 0;
6308 + info.threadstack_offset = offset;
6309 return vm_unmapped_area(&info);
6310 }
6311
6312 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
6313 return (unsigned long) mapping >> 8;
6314 }
6315
6316 -static unsigned long get_shared_area(struct address_space *mapping,
6317 - unsigned long addr, unsigned long len, unsigned long pgoff)
6318 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
6319 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
6320 {
6321 struct vm_unmapped_area_info info;
6322 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6323
6324 info.flags = 0;
6325 info.length = len;
6326 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
6327 info.high_limit = TASK_SIZE;
6328 info.align_mask = PAGE_MASK & (SHMLBA - 1);
6329 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
6330 + info.threadstack_offset = offset;
6331 return vm_unmapped_area(&info);
6332 }
6333
6334 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6335 return -EINVAL;
6336 return addr;
6337 }
6338 - if (!addr)
6339 + if (!addr) {
6340 addr = TASK_UNMAPPED_BASE;
6341
6342 +#ifdef CONFIG_PAX_RANDMMAP
6343 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
6344 + addr += current->mm->delta_mmap;
6345 +#endif
6346 +
6347 + }
6348 +
6349 if (filp) {
6350 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6351 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6352 } else if(flags & MAP_SHARED) {
6353 - addr = get_shared_area(NULL, addr, len, pgoff);
6354 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6355 } else {
6356 - addr = get_unshared_area(addr, len);
6357 + addr = get_unshared_area(filp, addr, len, flags);
6358 }
6359 return addr;
6360 }
6361 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6362 index 04e47c6..7a8faf6 100644
6363 --- a/arch/parisc/kernel/traps.c
6364 +++ b/arch/parisc/kernel/traps.c
6365 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6366
6367 down_read(&current->mm->mmap_sem);
6368 vma = find_vma(current->mm,regs->iaoq[0]);
6369 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6370 - && (vma->vm_flags & VM_EXEC)) {
6371 -
6372 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6373 fault_address = regs->iaoq[0];
6374 fault_space = regs->iasq[0];
6375
6376 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6377 index f247a34..dc0f219 100644
6378 --- a/arch/parisc/mm/fault.c
6379 +++ b/arch/parisc/mm/fault.c
6380 @@ -15,6 +15,7 @@
6381 #include <linux/sched.h>
6382 #include <linux/interrupt.h>
6383 #include <linux/module.h>
6384 +#include <linux/unistd.h>
6385
6386 #include <asm/uaccess.h>
6387 #include <asm/traps.h>
6388 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6389 static unsigned long
6390 parisc_acctyp(unsigned long code, unsigned int inst)
6391 {
6392 - if (code == 6 || code == 16)
6393 + if (code == 6 || code == 7 || code == 16)
6394 return VM_EXEC;
6395
6396 switch (inst & 0xf0000000) {
6397 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6398 }
6399 #endif
6400
6401 +#ifdef CONFIG_PAX_PAGEEXEC
6402 +/*
6403 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6404 + *
6405 + * returns 1 when task should be killed
6406 + * 2 when rt_sigreturn trampoline was detected
6407 + * 3 when unpatched PLT trampoline was detected
6408 + */
6409 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6410 +{
6411 +
6412 +#ifdef CONFIG_PAX_EMUPLT
6413 + int err;
6414 +
6415 + do { /* PaX: unpatched PLT emulation */
6416 + unsigned int bl, depwi;
6417 +
6418 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6419 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6420 +
6421 + if (err)
6422 + break;
6423 +
6424 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6425 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6426 +
6427 + err = get_user(ldw, (unsigned int *)addr);
6428 + err |= get_user(bv, (unsigned int *)(addr+4));
6429 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6430 +
6431 + if (err)
6432 + break;
6433 +
6434 + if (ldw == 0x0E801096U &&
6435 + bv == 0xEAC0C000U &&
6436 + ldw2 == 0x0E881095U)
6437 + {
6438 + unsigned int resolver, map;
6439 +
6440 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6441 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6442 + if (err)
6443 + break;
6444 +
6445 + regs->gr[20] = instruction_pointer(regs)+8;
6446 + regs->gr[21] = map;
6447 + regs->gr[22] = resolver;
6448 + regs->iaoq[0] = resolver | 3UL;
6449 + regs->iaoq[1] = regs->iaoq[0] + 4;
6450 + return 3;
6451 + }
6452 + }
6453 + } while (0);
6454 +#endif
6455 +
6456 +#ifdef CONFIG_PAX_EMUTRAMP
6457 +
6458 +#ifndef CONFIG_PAX_EMUSIGRT
6459 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6460 + return 1;
6461 +#endif
6462 +
6463 + do { /* PaX: rt_sigreturn emulation */
6464 + unsigned int ldi1, ldi2, bel, nop;
6465 +
6466 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6467 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6468 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6469 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6470 +
6471 + if (err)
6472 + break;
6473 +
6474 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6475 + ldi2 == 0x3414015AU &&
6476 + bel == 0xE4008200U &&
6477 + nop == 0x08000240U)
6478 + {
6479 + regs->gr[25] = (ldi1 & 2) >> 1;
6480 + regs->gr[20] = __NR_rt_sigreturn;
6481 + regs->gr[31] = regs->iaoq[1] + 16;
6482 + regs->sr[0] = regs->iasq[1];
6483 + regs->iaoq[0] = 0x100UL;
6484 + regs->iaoq[1] = regs->iaoq[0] + 4;
6485 + regs->iasq[0] = regs->sr[2];
6486 + regs->iasq[1] = regs->sr[2];
6487 + return 2;
6488 + }
6489 + } while (0);
6490 +#endif
6491 +
6492 + return 1;
6493 +}
6494 +
6495 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6496 +{
6497 + unsigned long i;
6498 +
6499 + printk(KERN_ERR "PAX: bytes at PC: ");
6500 + for (i = 0; i < 5; i++) {
6501 + unsigned int c;
6502 + if (get_user(c, (unsigned int *)pc+i))
6503 + printk(KERN_CONT "???????? ");
6504 + else
6505 + printk(KERN_CONT "%08x ", c);
6506 + }
6507 + printk("\n");
6508 +}
6509 +#endif
6510 +
6511 int fixup_exception(struct pt_regs *regs)
6512 {
6513 const struct exception_table_entry *fix;
6514 @@ -194,8 +305,33 @@ good_area:
6515
6516 acc_type = parisc_acctyp(code,regs->iir);
6517
6518 - if ((vma->vm_flags & acc_type) != acc_type)
6519 + if ((vma->vm_flags & acc_type) != acc_type) {
6520 +
6521 +#ifdef CONFIG_PAX_PAGEEXEC
6522 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6523 + (address & ~3UL) == instruction_pointer(regs))
6524 + {
6525 + up_read(&mm->mmap_sem);
6526 + switch (pax_handle_fetch_fault(regs)) {
6527 +
6528 +#ifdef CONFIG_PAX_EMUPLT
6529 + case 3:
6530 + return;
6531 +#endif
6532 +
6533 +#ifdef CONFIG_PAX_EMUTRAMP
6534 + case 2:
6535 + return;
6536 +#endif
6537 +
6538 + }
6539 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6540 + do_group_exit(SIGKILL);
6541 + }
6542 +#endif
6543 +
6544 goto bad_area;
6545 + }
6546
6547 /*
6548 * If for any reason at all we couldn't handle the fault, make
6549 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6550 index e3b1d41..8e81edf 100644
6551 --- a/arch/powerpc/include/asm/atomic.h
6552 +++ b/arch/powerpc/include/asm/atomic.h
6553 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6554 return t1;
6555 }
6556
6557 +#define atomic64_read_unchecked(v) atomic64_read(v)
6558 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6559 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6560 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6561 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6562 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6563 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6564 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6565 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6566 +
6567 #endif /* __powerpc64__ */
6568
6569 #endif /* __KERNEL__ */
6570 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6571 index 9e495c9..b6878e5 100644
6572 --- a/arch/powerpc/include/asm/cache.h
6573 +++ b/arch/powerpc/include/asm/cache.h
6574 @@ -3,6 +3,7 @@
6575
6576 #ifdef __KERNEL__
6577
6578 +#include <linux/const.h>
6579
6580 /* bytes per L1 cache line */
6581 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6582 @@ -22,7 +23,7 @@
6583 #define L1_CACHE_SHIFT 7
6584 #endif
6585
6586 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6587 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6588
6589 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6590
6591 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6592 index cc0655a..13eac2e 100644
6593 --- a/arch/powerpc/include/asm/elf.h
6594 +++ b/arch/powerpc/include/asm/elf.h
6595 @@ -28,8 +28,19 @@
6596 the loader. We need to make sure that it is out of the way of the program
6597 that it will "exec", and that there is sufficient room for the brk. */
6598
6599 -extern unsigned long randomize_et_dyn(unsigned long base);
6600 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6601 +#define ELF_ET_DYN_BASE (0x20000000)
6602 +
6603 +#ifdef CONFIG_PAX_ASLR
6604 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6605 +
6606 +#ifdef __powerpc64__
6607 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6608 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6609 +#else
6610 +#define PAX_DELTA_MMAP_LEN 15
6611 +#define PAX_DELTA_STACK_LEN 15
6612 +#endif
6613 +#endif
6614
6615 /*
6616 * Our registers are always unsigned longs, whether we're a 32 bit
6617 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6618 (0x7ff >> (PAGE_SHIFT - 12)) : \
6619 (0x3ffff >> (PAGE_SHIFT - 12)))
6620
6621 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6622 -#define arch_randomize_brk arch_randomize_brk
6623 -
6624 -
6625 #ifdef CONFIG_SPU_BASE
6626 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6627 #define NT_SPU 1
6628 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6629 index 8196e9c..d83a9f3 100644
6630 --- a/arch/powerpc/include/asm/exec.h
6631 +++ b/arch/powerpc/include/asm/exec.h
6632 @@ -4,6 +4,6 @@
6633 #ifndef _ASM_POWERPC_EXEC_H
6634 #define _ASM_POWERPC_EXEC_H
6635
6636 -extern unsigned long arch_align_stack(unsigned long sp);
6637 +#define arch_align_stack(x) ((x) & ~0xfUL)
6638
6639 #endif /* _ASM_POWERPC_EXEC_H */
6640 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6641 index 5acabbd..7ea14fa 100644
6642 --- a/arch/powerpc/include/asm/kmap_types.h
6643 +++ b/arch/powerpc/include/asm/kmap_types.h
6644 @@ -10,7 +10,7 @@
6645 * 2 of the License, or (at your option) any later version.
6646 */
6647
6648 -#define KM_TYPE_NR 16
6649 +#define KM_TYPE_NR 17
6650
6651 #endif /* __KERNEL__ */
6652 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6653 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6654 index 8565c25..2865190 100644
6655 --- a/arch/powerpc/include/asm/mman.h
6656 +++ b/arch/powerpc/include/asm/mman.h
6657 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6658 }
6659 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6660
6661 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6662 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6663 {
6664 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6665 }
6666 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6667 index 988c812..63c7d70 100644
6668 --- a/arch/powerpc/include/asm/page.h
6669 +++ b/arch/powerpc/include/asm/page.h
6670 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6671 * and needs to be executable. This means the whole heap ends
6672 * up being executable.
6673 */
6674 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6675 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6676 +#define VM_DATA_DEFAULT_FLAGS32 \
6677 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6678 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6679
6680 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6681 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6682 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6683 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6684 #endif
6685
6686 +#define ktla_ktva(addr) (addr)
6687 +#define ktva_ktla(addr) (addr)
6688 +
6689 #ifndef CONFIG_PPC_BOOK3S_64
6690 /*
6691 * Use the top bit of the higher-level page table entries to indicate whether
6692 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6693 index 88693ce..ac6f9ab 100644
6694 --- a/arch/powerpc/include/asm/page_64.h
6695 +++ b/arch/powerpc/include/asm/page_64.h
6696 @@ -153,15 +153,18 @@ do { \
6697 * stack by default, so in the absence of a PT_GNU_STACK program header
6698 * we turn execute permission off.
6699 */
6700 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6701 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6702 +#define VM_STACK_DEFAULT_FLAGS32 \
6703 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6704 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6705
6706 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6707 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6708
6709 +#ifndef CONFIG_PAX_PAGEEXEC
6710 #define VM_STACK_DEFAULT_FLAGS \
6711 (is_32bit_task() ? \
6712 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6713 +#endif
6714
6715 #include <asm-generic/getorder.h>
6716
6717 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6718 index b66ae72..4a378cd 100644
6719 --- a/arch/powerpc/include/asm/pgalloc-64.h
6720 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6721 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6722 #ifndef CONFIG_PPC_64K_PAGES
6723
6724 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6725 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6726
6727 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6728 {
6729 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6730 pud_set(pud, (unsigned long)pmd);
6731 }
6732
6733 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6734 +{
6735 + pud_populate(mm, pud, pmd);
6736 +}
6737 +
6738 #define pmd_populate(mm, pmd, pte_page) \
6739 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6740 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6741 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
6742 #endif
6743
6744 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6745 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6746
6747 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6748 pte_t *pte)
6749 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6750 index 7aeb955..19f748e 100644
6751 --- a/arch/powerpc/include/asm/pgtable.h
6752 +++ b/arch/powerpc/include/asm/pgtable.h
6753 @@ -2,6 +2,7 @@
6754 #define _ASM_POWERPC_PGTABLE_H
6755 #ifdef __KERNEL__
6756
6757 +#include <linux/const.h>
6758 #ifndef __ASSEMBLY__
6759 #include <asm/processor.h> /* For TASK_SIZE */
6760 #include <asm/mmu.h>
6761 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6762 index 4aad413..85d86bf 100644
6763 --- a/arch/powerpc/include/asm/pte-hash32.h
6764 +++ b/arch/powerpc/include/asm/pte-hash32.h
6765 @@ -21,6 +21,7 @@
6766 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6767 #define _PAGE_USER 0x004 /* usermode access allowed */
6768 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6769 +#define _PAGE_EXEC _PAGE_GUARDED
6770 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6771 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6772 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6773 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6774 index e1fb161..2290d1d 100644
6775 --- a/arch/powerpc/include/asm/reg.h
6776 +++ b/arch/powerpc/include/asm/reg.h
6777 @@ -234,6 +234,7 @@
6778 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6779 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6780 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6781 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6782 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6783 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6784 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6785 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6786 index 48cfc85..891382f 100644
6787 --- a/arch/powerpc/include/asm/smp.h
6788 +++ b/arch/powerpc/include/asm/smp.h
6789 @@ -50,7 +50,7 @@ struct smp_ops_t {
6790 int (*cpu_disable)(void);
6791 void (*cpu_die)(unsigned int nr);
6792 int (*cpu_bootable)(unsigned int nr);
6793 -};
6794 +} __no_const;
6795
6796 extern void smp_send_debugger_break(void);
6797 extern void start_secondary_resume(void);
6798 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6799 index ba7b197..d292e26 100644
6800 --- a/arch/powerpc/include/asm/thread_info.h
6801 +++ b/arch/powerpc/include/asm/thread_info.h
6802 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
6803 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
6804 TIF_NEED_RESCHED */
6805 #define TIF_32BIT 4 /* 32 bit binary */
6806 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
6807 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6808 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6809 #define TIF_SINGLESTEP 8 /* singlestepping active */
6810 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
6811 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6812 for stack store? */
6813 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6814 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
6815 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6816 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
6817
6818 /* as above, but as bit values */
6819 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6820 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
6821 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6822 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6823 #define _TIF_NOHZ (1<<TIF_NOHZ)
6824 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6825 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6826 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6827 - _TIF_NOHZ)
6828 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
6829
6830 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6831 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6832 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6833 index 4db4959..aba5c41 100644
6834 --- a/arch/powerpc/include/asm/uaccess.h
6835 +++ b/arch/powerpc/include/asm/uaccess.h
6836 @@ -318,52 +318,6 @@ do { \
6837 extern unsigned long __copy_tofrom_user(void __user *to,
6838 const void __user *from, unsigned long size);
6839
6840 -#ifndef __powerpc64__
6841 -
6842 -static inline unsigned long copy_from_user(void *to,
6843 - const void __user *from, unsigned long n)
6844 -{
6845 - unsigned long over;
6846 -
6847 - if (access_ok(VERIFY_READ, from, n))
6848 - return __copy_tofrom_user((__force void __user *)to, from, n);
6849 - if ((unsigned long)from < TASK_SIZE) {
6850 - over = (unsigned long)from + n - TASK_SIZE;
6851 - return __copy_tofrom_user((__force void __user *)to, from,
6852 - n - over) + over;
6853 - }
6854 - return n;
6855 -}
6856 -
6857 -static inline unsigned long copy_to_user(void __user *to,
6858 - const void *from, unsigned long n)
6859 -{
6860 - unsigned long over;
6861 -
6862 - if (access_ok(VERIFY_WRITE, to, n))
6863 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6864 - if ((unsigned long)to < TASK_SIZE) {
6865 - over = (unsigned long)to + n - TASK_SIZE;
6866 - return __copy_tofrom_user(to, (__force void __user *)from,
6867 - n - over) + over;
6868 - }
6869 - return n;
6870 -}
6871 -
6872 -#else /* __powerpc64__ */
6873 -
6874 -#define __copy_in_user(to, from, size) \
6875 - __copy_tofrom_user((to), (from), (size))
6876 -
6877 -extern unsigned long copy_from_user(void *to, const void __user *from,
6878 - unsigned long n);
6879 -extern unsigned long copy_to_user(void __user *to, const void *from,
6880 - unsigned long n);
6881 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6882 - unsigned long n);
6883 -
6884 -#endif /* __powerpc64__ */
6885 -
6886 static inline unsigned long __copy_from_user_inatomic(void *to,
6887 const void __user *from, unsigned long n)
6888 {
6889 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6890 if (ret == 0)
6891 return 0;
6892 }
6893 +
6894 + if (!__builtin_constant_p(n))
6895 + check_object_size(to, n, false);
6896 +
6897 return __copy_tofrom_user((__force void __user *)to, from, n);
6898 }
6899
6900 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6901 if (ret == 0)
6902 return 0;
6903 }
6904 +
6905 + if (!__builtin_constant_p(n))
6906 + check_object_size(from, n, true);
6907 +
6908 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6909 }
6910
6911 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6912 return __copy_to_user_inatomic(to, from, size);
6913 }
6914
6915 +#ifndef __powerpc64__
6916 +
6917 +static inline unsigned long __must_check copy_from_user(void *to,
6918 + const void __user *from, unsigned long n)
6919 +{
6920 + unsigned long over;
6921 +
6922 + if ((long)n < 0)
6923 + return n;
6924 +
6925 + if (access_ok(VERIFY_READ, from, n)) {
6926 + if (!__builtin_constant_p(n))
6927 + check_object_size(to, n, false);
6928 + return __copy_tofrom_user((__force void __user *)to, from, n);
6929 + }
6930 + if ((unsigned long)from < TASK_SIZE) {
6931 + over = (unsigned long)from + n - TASK_SIZE;
6932 + if (!__builtin_constant_p(n - over))
6933 + check_object_size(to, n - over, false);
6934 + return __copy_tofrom_user((__force void __user *)to, from,
6935 + n - over) + over;
6936 + }
6937 + return n;
6938 +}
6939 +
6940 +static inline unsigned long __must_check copy_to_user(void __user *to,
6941 + const void *from, unsigned long n)
6942 +{
6943 + unsigned long over;
6944 +
6945 + if ((long)n < 0)
6946 + return n;
6947 +
6948 + if (access_ok(VERIFY_WRITE, to, n)) {
6949 + if (!__builtin_constant_p(n))
6950 + check_object_size(from, n, true);
6951 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6952 + }
6953 + if ((unsigned long)to < TASK_SIZE) {
6954 + over = (unsigned long)to + n - TASK_SIZE;
6955 + if (!__builtin_constant_p(n))
6956 + check_object_size(from, n - over, true);
6957 + return __copy_tofrom_user(to, (__force void __user *)from,
6958 + n - over) + over;
6959 + }
6960 + return n;
6961 +}
6962 +
6963 +#else /* __powerpc64__ */
6964 +
6965 +#define __copy_in_user(to, from, size) \
6966 + __copy_tofrom_user((to), (from), (size))
6967 +
6968 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6969 +{
6970 + if ((long)n < 0 || n > INT_MAX)
6971 + return n;
6972 +
6973 + if (!__builtin_constant_p(n))
6974 + check_object_size(to, n, false);
6975 +
6976 + if (likely(access_ok(VERIFY_READ, from, n)))
6977 + n = __copy_from_user(to, from, n);
6978 + else
6979 + memset(to, 0, n);
6980 + return n;
6981 +}
6982 +
6983 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6984 +{
6985 + if ((long)n < 0 || n > INT_MAX)
6986 + return n;
6987 +
6988 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6989 + if (!__builtin_constant_p(n))
6990 + check_object_size(from, n, true);
6991 + n = __copy_to_user(to, from, n);
6992 + }
6993 + return n;
6994 +}
6995 +
6996 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6997 + unsigned long n);
6998 +
6999 +#endif /* __powerpc64__ */
7000 +
7001 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7002
7003 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7004 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7005 index 645170a..6cf0271 100644
7006 --- a/arch/powerpc/kernel/exceptions-64e.S
7007 +++ b/arch/powerpc/kernel/exceptions-64e.S
7008 @@ -757,6 +757,7 @@ storage_fault_common:
7009 std r14,_DAR(r1)
7010 std r15,_DSISR(r1)
7011 addi r3,r1,STACK_FRAME_OVERHEAD
7012 + bl .save_nvgprs
7013 mr r4,r14
7014 mr r5,r15
7015 ld r14,PACA_EXGEN+EX_R14(r13)
7016 @@ -765,8 +766,7 @@ storage_fault_common:
7017 cmpdi r3,0
7018 bne- 1f
7019 b .ret_from_except_lite
7020 -1: bl .save_nvgprs
7021 - mr r5,r3
7022 +1: mr r5,r3
7023 addi r3,r1,STACK_FRAME_OVERHEAD
7024 ld r4,_DAR(r1)
7025 bl .bad_page_fault
7026 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7027 index 902ca3c..e942155 100644
7028 --- a/arch/powerpc/kernel/exceptions-64s.S
7029 +++ b/arch/powerpc/kernel/exceptions-64s.S
7030 @@ -1357,10 +1357,10 @@ handle_page_fault:
7031 11: ld r4,_DAR(r1)
7032 ld r5,_DSISR(r1)
7033 addi r3,r1,STACK_FRAME_OVERHEAD
7034 + bl .save_nvgprs
7035 bl .do_page_fault
7036 cmpdi r3,0
7037 beq+ 12f
7038 - bl .save_nvgprs
7039 mr r5,r3
7040 addi r3,r1,STACK_FRAME_OVERHEAD
7041 lwz r4,_DAR(r1)
7042 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7043 index 2e3200c..72095ce 100644
7044 --- a/arch/powerpc/kernel/module_32.c
7045 +++ b/arch/powerpc/kernel/module_32.c
7046 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7047 me->arch.core_plt_section = i;
7048 }
7049 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7050 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7051 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7052 return -ENOEXEC;
7053 }
7054
7055 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7056
7057 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7058 /* Init, or core PLT? */
7059 - if (location >= mod->module_core
7060 - && location < mod->module_core + mod->core_size)
7061 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7062 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7063 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7064 - else
7065 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7066 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7067 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7068 + else {
7069 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7070 + return ~0UL;
7071 + }
7072
7073 /* Find this entry, or if that fails, the next avail. entry */
7074 while (entry->jump[0]) {
7075 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7076 index 7baa27b..f6b394a 100644
7077 --- a/arch/powerpc/kernel/process.c
7078 +++ b/arch/powerpc/kernel/process.c
7079 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
7080 * Lookup NIP late so we have the best change of getting the
7081 * above info out without failing
7082 */
7083 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7084 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7085 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7086 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7087 #endif
7088 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
7089 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
7090 @@ -1345,10 +1345,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7091 newsp = stack[0];
7092 ip = stack[STACK_FRAME_LR_SAVE];
7093 if (!firstframe || ip != lr) {
7094 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
7095 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
7096 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
7097 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
7098 - printk(" (%pS)",
7099 + printk(" (%pA)",
7100 (void *)current->ret_stack[curr_frame].ret);
7101 curr_frame--;
7102 }
7103 @@ -1368,7 +1368,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7104 struct pt_regs *regs = (struct pt_regs *)
7105 (sp + STACK_FRAME_OVERHEAD);
7106 lr = regs->link;
7107 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
7108 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
7109 regs->trap, (void *)regs->nip, (void *)lr);
7110 firstframe = 1;
7111 }
7112 @@ -1404,58 +1404,3 @@ void notrace __ppc64_runlatch_off(void)
7113 mtspr(SPRN_CTRLT, ctrl);
7114 }
7115 #endif /* CONFIG_PPC64 */
7116 -
7117 -unsigned long arch_align_stack(unsigned long sp)
7118 -{
7119 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7120 - sp -= get_random_int() & ~PAGE_MASK;
7121 - return sp & ~0xf;
7122 -}
7123 -
7124 -static inline unsigned long brk_rnd(void)
7125 -{
7126 - unsigned long rnd = 0;
7127 -
7128 - /* 8MB for 32bit, 1GB for 64bit */
7129 - if (is_32bit_task())
7130 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
7131 - else
7132 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
7133 -
7134 - return rnd << PAGE_SHIFT;
7135 -}
7136 -
7137 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7138 -{
7139 - unsigned long base = mm->brk;
7140 - unsigned long ret;
7141 -
7142 -#ifdef CONFIG_PPC_STD_MMU_64
7143 - /*
7144 - * If we are using 1TB segments and we are allowed to randomise
7145 - * the heap, we can put it above 1TB so it is backed by a 1TB
7146 - * segment. Otherwise the heap will be in the bottom 1TB
7147 - * which always uses 256MB segments and this may result in a
7148 - * performance penalty.
7149 - */
7150 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
7151 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
7152 -#endif
7153 -
7154 - ret = PAGE_ALIGN(base + brk_rnd());
7155 -
7156 - if (ret < mm->brk)
7157 - return mm->brk;
7158 -
7159 - return ret;
7160 -}
7161 -
7162 -unsigned long randomize_et_dyn(unsigned long base)
7163 -{
7164 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7165 -
7166 - if (ret < base)
7167 - return base;
7168 -
7169 - return ret;
7170 -}
7171 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
7172 index 64f7bd5..8dd550f 100644
7173 --- a/arch/powerpc/kernel/ptrace.c
7174 +++ b/arch/powerpc/kernel/ptrace.c
7175 @@ -1783,6 +1783,10 @@ long arch_ptrace(struct task_struct *child, long request,
7176 return ret;
7177 }
7178
7179 +#ifdef CONFIG_GRKERNSEC_SETXID
7180 +extern void gr_delayed_cred_worker(void);
7181 +#endif
7182 +
7183 /*
7184 * We must return the syscall number to actually look up in the table.
7185 * This can be -1L to skip running any syscall at all.
7186 @@ -1795,6 +1799,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
7187
7188 secure_computing_strict(regs->gpr[0]);
7189
7190 +#ifdef CONFIG_GRKERNSEC_SETXID
7191 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7192 + gr_delayed_cred_worker();
7193 +#endif
7194 +
7195 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
7196 tracehook_report_syscall_entry(regs))
7197 /*
7198 @@ -1829,6 +1838,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
7199 {
7200 int step;
7201
7202 +#ifdef CONFIG_GRKERNSEC_SETXID
7203 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7204 + gr_delayed_cred_worker();
7205 +#endif
7206 +
7207 audit_syscall_exit(regs);
7208
7209 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7210 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
7211 index 0f83122..c0aca6a 100644
7212 --- a/arch/powerpc/kernel/signal_32.c
7213 +++ b/arch/powerpc/kernel/signal_32.c
7214 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
7215 /* Save user registers on the stack */
7216 frame = &rt_sf->uc.uc_mcontext;
7217 addr = frame;
7218 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
7219 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7220 sigret = 0;
7221 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
7222 } else {
7223 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
7224 index 887e99d..310bc11 100644
7225 --- a/arch/powerpc/kernel/signal_64.c
7226 +++ b/arch/powerpc/kernel/signal_64.c
7227 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
7228 #endif
7229
7230 /* Set up to return from userspace. */
7231 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
7232 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7233 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
7234 } else {
7235 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
7236 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
7237 index e68a845..8b140e6 100644
7238 --- a/arch/powerpc/kernel/sysfs.c
7239 +++ b/arch/powerpc/kernel/sysfs.c
7240 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
7241 return NOTIFY_OK;
7242 }
7243
7244 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
7245 +static struct notifier_block sysfs_cpu_nb = {
7246 .notifier_call = sysfs_cpu_notify,
7247 };
7248
7249 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
7250 index 88929b1..bece8f8 100644
7251 --- a/arch/powerpc/kernel/traps.c
7252 +++ b/arch/powerpc/kernel/traps.c
7253 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
7254 return flags;
7255 }
7256
7257 +extern void gr_handle_kernel_exploit(void);
7258 +
7259 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7260 int signr)
7261 {
7262 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7263 panic("Fatal exception in interrupt");
7264 if (panic_on_oops)
7265 panic("Fatal exception");
7266 +
7267 + gr_handle_kernel_exploit();
7268 +
7269 do_exit(signr);
7270 }
7271
7272 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
7273 index d4f463a..8fb7431 100644
7274 --- a/arch/powerpc/kernel/vdso.c
7275 +++ b/arch/powerpc/kernel/vdso.c
7276 @@ -34,6 +34,7 @@
7277 #include <asm/firmware.h>
7278 #include <asm/vdso.h>
7279 #include <asm/vdso_datapage.h>
7280 +#include <asm/mman.h>
7281
7282 #include "setup.h"
7283
7284 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7285 vdso_base = VDSO32_MBASE;
7286 #endif
7287
7288 - current->mm->context.vdso_base = 0;
7289 + current->mm->context.vdso_base = ~0UL;
7290
7291 /* vDSO has a problem and was disabled, just don't "enable" it for the
7292 * process
7293 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7294 vdso_base = get_unmapped_area(NULL, vdso_base,
7295 (vdso_pages << PAGE_SHIFT) +
7296 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
7297 - 0, 0);
7298 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
7299 if (IS_ERR_VALUE(vdso_base)) {
7300 rc = vdso_base;
7301 goto fail_mmapsem;
7302 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
7303 index 5eea6f3..5d10396 100644
7304 --- a/arch/powerpc/lib/usercopy_64.c
7305 +++ b/arch/powerpc/lib/usercopy_64.c
7306 @@ -9,22 +9,6 @@
7307 #include <linux/module.h>
7308 #include <asm/uaccess.h>
7309
7310 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
7311 -{
7312 - if (likely(access_ok(VERIFY_READ, from, n)))
7313 - n = __copy_from_user(to, from, n);
7314 - else
7315 - memset(to, 0, n);
7316 - return n;
7317 -}
7318 -
7319 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
7320 -{
7321 - if (likely(access_ok(VERIFY_WRITE, to, n)))
7322 - n = __copy_to_user(to, from, n);
7323 - return n;
7324 -}
7325 -
7326 unsigned long copy_in_user(void __user *to, const void __user *from,
7327 unsigned long n)
7328 {
7329 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7330 return n;
7331 }
7332
7333 -EXPORT_SYMBOL(copy_from_user);
7334 -EXPORT_SYMBOL(copy_to_user);
7335 EXPORT_SYMBOL(copy_in_user);
7336
7337 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7338 index 8726779..a33c512 100644
7339 --- a/arch/powerpc/mm/fault.c
7340 +++ b/arch/powerpc/mm/fault.c
7341 @@ -33,6 +33,10 @@
7342 #include <linux/magic.h>
7343 #include <linux/ratelimit.h>
7344 #include <linux/context_tracking.h>
7345 +#include <linux/slab.h>
7346 +#include <linux/pagemap.h>
7347 +#include <linux/compiler.h>
7348 +#include <linux/unistd.h>
7349
7350 #include <asm/firmware.h>
7351 #include <asm/page.h>
7352 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7353 }
7354 #endif
7355
7356 +#ifdef CONFIG_PAX_PAGEEXEC
7357 +/*
7358 + * PaX: decide what to do with offenders (regs->nip = fault address)
7359 + *
7360 + * returns 1 when task should be killed
7361 + */
7362 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7363 +{
7364 + return 1;
7365 +}
7366 +
7367 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7368 +{
7369 + unsigned long i;
7370 +
7371 + printk(KERN_ERR "PAX: bytes at PC: ");
7372 + for (i = 0; i < 5; i++) {
7373 + unsigned int c;
7374 + if (get_user(c, (unsigned int __user *)pc+i))
7375 + printk(KERN_CONT "???????? ");
7376 + else
7377 + printk(KERN_CONT "%08x ", c);
7378 + }
7379 + printk("\n");
7380 +}
7381 +#endif
7382 +
7383 /*
7384 * Check whether the instruction at regs->nip is a store using
7385 * an update addressing form which will update r1.
7386 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7387 * indicate errors in DSISR but can validly be set in SRR1.
7388 */
7389 if (trap == 0x400)
7390 - error_code &= 0x48200000;
7391 + error_code &= 0x58200000;
7392 else
7393 is_write = error_code & DSISR_ISSTORE;
7394 #else
7395 @@ -371,7 +402,7 @@ good_area:
7396 * "undefined". Of those that can be set, this is the only
7397 * one which seems bad.
7398 */
7399 - if (error_code & 0x10000000)
7400 + if (error_code & DSISR_GUARDED)
7401 /* Guarded storage error. */
7402 goto bad_area;
7403 #endif /* CONFIG_8xx */
7404 @@ -386,7 +417,7 @@ good_area:
7405 * processors use the same I/D cache coherency mechanism
7406 * as embedded.
7407 */
7408 - if (error_code & DSISR_PROTFAULT)
7409 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7410 goto bad_area;
7411 #endif /* CONFIG_PPC_STD_MMU */
7412
7413 @@ -471,6 +502,23 @@ bad_area:
7414 bad_area_nosemaphore:
7415 /* User mode accesses cause a SIGSEGV */
7416 if (user_mode(regs)) {
7417 +
7418 +#ifdef CONFIG_PAX_PAGEEXEC
7419 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7420 +#ifdef CONFIG_PPC_STD_MMU
7421 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7422 +#else
7423 + if (is_exec && regs->nip == address) {
7424 +#endif
7425 + switch (pax_handle_fetch_fault(regs)) {
7426 + }
7427 +
7428 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7429 + do_group_exit(SIGKILL);
7430 + }
7431 + }
7432 +#endif
7433 +
7434 _exception(SIGSEGV, regs, code, address);
7435 goto bail;
7436 }
7437 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7438 index 67a42ed..cd463e0 100644
7439 --- a/arch/powerpc/mm/mmap_64.c
7440 +++ b/arch/powerpc/mm/mmap_64.c
7441 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7442 {
7443 unsigned long rnd = 0;
7444
7445 +#ifdef CONFIG_PAX_RANDMMAP
7446 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7447 +#endif
7448 +
7449 if (current->flags & PF_RANDOMIZE) {
7450 /* 8MB for 32bit, 1GB for 64bit */
7451 if (is_32bit_task())
7452 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7453 */
7454 if (mmap_is_legacy()) {
7455 mm->mmap_base = TASK_UNMAPPED_BASE;
7456 +
7457 +#ifdef CONFIG_PAX_RANDMMAP
7458 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7459 + mm->mmap_base += mm->delta_mmap;
7460 +#endif
7461 +
7462 mm->get_unmapped_area = arch_get_unmapped_area;
7463 mm->unmap_area = arch_unmap_area;
7464 } else {
7465 mm->mmap_base = mmap_base();
7466 +
7467 +#ifdef CONFIG_PAX_RANDMMAP
7468 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7469 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7470 +#endif
7471 +
7472 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7473 mm->unmap_area = arch_unmap_area_topdown;
7474 }
7475 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7476 index e779642..e5bb889 100644
7477 --- a/arch/powerpc/mm/mmu_context_nohash.c
7478 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7479 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7480 return NOTIFY_OK;
7481 }
7482
7483 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7484 +static struct notifier_block mmu_context_cpu_nb = {
7485 .notifier_call = mmu_context_cpu_notify,
7486 };
7487
7488 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7489 index cafad40..9cbc0fc 100644
7490 --- a/arch/powerpc/mm/numa.c
7491 +++ b/arch/powerpc/mm/numa.c
7492 @@ -920,7 +920,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7493 return ret;
7494 }
7495
7496 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7497 +static struct notifier_block ppc64_numa_nb = {
7498 .notifier_call = cpu_numa_callback,
7499 .priority = 1 /* Must run before sched domains notifier. */
7500 };
7501 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7502 index 3e99c14..f00953c 100644
7503 --- a/arch/powerpc/mm/slice.c
7504 +++ b/arch/powerpc/mm/slice.c
7505 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7506 if ((mm->task_size - len) < addr)
7507 return 0;
7508 vma = find_vma(mm, addr);
7509 - return (!vma || (addr + len) <= vma->vm_start);
7510 + return check_heap_stack_gap(vma, addr, len, 0);
7511 }
7512
7513 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7514 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
7515 info.align_offset = 0;
7516
7517 addr = TASK_UNMAPPED_BASE;
7518 +
7519 +#ifdef CONFIG_PAX_RANDMMAP
7520 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7521 + addr += mm->delta_mmap;
7522 +#endif
7523 +
7524 while (addr < TASK_SIZE) {
7525 info.low_limit = addr;
7526 if (!slice_scan_available(addr, available, 1, &addr))
7527 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7528 if (fixed && addr > (mm->task_size - len))
7529 return -EINVAL;
7530
7531 +#ifdef CONFIG_PAX_RANDMMAP
7532 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7533 + addr = 0;
7534 +#endif
7535 +
7536 /* If hint, make sure it matches our alignment restrictions */
7537 if (!fixed && addr) {
7538 addr = _ALIGN_UP(addr, 1ul << pshift);
7539 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7540 index 9098692..3d54cd1 100644
7541 --- a/arch/powerpc/platforms/cell/spufs/file.c
7542 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7543 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7544 return VM_FAULT_NOPAGE;
7545 }
7546
7547 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7548 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7549 unsigned long address,
7550 - void *buf, int len, int write)
7551 + void *buf, size_t len, int write)
7552 {
7553 struct spu_context *ctx = vma->vm_file->private_data;
7554 unsigned long offset = address - vma->vm_start;
7555 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7556 index bdb738a..49c9f95 100644
7557 --- a/arch/powerpc/platforms/powermac/smp.c
7558 +++ b/arch/powerpc/platforms/powermac/smp.c
7559 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7560 return NOTIFY_OK;
7561 }
7562
7563 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7564 +static struct notifier_block smp_core99_cpu_nb = {
7565 .notifier_call = smp_core99_cpu_notify,
7566 };
7567 #endif /* CONFIG_HOTPLUG_CPU */
7568 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7569 index c797832..ce575c8 100644
7570 --- a/arch/s390/include/asm/atomic.h
7571 +++ b/arch/s390/include/asm/atomic.h
7572 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7573 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7574 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7575
7576 +#define atomic64_read_unchecked(v) atomic64_read(v)
7577 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7578 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7579 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7580 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7581 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7582 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7583 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7584 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7585 +
7586 #define smp_mb__before_atomic_dec() smp_mb()
7587 #define smp_mb__after_atomic_dec() smp_mb()
7588 #define smp_mb__before_atomic_inc() smp_mb()
7589 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7590 index 4d7ccac..d03d0ad 100644
7591 --- a/arch/s390/include/asm/cache.h
7592 +++ b/arch/s390/include/asm/cache.h
7593 @@ -9,8 +9,10 @@
7594 #ifndef __ARCH_S390_CACHE_H
7595 #define __ARCH_S390_CACHE_H
7596
7597 -#define L1_CACHE_BYTES 256
7598 +#include <linux/const.h>
7599 +
7600 #define L1_CACHE_SHIFT 8
7601 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7602 #define NET_SKB_PAD 32
7603
7604 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7605 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7606 index 78f4f87..598ce39 100644
7607 --- a/arch/s390/include/asm/elf.h
7608 +++ b/arch/s390/include/asm/elf.h
7609 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
7610 the loader. We need to make sure that it is out of the way of the program
7611 that it will "exec", and that there is sufficient room for the brk. */
7612
7613 -extern unsigned long randomize_et_dyn(unsigned long base);
7614 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7615 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7616 +
7617 +#ifdef CONFIG_PAX_ASLR
7618 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7619 +
7620 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7621 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7622 +#endif
7623
7624 /* This yields a mask that user programs can use to figure out what
7625 instruction set this CPU supports. */
7626 @@ -222,9 +228,6 @@ struct linux_binprm;
7627 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7628 int arch_setup_additional_pages(struct linux_binprm *, int);
7629
7630 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7631 -#define arch_randomize_brk arch_randomize_brk
7632 -
7633 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7634
7635 #endif
7636 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7637 index c4a93d6..4d2a9b4 100644
7638 --- a/arch/s390/include/asm/exec.h
7639 +++ b/arch/s390/include/asm/exec.h
7640 @@ -7,6 +7,6 @@
7641 #ifndef __ASM_EXEC_H
7642 #define __ASM_EXEC_H
7643
7644 -extern unsigned long arch_align_stack(unsigned long sp);
7645 +#define arch_align_stack(x) ((x) & ~0xfUL)
7646
7647 #endif /* __ASM_EXEC_H */
7648 diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h
7649 index b75d7d6..6d6d92b 100644
7650 --- a/arch/s390/include/asm/tlb.h
7651 +++ b/arch/s390/include/asm/tlb.h
7652 @@ -32,6 +32,7 @@ struct mmu_gather {
7653 struct mm_struct *mm;
7654 struct mmu_table_batch *batch;
7655 unsigned int fullmm;
7656 + unsigned long start, end;
7657 };
7658
7659 struct mmu_table_batch {
7660 @@ -48,10 +49,13 @@ extern void tlb_remove_table(struct mmu_gather *tlb, void *table);
7661
7662 static inline void tlb_gather_mmu(struct mmu_gather *tlb,
7663 struct mm_struct *mm,
7664 - unsigned int full_mm_flush)
7665 + unsigned long start,
7666 + unsigned long end)
7667 {
7668 tlb->mm = mm;
7669 - tlb->fullmm = full_mm_flush;
7670 + tlb->start = start;
7671 + tlb->end = end;
7672 + tlb->fullmm = !(start | (end+1));
7673 tlb->batch = NULL;
7674 if (tlb->fullmm)
7675 __tlb_flush_mm(mm);
7676 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7677 index 9c33ed4..e40cbef 100644
7678 --- a/arch/s390/include/asm/uaccess.h
7679 +++ b/arch/s390/include/asm/uaccess.h
7680 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7681 copy_to_user(void __user *to, const void *from, unsigned long n)
7682 {
7683 might_fault();
7684 +
7685 + if ((long)n < 0)
7686 + return n;
7687 +
7688 return __copy_to_user(to, from, n);
7689 }
7690
7691 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7692 static inline unsigned long __must_check
7693 __copy_from_user(void *to, const void __user *from, unsigned long n)
7694 {
7695 + if ((long)n < 0)
7696 + return n;
7697 +
7698 if (__builtin_constant_p(n) && (n <= 256))
7699 return uaccess.copy_from_user_small(n, from, to);
7700 else
7701 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7702 static inline unsigned long __must_check
7703 copy_from_user(void *to, const void __user *from, unsigned long n)
7704 {
7705 - unsigned int sz = __compiletime_object_size(to);
7706 + size_t sz = __compiletime_object_size(to);
7707
7708 might_fault();
7709 - if (unlikely(sz != -1 && sz < n)) {
7710 +
7711 + if ((long)n < 0)
7712 + return n;
7713 +
7714 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7715 copy_from_user_overflow();
7716 return n;
7717 }
7718 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7719 index 7845e15..59c4353 100644
7720 --- a/arch/s390/kernel/module.c
7721 +++ b/arch/s390/kernel/module.c
7722 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7723
7724 /* Increase core size by size of got & plt and set start
7725 offsets for got and plt. */
7726 - me->core_size = ALIGN(me->core_size, 4);
7727 - me->arch.got_offset = me->core_size;
7728 - me->core_size += me->arch.got_size;
7729 - me->arch.plt_offset = me->core_size;
7730 - me->core_size += me->arch.plt_size;
7731 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7732 + me->arch.got_offset = me->core_size_rw;
7733 + me->core_size_rw += me->arch.got_size;
7734 + me->arch.plt_offset = me->core_size_rx;
7735 + me->core_size_rx += me->arch.plt_size;
7736 return 0;
7737 }
7738
7739 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7740 if (info->got_initialized == 0) {
7741 Elf_Addr *gotent;
7742
7743 - gotent = me->module_core + me->arch.got_offset +
7744 + gotent = me->module_core_rw + me->arch.got_offset +
7745 info->got_offset;
7746 *gotent = val;
7747 info->got_initialized = 1;
7748 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7749 rc = apply_rela_bits(loc, val, 0, 64, 0);
7750 else if (r_type == R_390_GOTENT ||
7751 r_type == R_390_GOTPLTENT) {
7752 - val += (Elf_Addr) me->module_core - loc;
7753 + val += (Elf_Addr) me->module_core_rw - loc;
7754 rc = apply_rela_bits(loc, val, 1, 32, 1);
7755 }
7756 break;
7757 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7758 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7759 if (info->plt_initialized == 0) {
7760 unsigned int *ip;
7761 - ip = me->module_core + me->arch.plt_offset +
7762 + ip = me->module_core_rx + me->arch.plt_offset +
7763 info->plt_offset;
7764 #ifndef CONFIG_64BIT
7765 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7766 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7767 val - loc + 0xffffUL < 0x1ffffeUL) ||
7768 (r_type == R_390_PLT32DBL &&
7769 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7770 - val = (Elf_Addr) me->module_core +
7771 + val = (Elf_Addr) me->module_core_rx +
7772 me->arch.plt_offset +
7773 info->plt_offset;
7774 val += rela->r_addend - loc;
7775 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7776 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7777 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7778 val = val + rela->r_addend -
7779 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7780 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7781 if (r_type == R_390_GOTOFF16)
7782 rc = apply_rela_bits(loc, val, 0, 16, 0);
7783 else if (r_type == R_390_GOTOFF32)
7784 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7785 break;
7786 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7787 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7788 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7789 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7790 rela->r_addend - loc;
7791 if (r_type == R_390_GOTPC)
7792 rc = apply_rela_bits(loc, val, 1, 32, 0);
7793 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7794 index 2bc3edd..ab9d598 100644
7795 --- a/arch/s390/kernel/process.c
7796 +++ b/arch/s390/kernel/process.c
7797 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
7798 }
7799 return 0;
7800 }
7801 -
7802 -unsigned long arch_align_stack(unsigned long sp)
7803 -{
7804 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7805 - sp -= get_random_int() & ~PAGE_MASK;
7806 - return sp & ~0xf;
7807 -}
7808 -
7809 -static inline unsigned long brk_rnd(void)
7810 -{
7811 - /* 8MB for 32bit, 1GB for 64bit */
7812 - if (is_32bit_task())
7813 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7814 - else
7815 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7816 -}
7817 -
7818 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7819 -{
7820 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7821 -
7822 - if (ret < mm->brk)
7823 - return mm->brk;
7824 - return ret;
7825 -}
7826 -
7827 -unsigned long randomize_et_dyn(unsigned long base)
7828 -{
7829 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7830 -
7831 - if (!(current->flags & PF_RANDOMIZE))
7832 - return base;
7833 - if (ret < base)
7834 - return base;
7835 - return ret;
7836 -}
7837 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7838 index 06bafec..2bca531 100644
7839 --- a/arch/s390/mm/mmap.c
7840 +++ b/arch/s390/mm/mmap.c
7841 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7842 */
7843 if (mmap_is_legacy()) {
7844 mm->mmap_base = TASK_UNMAPPED_BASE;
7845 +
7846 +#ifdef CONFIG_PAX_RANDMMAP
7847 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7848 + mm->mmap_base += mm->delta_mmap;
7849 +#endif
7850 +
7851 mm->get_unmapped_area = arch_get_unmapped_area;
7852 mm->unmap_area = arch_unmap_area;
7853 } else {
7854 mm->mmap_base = mmap_base();
7855 +
7856 +#ifdef CONFIG_PAX_RANDMMAP
7857 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7858 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7859 +#endif
7860 +
7861 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7862 mm->unmap_area = arch_unmap_area_topdown;
7863 }
7864 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7865 */
7866 if (mmap_is_legacy()) {
7867 mm->mmap_base = TASK_UNMAPPED_BASE;
7868 +
7869 +#ifdef CONFIG_PAX_RANDMMAP
7870 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7871 + mm->mmap_base += mm->delta_mmap;
7872 +#endif
7873 +
7874 mm->get_unmapped_area = s390_get_unmapped_area;
7875 mm->unmap_area = arch_unmap_area;
7876 } else {
7877 mm->mmap_base = mmap_base();
7878 +
7879 +#ifdef CONFIG_PAX_RANDMMAP
7880 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7881 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7882 +#endif
7883 +
7884 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7885 mm->unmap_area = arch_unmap_area_topdown;
7886 }
7887 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7888 index ae3d59f..f65f075 100644
7889 --- a/arch/score/include/asm/cache.h
7890 +++ b/arch/score/include/asm/cache.h
7891 @@ -1,7 +1,9 @@
7892 #ifndef _ASM_SCORE_CACHE_H
7893 #define _ASM_SCORE_CACHE_H
7894
7895 +#include <linux/const.h>
7896 +
7897 #define L1_CACHE_SHIFT 4
7898 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7899 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7900
7901 #endif /* _ASM_SCORE_CACHE_H */
7902 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7903 index f9f3cd5..58ff438 100644
7904 --- a/arch/score/include/asm/exec.h
7905 +++ b/arch/score/include/asm/exec.h
7906 @@ -1,6 +1,6 @@
7907 #ifndef _ASM_SCORE_EXEC_H
7908 #define _ASM_SCORE_EXEC_H
7909
7910 -extern unsigned long arch_align_stack(unsigned long sp);
7911 +#define arch_align_stack(x) (x)
7912
7913 #endif /* _ASM_SCORE_EXEC_H */
7914 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7915 index f4c6d02..e9355c3 100644
7916 --- a/arch/score/kernel/process.c
7917 +++ b/arch/score/kernel/process.c
7918 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
7919
7920 return task_pt_regs(task)->cp0_epc;
7921 }
7922 -
7923 -unsigned long arch_align_stack(unsigned long sp)
7924 -{
7925 - return sp;
7926 -}
7927 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7928 index ef9e555..331bd29 100644
7929 --- a/arch/sh/include/asm/cache.h
7930 +++ b/arch/sh/include/asm/cache.h
7931 @@ -9,10 +9,11 @@
7932 #define __ASM_SH_CACHE_H
7933 #ifdef __KERNEL__
7934
7935 +#include <linux/const.h>
7936 #include <linux/init.h>
7937 #include <cpu/cache.h>
7938
7939 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7940 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7941
7942 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7943
7944 diff --git a/arch/sh/include/asm/tlb.h b/arch/sh/include/asm/tlb.h
7945 index e61d43d..362192e 100644
7946 --- a/arch/sh/include/asm/tlb.h
7947 +++ b/arch/sh/include/asm/tlb.h
7948 @@ -36,10 +36,12 @@ static inline void init_tlb_gather(struct mmu_gather *tlb)
7949 }
7950
7951 static inline void
7952 -tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int full_mm_flush)
7953 +tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
7954 {
7955 tlb->mm = mm;
7956 - tlb->fullmm = full_mm_flush;
7957 + tlb->start = start;
7958 + tlb->end = end;
7959 + tlb->fullmm = !(start | (end+1));
7960
7961 init_tlb_gather(tlb);
7962 }
7963 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7964 index 03f2b55..b0270327 100644
7965 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7966 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7967 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7968 return NOTIFY_OK;
7969 }
7970
7971 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7972 +static struct notifier_block shx3_cpu_notifier = {
7973 .notifier_call = shx3_cpu_callback,
7974 };
7975
7976 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7977 index 6777177..cb5e44f 100644
7978 --- a/arch/sh/mm/mmap.c
7979 +++ b/arch/sh/mm/mmap.c
7980 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7981 struct mm_struct *mm = current->mm;
7982 struct vm_area_struct *vma;
7983 int do_colour_align;
7984 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7985 struct vm_unmapped_area_info info;
7986
7987 if (flags & MAP_FIXED) {
7988 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7989 if (filp || (flags & MAP_SHARED))
7990 do_colour_align = 1;
7991
7992 +#ifdef CONFIG_PAX_RANDMMAP
7993 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7994 +#endif
7995 +
7996 if (addr) {
7997 if (do_colour_align)
7998 addr = COLOUR_ALIGN(addr, pgoff);
7999 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8000 addr = PAGE_ALIGN(addr);
8001
8002 vma = find_vma(mm, addr);
8003 - if (TASK_SIZE - len >= addr &&
8004 - (!vma || addr + len <= vma->vm_start))
8005 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8006 return addr;
8007 }
8008
8009 info.flags = 0;
8010 info.length = len;
8011 - info.low_limit = TASK_UNMAPPED_BASE;
8012 + info.low_limit = mm->mmap_base;
8013 info.high_limit = TASK_SIZE;
8014 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8015 info.align_offset = pgoff << PAGE_SHIFT;
8016 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8017 struct mm_struct *mm = current->mm;
8018 unsigned long addr = addr0;
8019 int do_colour_align;
8020 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8021 struct vm_unmapped_area_info info;
8022
8023 if (flags & MAP_FIXED) {
8024 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8025 if (filp || (flags & MAP_SHARED))
8026 do_colour_align = 1;
8027
8028 +#ifdef CONFIG_PAX_RANDMMAP
8029 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8030 +#endif
8031 +
8032 /* requesting a specific address */
8033 if (addr) {
8034 if (do_colour_align)
8035 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8036 addr = PAGE_ALIGN(addr);
8037
8038 vma = find_vma(mm, addr);
8039 - if (TASK_SIZE - len >= addr &&
8040 - (!vma || addr + len <= vma->vm_start))
8041 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8042 return addr;
8043 }
8044
8045 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8046 VM_BUG_ON(addr != -ENOMEM);
8047 info.flags = 0;
8048 info.low_limit = TASK_UNMAPPED_BASE;
8049 +
8050 +#ifdef CONFIG_PAX_RANDMMAP
8051 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8052 + info.low_limit += mm->delta_mmap;
8053 +#endif
8054 +
8055 info.high_limit = TASK_SIZE;
8056 addr = vm_unmapped_area(&info);
8057 }
8058 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8059 index be56a24..443328f 100644
8060 --- a/arch/sparc/include/asm/atomic_64.h
8061 +++ b/arch/sparc/include/asm/atomic_64.h
8062 @@ -14,18 +14,40 @@
8063 #define ATOMIC64_INIT(i) { (i) }
8064
8065 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8066 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8067 +{
8068 + return v->counter;
8069 +}
8070 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8071 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8072 +{
8073 + return v->counter;
8074 +}
8075
8076 #define atomic_set(v, i) (((v)->counter) = i)
8077 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8078 +{
8079 + v->counter = i;
8080 +}
8081 #define atomic64_set(v, i) (((v)->counter) = i)
8082 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8083 +{
8084 + v->counter = i;
8085 +}
8086
8087 extern void atomic_add(int, atomic_t *);
8088 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8089 extern void atomic64_add(long, atomic64_t *);
8090 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8091 extern void atomic_sub(int, atomic_t *);
8092 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8093 extern void atomic64_sub(long, atomic64_t *);
8094 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8095
8096 extern int atomic_add_ret(int, atomic_t *);
8097 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8098 extern long atomic64_add_ret(long, atomic64_t *);
8099 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8100 extern int atomic_sub_ret(int, atomic_t *);
8101 extern long atomic64_sub_ret(long, atomic64_t *);
8102
8103 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8104 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8105
8106 #define atomic_inc_return(v) atomic_add_ret(1, v)
8107 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8108 +{
8109 + return atomic_add_ret_unchecked(1, v);
8110 +}
8111 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8112 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8113 +{
8114 + return atomic64_add_ret_unchecked(1, v);
8115 +}
8116
8117 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8118 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8119
8120 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8121 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8122 +{
8123 + return atomic_add_ret_unchecked(i, v);
8124 +}
8125 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8126 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8127 +{
8128 + return atomic64_add_ret_unchecked(i, v);
8129 +}
8130
8131 /*
8132 * atomic_inc_and_test - increment and test
8133 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8134 * other cases.
8135 */
8136 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8137 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8138 +{
8139 + return atomic_inc_return_unchecked(v) == 0;
8140 +}
8141 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8142
8143 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8144 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8145 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8146
8147 #define atomic_inc(v) atomic_add(1, v)
8148 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8149 +{
8150 + atomic_add_unchecked(1, v);
8151 +}
8152 #define atomic64_inc(v) atomic64_add(1, v)
8153 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8154 +{
8155 + atomic64_add_unchecked(1, v);
8156 +}
8157
8158 #define atomic_dec(v) atomic_sub(1, v)
8159 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8160 +{
8161 + atomic_sub_unchecked(1, v);
8162 +}
8163 #define atomic64_dec(v) atomic64_sub(1, v)
8164 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8165 +{
8166 + atomic64_sub_unchecked(1, v);
8167 +}
8168
8169 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8170 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8171
8172 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8173 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8174 +{
8175 + return cmpxchg(&v->counter, old, new);
8176 +}
8177 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8178 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8179 +{
8180 + return xchg(&v->counter, new);
8181 +}
8182
8183 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8184 {
8185 - int c, old;
8186 + int c, old, new;
8187 c = atomic_read(v);
8188 for (;;) {
8189 - if (unlikely(c == (u)))
8190 + if (unlikely(c == u))
8191 break;
8192 - old = atomic_cmpxchg((v), c, c + (a));
8193 +
8194 + asm volatile("addcc %2, %0, %0\n"
8195 +
8196 +#ifdef CONFIG_PAX_REFCOUNT
8197 + "tvs %%icc, 6\n"
8198 +#endif
8199 +
8200 + : "=r" (new)
8201 + : "0" (c), "ir" (a)
8202 + : "cc");
8203 +
8204 + old = atomic_cmpxchg(v, c, new);
8205 if (likely(old == c))
8206 break;
8207 c = old;
8208 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8209 #define atomic64_cmpxchg(v, o, n) \
8210 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8211 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8212 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8213 +{
8214 + return xchg(&v->counter, new);
8215 +}
8216
8217 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8218 {
8219 - long c, old;
8220 + long c, old, new;
8221 c = atomic64_read(v);
8222 for (;;) {
8223 - if (unlikely(c == (u)))
8224 + if (unlikely(c == u))
8225 break;
8226 - old = atomic64_cmpxchg((v), c, c + (a));
8227 +
8228 + asm volatile("addcc %2, %0, %0\n"
8229 +
8230 +#ifdef CONFIG_PAX_REFCOUNT
8231 + "tvs %%xcc, 6\n"
8232 +#endif
8233 +
8234 + : "=r" (new)
8235 + : "0" (c), "ir" (a)
8236 + : "cc");
8237 +
8238 + old = atomic64_cmpxchg(v, c, new);
8239 if (likely(old == c))
8240 break;
8241 c = old;
8242 }
8243 - return c != (u);
8244 + return c != u;
8245 }
8246
8247 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8248 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
8249 index 5bb6991..5c2132e 100644
8250 --- a/arch/sparc/include/asm/cache.h
8251 +++ b/arch/sparc/include/asm/cache.h
8252 @@ -7,10 +7,12 @@
8253 #ifndef _SPARC_CACHE_H
8254 #define _SPARC_CACHE_H
8255
8256 +#include <linux/const.h>
8257 +
8258 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
8259
8260 #define L1_CACHE_SHIFT 5
8261 -#define L1_CACHE_BYTES 32
8262 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8263
8264 #ifdef CONFIG_SPARC32
8265 #define SMP_CACHE_BYTES_SHIFT 5
8266 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
8267 index a24e41f..47677ff 100644
8268 --- a/arch/sparc/include/asm/elf_32.h
8269 +++ b/arch/sparc/include/asm/elf_32.h
8270 @@ -114,6 +114,13 @@ typedef struct {
8271
8272 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
8273
8274 +#ifdef CONFIG_PAX_ASLR
8275 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
8276 +
8277 +#define PAX_DELTA_MMAP_LEN 16
8278 +#define PAX_DELTA_STACK_LEN 16
8279 +#endif
8280 +
8281 /* This yields a mask that user programs can use to figure out what
8282 instruction set this cpu supports. This can NOT be done in userspace
8283 on Sparc. */
8284 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
8285 index 370ca1e..d4f4a98 100644
8286 --- a/arch/sparc/include/asm/elf_64.h
8287 +++ b/arch/sparc/include/asm/elf_64.h
8288 @@ -189,6 +189,13 @@ typedef struct {
8289 #define ELF_ET_DYN_BASE 0x0000010000000000UL
8290 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
8291
8292 +#ifdef CONFIG_PAX_ASLR
8293 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
8294 +
8295 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
8296 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
8297 +#endif
8298 +
8299 extern unsigned long sparc64_elf_hwcap;
8300 #define ELF_HWCAP sparc64_elf_hwcap
8301
8302 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
8303 index 9b1c36d..209298b 100644
8304 --- a/arch/sparc/include/asm/pgalloc_32.h
8305 +++ b/arch/sparc/include/asm/pgalloc_32.h
8306 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
8307 }
8308
8309 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
8310 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
8311
8312 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
8313 unsigned long address)
8314 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
8315 index bcfe063..b333142 100644
8316 --- a/arch/sparc/include/asm/pgalloc_64.h
8317 +++ b/arch/sparc/include/asm/pgalloc_64.h
8318 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8319 }
8320
8321 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
8322 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
8323
8324 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
8325 {
8326 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
8327 index 6fc1348..390c50a 100644
8328 --- a/arch/sparc/include/asm/pgtable_32.h
8329 +++ b/arch/sparc/include/asm/pgtable_32.h
8330 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
8331 #define PAGE_SHARED SRMMU_PAGE_SHARED
8332 #define PAGE_COPY SRMMU_PAGE_COPY
8333 #define PAGE_READONLY SRMMU_PAGE_RDONLY
8334 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
8335 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
8336 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
8337 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
8338
8339 /* Top-level page directory - dummy used by init-mm.
8340 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
8341
8342 /* xwr */
8343 #define __P000 PAGE_NONE
8344 -#define __P001 PAGE_READONLY
8345 -#define __P010 PAGE_COPY
8346 -#define __P011 PAGE_COPY
8347 +#define __P001 PAGE_READONLY_NOEXEC
8348 +#define __P010 PAGE_COPY_NOEXEC
8349 +#define __P011 PAGE_COPY_NOEXEC
8350 #define __P100 PAGE_READONLY
8351 #define __P101 PAGE_READONLY
8352 #define __P110 PAGE_COPY
8353 #define __P111 PAGE_COPY
8354
8355 #define __S000 PAGE_NONE
8356 -#define __S001 PAGE_READONLY
8357 -#define __S010 PAGE_SHARED
8358 -#define __S011 PAGE_SHARED
8359 +#define __S001 PAGE_READONLY_NOEXEC
8360 +#define __S010 PAGE_SHARED_NOEXEC
8361 +#define __S011 PAGE_SHARED_NOEXEC
8362 #define __S100 PAGE_READONLY
8363 #define __S101 PAGE_READONLY
8364 #define __S110 PAGE_SHARED
8365 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
8366 index 79da178..c2eede8 100644
8367 --- a/arch/sparc/include/asm/pgtsrmmu.h
8368 +++ b/arch/sparc/include/asm/pgtsrmmu.h
8369 @@ -115,6 +115,11 @@
8370 SRMMU_EXEC | SRMMU_REF)
8371 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
8372 SRMMU_EXEC | SRMMU_REF)
8373 +
8374 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
8375 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8376 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8377 +
8378 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8379 SRMMU_DIRTY | SRMMU_REF)
8380
8381 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8382 index 9689176..63c18ea 100644
8383 --- a/arch/sparc/include/asm/spinlock_64.h
8384 +++ b/arch/sparc/include/asm/spinlock_64.h
8385 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8386
8387 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8388
8389 -static void inline arch_read_lock(arch_rwlock_t *lock)
8390 +static inline void arch_read_lock(arch_rwlock_t *lock)
8391 {
8392 unsigned long tmp1, tmp2;
8393
8394 __asm__ __volatile__ (
8395 "1: ldsw [%2], %0\n"
8396 " brlz,pn %0, 2f\n"
8397 -"4: add %0, 1, %1\n"
8398 +"4: addcc %0, 1, %1\n"
8399 +
8400 +#ifdef CONFIG_PAX_REFCOUNT
8401 +" tvs %%icc, 6\n"
8402 +#endif
8403 +
8404 " cas [%2], %0, %1\n"
8405 " cmp %0, %1\n"
8406 " bne,pn %%icc, 1b\n"
8407 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8408 " .previous"
8409 : "=&r" (tmp1), "=&r" (tmp2)
8410 : "r" (lock)
8411 - : "memory");
8412 + : "memory", "cc");
8413 }
8414
8415 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8416 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8417 {
8418 int tmp1, tmp2;
8419
8420 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8421 "1: ldsw [%2], %0\n"
8422 " brlz,a,pn %0, 2f\n"
8423 " mov 0, %0\n"
8424 -" add %0, 1, %1\n"
8425 +" addcc %0, 1, %1\n"
8426 +
8427 +#ifdef CONFIG_PAX_REFCOUNT
8428 +" tvs %%icc, 6\n"
8429 +#endif
8430 +
8431 " cas [%2], %0, %1\n"
8432 " cmp %0, %1\n"
8433 " bne,pn %%icc, 1b\n"
8434 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8435 return tmp1;
8436 }
8437
8438 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8439 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8440 {
8441 unsigned long tmp1, tmp2;
8442
8443 __asm__ __volatile__(
8444 "1: lduw [%2], %0\n"
8445 -" sub %0, 1, %1\n"
8446 +" subcc %0, 1, %1\n"
8447 +
8448 +#ifdef CONFIG_PAX_REFCOUNT
8449 +" tvs %%icc, 6\n"
8450 +#endif
8451 +
8452 " cas [%2], %0, %1\n"
8453 " cmp %0, %1\n"
8454 " bne,pn %%xcc, 1b\n"
8455 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8456 : "memory");
8457 }
8458
8459 -static void inline arch_write_lock(arch_rwlock_t *lock)
8460 +static inline void arch_write_lock(arch_rwlock_t *lock)
8461 {
8462 unsigned long mask, tmp1, tmp2;
8463
8464 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8465 : "memory");
8466 }
8467
8468 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8469 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8470 {
8471 __asm__ __volatile__(
8472 " stw %%g0, [%0]"
8473 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8474 : "memory");
8475 }
8476
8477 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8478 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8479 {
8480 unsigned long mask, tmp1, tmp2, result;
8481
8482 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8483 index dd38075..e7cac83 100644
8484 --- a/arch/sparc/include/asm/thread_info_32.h
8485 +++ b/arch/sparc/include/asm/thread_info_32.h
8486 @@ -49,6 +49,8 @@ struct thread_info {
8487 unsigned long w_saved;
8488
8489 struct restart_block restart_block;
8490 +
8491 + unsigned long lowest_stack;
8492 };
8493
8494 /*
8495 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8496 index d5e5042..9bfee76 100644
8497 --- a/arch/sparc/include/asm/thread_info_64.h
8498 +++ b/arch/sparc/include/asm/thread_info_64.h
8499 @@ -63,6 +63,8 @@ struct thread_info {
8500 struct pt_regs *kern_una_regs;
8501 unsigned int kern_una_insn;
8502
8503 + unsigned long lowest_stack;
8504 +
8505 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8506 };
8507
8508 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8509 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8510 /* flag bit 6 is available */
8511 #define TIF_32BIT 7 /* 32-bit binary */
8512 -/* flag bit 8 is available */
8513 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8514 #define TIF_SECCOMP 9 /* secure computing */
8515 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8516 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8517 +
8518 /* NOTE: Thread flags >= 12 should be ones we have no interest
8519 * in using in assembly, else we can't use the mask as
8520 * an immediate value in instructions such as andcc.
8521 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8522 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8523 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8524 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8525 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8526
8527 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8528 _TIF_DO_NOTIFY_RESUME_MASK | \
8529 _TIF_NEED_RESCHED)
8530 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8531
8532 +#define _TIF_WORK_SYSCALL \
8533 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8534 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8535 +
8536 +
8537 /*
8538 * Thread-synchronous status.
8539 *
8540 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8541 index 0167d26..767bb0c 100644
8542 --- a/arch/sparc/include/asm/uaccess.h
8543 +++ b/arch/sparc/include/asm/uaccess.h
8544 @@ -1,5 +1,6 @@
8545 #ifndef ___ASM_SPARC_UACCESS_H
8546 #define ___ASM_SPARC_UACCESS_H
8547 +
8548 #if defined(__sparc__) && defined(__arch64__)
8549 #include <asm/uaccess_64.h>
8550 #else
8551 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8552 index 53a28dd..50c38c3 100644
8553 --- a/arch/sparc/include/asm/uaccess_32.h
8554 +++ b/arch/sparc/include/asm/uaccess_32.h
8555 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8556
8557 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8558 {
8559 - if (n && __access_ok((unsigned long) to, n))
8560 + if ((long)n < 0)
8561 + return n;
8562 +
8563 + if (n && __access_ok((unsigned long) to, n)) {
8564 + if (!__builtin_constant_p(n))
8565 + check_object_size(from, n, true);
8566 return __copy_user(to, (__force void __user *) from, n);
8567 - else
8568 + } else
8569 return n;
8570 }
8571
8572 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8573 {
8574 + if ((long)n < 0)
8575 + return n;
8576 +
8577 + if (!__builtin_constant_p(n))
8578 + check_object_size(from, n, true);
8579 +
8580 return __copy_user(to, (__force void __user *) from, n);
8581 }
8582
8583 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8584 {
8585 - if (n && __access_ok((unsigned long) from, n))
8586 + if ((long)n < 0)
8587 + return n;
8588 +
8589 + if (n && __access_ok((unsigned long) from, n)) {
8590 + if (!__builtin_constant_p(n))
8591 + check_object_size(to, n, false);
8592 return __copy_user((__force void __user *) to, from, n);
8593 - else
8594 + } else
8595 return n;
8596 }
8597
8598 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8599 {
8600 + if ((long)n < 0)
8601 + return n;
8602 +
8603 return __copy_user((__force void __user *) to, from, n);
8604 }
8605
8606 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8607 index e562d3c..191f176 100644
8608 --- a/arch/sparc/include/asm/uaccess_64.h
8609 +++ b/arch/sparc/include/asm/uaccess_64.h
8610 @@ -10,6 +10,7 @@
8611 #include <linux/compiler.h>
8612 #include <linux/string.h>
8613 #include <linux/thread_info.h>
8614 +#include <linux/kernel.h>
8615 #include <asm/asi.h>
8616 #include <asm/spitfire.h>
8617 #include <asm-generic/uaccess-unaligned.h>
8618 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8619 static inline unsigned long __must_check
8620 copy_from_user(void *to, const void __user *from, unsigned long size)
8621 {
8622 - unsigned long ret = ___copy_from_user(to, from, size);
8623 + unsigned long ret;
8624
8625 + if ((long)size < 0 || size > INT_MAX)
8626 + return size;
8627 +
8628 + if (!__builtin_constant_p(size))
8629 + check_object_size(to, size, false);
8630 +
8631 + ret = ___copy_from_user(to, from, size);
8632 if (unlikely(ret))
8633 ret = copy_from_user_fixup(to, from, size);
8634
8635 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8636 static inline unsigned long __must_check
8637 copy_to_user(void __user *to, const void *from, unsigned long size)
8638 {
8639 - unsigned long ret = ___copy_to_user(to, from, size);
8640 + unsigned long ret;
8641
8642 + if ((long)size < 0 || size > INT_MAX)
8643 + return size;
8644 +
8645 + if (!__builtin_constant_p(size))
8646 + check_object_size(from, size, true);
8647 +
8648 + ret = ___copy_to_user(to, from, size);
8649 if (unlikely(ret))
8650 ret = copy_to_user_fixup(to, from, size);
8651 return ret;
8652 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8653 index d432fb2..6056af1 100644
8654 --- a/arch/sparc/kernel/Makefile
8655 +++ b/arch/sparc/kernel/Makefile
8656 @@ -3,7 +3,7 @@
8657 #
8658
8659 asflags-y := -ansi
8660 -ccflags-y := -Werror
8661 +#ccflags-y := -Werror
8662
8663 extra-y := head_$(BITS).o
8664
8665 diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
8666 index 5ef48da..11d460f 100644
8667 --- a/arch/sparc/kernel/ds.c
8668 +++ b/arch/sparc/kernel/ds.c
8669 @@ -783,6 +783,16 @@ void ldom_set_var(const char *var, const char *value)
8670 char *base, *p;
8671 int msg_len, loops;
8672
8673 + if (strlen(var) + strlen(value) + 2 >
8674 + sizeof(pkt) - sizeof(pkt.header)) {
8675 + printk(KERN_ERR PFX
8676 + "contents length: %zu, which more than max: %lu,"
8677 + "so could not set (%s) variable to (%s).\n",
8678 + strlen(var) + strlen(value) + 2,
8679 + sizeof(pkt) - sizeof(pkt.header), var, value);
8680 + return;
8681 + }
8682 +
8683 memset(&pkt, 0, sizeof(pkt));
8684 pkt.header.data.tag.type = DS_DATA;
8685 pkt.header.data.handle = cp->handle;
8686 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8687 index fdd819d..5af08c8 100644
8688 --- a/arch/sparc/kernel/process_32.c
8689 +++ b/arch/sparc/kernel/process_32.c
8690 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
8691
8692 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8693 r->psr, r->pc, r->npc, r->y, print_tainted());
8694 - printk("PC: <%pS>\n", (void *) r->pc);
8695 + printk("PC: <%pA>\n", (void *) r->pc);
8696 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8697 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8698 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8699 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8700 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8701 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8702 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8703 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8704
8705 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8706 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8707 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8708 rw = (struct reg_window32 *) fp;
8709 pc = rw->ins[7];
8710 printk("[%08lx : ", pc);
8711 - printk("%pS ] ", (void *) pc);
8712 + printk("%pA ] ", (void *) pc);
8713 fp = rw->ins[6];
8714 } while (++count < 16);
8715 printk("\n");
8716 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8717 index baebab2..9cd13b1 100644
8718 --- a/arch/sparc/kernel/process_64.c
8719 +++ b/arch/sparc/kernel/process_64.c
8720 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
8721 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8722 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8723 if (regs->tstate & TSTATE_PRIV)
8724 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8725 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8726 }
8727
8728 void show_regs(struct pt_regs *regs)
8729 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
8730
8731 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8732 regs->tpc, regs->tnpc, regs->y, print_tainted());
8733 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8734 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8735 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8736 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8737 regs->u_regs[3]);
8738 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
8739 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8740 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8741 regs->u_regs[15]);
8742 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8743 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8744 show_regwindow(regs);
8745 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8746 }
8747 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
8748 ((tp && tp->task) ? tp->task->pid : -1));
8749
8750 if (gp->tstate & TSTATE_PRIV) {
8751 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8752 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8753 (void *) gp->tpc,
8754 (void *) gp->o7,
8755 (void *) gp->i7,
8756 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8757 index 79cc0d1..ec62734 100644
8758 --- a/arch/sparc/kernel/prom_common.c
8759 +++ b/arch/sparc/kernel/prom_common.c
8760 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8761
8762 unsigned int prom_early_allocated __initdata;
8763
8764 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8765 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8766 .nextprop = prom_common_nextprop,
8767 .getproplen = prom_getproplen,
8768 .getproperty = prom_getproperty,
8769 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8770 index 7ff45e4..a58f271 100644
8771 --- a/arch/sparc/kernel/ptrace_64.c
8772 +++ b/arch/sparc/kernel/ptrace_64.c
8773 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8774 return ret;
8775 }
8776
8777 +#ifdef CONFIG_GRKERNSEC_SETXID
8778 +extern void gr_delayed_cred_worker(void);
8779 +#endif
8780 +
8781 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8782 {
8783 int ret = 0;
8784 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8785 /* do the secure computing check first */
8786 secure_computing_strict(regs->u_regs[UREG_G1]);
8787
8788 +#ifdef CONFIG_GRKERNSEC_SETXID
8789 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8790 + gr_delayed_cred_worker();
8791 +#endif
8792 +
8793 if (test_thread_flag(TIF_SYSCALL_TRACE))
8794 ret = tracehook_report_syscall_entry(regs);
8795
8796 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8797
8798 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8799 {
8800 +#ifdef CONFIG_GRKERNSEC_SETXID
8801 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8802 + gr_delayed_cred_worker();
8803 +#endif
8804 +
8805 audit_syscall_exit(regs);
8806
8807 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8808 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8809 index 3a8d184..49498a8 100644
8810 --- a/arch/sparc/kernel/sys_sparc_32.c
8811 +++ b/arch/sparc/kernel/sys_sparc_32.c
8812 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8813 if (len > TASK_SIZE - PAGE_SIZE)
8814 return -ENOMEM;
8815 if (!addr)
8816 - addr = TASK_UNMAPPED_BASE;
8817 + addr = current->mm->mmap_base;
8818
8819 info.flags = 0;
8820 info.length = len;
8821 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8822 index 2daaaa6..4fb84dc 100644
8823 --- a/arch/sparc/kernel/sys_sparc_64.c
8824 +++ b/arch/sparc/kernel/sys_sparc_64.c
8825 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8826 struct vm_area_struct * vma;
8827 unsigned long task_size = TASK_SIZE;
8828 int do_color_align;
8829 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8830 struct vm_unmapped_area_info info;
8831
8832 if (flags & MAP_FIXED) {
8833 /* We do not accept a shared mapping if it would violate
8834 * cache aliasing constraints.
8835 */
8836 - if ((flags & MAP_SHARED) &&
8837 + if ((filp || (flags & MAP_SHARED)) &&
8838 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8839 return -EINVAL;
8840 return addr;
8841 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8842 if (filp || (flags & MAP_SHARED))
8843 do_color_align = 1;
8844
8845 +#ifdef CONFIG_PAX_RANDMMAP
8846 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8847 +#endif
8848 +
8849 if (addr) {
8850 if (do_color_align)
8851 addr = COLOR_ALIGN(addr, pgoff);
8852 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8853 addr = PAGE_ALIGN(addr);
8854
8855 vma = find_vma(mm, addr);
8856 - if (task_size - len >= addr &&
8857 - (!vma || addr + len <= vma->vm_start))
8858 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8859 return addr;
8860 }
8861
8862 info.flags = 0;
8863 info.length = len;
8864 - info.low_limit = TASK_UNMAPPED_BASE;
8865 + info.low_limit = mm->mmap_base;
8866 info.high_limit = min(task_size, VA_EXCLUDE_START);
8867 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8868 info.align_offset = pgoff << PAGE_SHIFT;
8869 + info.threadstack_offset = offset;
8870 addr = vm_unmapped_area(&info);
8871
8872 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8873 VM_BUG_ON(addr != -ENOMEM);
8874 info.low_limit = VA_EXCLUDE_END;
8875 +
8876 +#ifdef CONFIG_PAX_RANDMMAP
8877 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8878 + info.low_limit += mm->delta_mmap;
8879 +#endif
8880 +
8881 info.high_limit = task_size;
8882 addr = vm_unmapped_area(&info);
8883 }
8884 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8885 unsigned long task_size = STACK_TOP32;
8886 unsigned long addr = addr0;
8887 int do_color_align;
8888 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8889 struct vm_unmapped_area_info info;
8890
8891 /* This should only ever run for 32-bit processes. */
8892 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8893 /* We do not accept a shared mapping if it would violate
8894 * cache aliasing constraints.
8895 */
8896 - if ((flags & MAP_SHARED) &&
8897 + if ((filp || (flags & MAP_SHARED)) &&
8898 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8899 return -EINVAL;
8900 return addr;
8901 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8902 if (filp || (flags & MAP_SHARED))
8903 do_color_align = 1;
8904
8905 +#ifdef CONFIG_PAX_RANDMMAP
8906 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8907 +#endif
8908 +
8909 /* requesting a specific address */
8910 if (addr) {
8911 if (do_color_align)
8912 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8913 addr = PAGE_ALIGN(addr);
8914
8915 vma = find_vma(mm, addr);
8916 - if (task_size - len >= addr &&
8917 - (!vma || addr + len <= vma->vm_start))
8918 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8919 return addr;
8920 }
8921
8922 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8923 info.high_limit = mm->mmap_base;
8924 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8925 info.align_offset = pgoff << PAGE_SHIFT;
8926 + info.threadstack_offset = offset;
8927 addr = vm_unmapped_area(&info);
8928
8929 /*
8930 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8931 VM_BUG_ON(addr != -ENOMEM);
8932 info.flags = 0;
8933 info.low_limit = TASK_UNMAPPED_BASE;
8934 +
8935 +#ifdef CONFIG_PAX_RANDMMAP
8936 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8937 + info.low_limit += mm->delta_mmap;
8938 +#endif
8939 +
8940 info.high_limit = STACK_TOP32;
8941 addr = vm_unmapped_area(&info);
8942 }
8943 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
8944 EXPORT_SYMBOL(get_fb_unmapped_area);
8945
8946 /* Essentially the same as PowerPC. */
8947 -static unsigned long mmap_rnd(void)
8948 +static unsigned long mmap_rnd(struct mm_struct *mm)
8949 {
8950 unsigned long rnd = 0UL;
8951
8952 +#ifdef CONFIG_PAX_RANDMMAP
8953 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8954 +#endif
8955 +
8956 if (current->flags & PF_RANDOMIZE) {
8957 unsigned long val = get_random_int();
8958 if (test_thread_flag(TIF_32BIT))
8959 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
8960
8961 void arch_pick_mmap_layout(struct mm_struct *mm)
8962 {
8963 - unsigned long random_factor = mmap_rnd();
8964 + unsigned long random_factor = mmap_rnd(mm);
8965 unsigned long gap;
8966
8967 /*
8968 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8969 gap == RLIM_INFINITY ||
8970 sysctl_legacy_va_layout) {
8971 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8972 +
8973 +#ifdef CONFIG_PAX_RANDMMAP
8974 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8975 + mm->mmap_base += mm->delta_mmap;
8976 +#endif
8977 +
8978 mm->get_unmapped_area = arch_get_unmapped_area;
8979 mm->unmap_area = arch_unmap_area;
8980 } else {
8981 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8982 gap = (task_size / 6 * 5);
8983
8984 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8985 +
8986 +#ifdef CONFIG_PAX_RANDMMAP
8987 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8988 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8989 +#endif
8990 +
8991 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8992 mm->unmap_area = arch_unmap_area_topdown;
8993 }
8994 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8995 index 22a1098..6255eb9 100644
8996 --- a/arch/sparc/kernel/syscalls.S
8997 +++ b/arch/sparc/kernel/syscalls.S
8998 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8999 #endif
9000 .align 32
9001 1: ldx [%g6 + TI_FLAGS], %l5
9002 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9003 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9004 be,pt %icc, rtrap
9005 nop
9006 call syscall_trace_leave
9007 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9008
9009 srl %i5, 0, %o5 ! IEU1
9010 srl %i2, 0, %o2 ! IEU0 Group
9011 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9012 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9013 bne,pn %icc, linux_syscall_trace32 ! CTI
9014 mov %i0, %l5 ! IEU1
9015 call %l7 ! CTI Group brk forced
9016 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9017
9018 mov %i3, %o3 ! IEU1
9019 mov %i4, %o4 ! IEU0 Group
9020 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9021 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9022 bne,pn %icc, linux_syscall_trace ! CTI Group
9023 mov %i0, %l5 ! IEU0
9024 2: call %l7 ! CTI Group brk forced
9025 @@ -223,7 +223,7 @@ ret_sys_call:
9026
9027 cmp %o0, -ERESTART_RESTARTBLOCK
9028 bgeu,pn %xcc, 1f
9029 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9030 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9031 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9032
9033 2:
9034 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
9035 index 654e8aa..45f431b 100644
9036 --- a/arch/sparc/kernel/sysfs.c
9037 +++ b/arch/sparc/kernel/sysfs.c
9038 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
9039 return NOTIFY_OK;
9040 }
9041
9042 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
9043 +static struct notifier_block sysfs_cpu_nb = {
9044 .notifier_call = sysfs_cpu_notify,
9045 };
9046
9047 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9048 index 6629829..036032d 100644
9049 --- a/arch/sparc/kernel/traps_32.c
9050 +++ b/arch/sparc/kernel/traps_32.c
9051 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9052 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9053 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9054
9055 +extern void gr_handle_kernel_exploit(void);
9056 +
9057 void die_if_kernel(char *str, struct pt_regs *regs)
9058 {
9059 static int die_counter;
9060 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9061 count++ < 30 &&
9062 (((unsigned long) rw) >= PAGE_OFFSET) &&
9063 !(((unsigned long) rw) & 0x7)) {
9064 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9065 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9066 (void *) rw->ins[7]);
9067 rw = (struct reg_window32 *)rw->ins[6];
9068 }
9069 }
9070 printk("Instruction DUMP:");
9071 instruction_dump ((unsigned long *) regs->pc);
9072 - if(regs->psr & PSR_PS)
9073 + if(regs->psr & PSR_PS) {
9074 + gr_handle_kernel_exploit();
9075 do_exit(SIGKILL);
9076 + }
9077 do_exit(SIGSEGV);
9078 }
9079
9080 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9081 index b3f833a..ac74b2d 100644
9082 --- a/arch/sparc/kernel/traps_64.c
9083 +++ b/arch/sparc/kernel/traps_64.c
9084 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9085 i + 1,
9086 p->trapstack[i].tstate, p->trapstack[i].tpc,
9087 p->trapstack[i].tnpc, p->trapstack[i].tt);
9088 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9089 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9090 }
9091 }
9092
9093 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9094
9095 lvl -= 0x100;
9096 if (regs->tstate & TSTATE_PRIV) {
9097 +
9098 +#ifdef CONFIG_PAX_REFCOUNT
9099 + if (lvl == 6)
9100 + pax_report_refcount_overflow(regs);
9101 +#endif
9102 +
9103 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9104 die_if_kernel(buffer, regs);
9105 }
9106 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9107 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9108 {
9109 char buffer[32];
9110 -
9111 +
9112 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9113 0, lvl, SIGTRAP) == NOTIFY_STOP)
9114 return;
9115
9116 +#ifdef CONFIG_PAX_REFCOUNT
9117 + if (lvl == 6)
9118 + pax_report_refcount_overflow(regs);
9119 +#endif
9120 +
9121 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9122
9123 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9124 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9125 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9126 printk("%s" "ERROR(%d): ",
9127 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9128 - printk("TPC<%pS>\n", (void *) regs->tpc);
9129 + printk("TPC<%pA>\n", (void *) regs->tpc);
9130 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9131 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9132 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9133 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9134 smp_processor_id(),
9135 (type & 0x1) ? 'I' : 'D',
9136 regs->tpc);
9137 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9138 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9139 panic("Irrecoverable Cheetah+ parity error.");
9140 }
9141
9142 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9143 smp_processor_id(),
9144 (type & 0x1) ? 'I' : 'D',
9145 regs->tpc);
9146 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9147 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9148 }
9149
9150 struct sun4v_error_entry {
9151 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
9152
9153 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
9154 regs->tpc, tl);
9155 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
9156 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
9157 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9158 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
9159 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
9160 (void *) regs->u_regs[UREG_I7]);
9161 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
9162 "pte[%lx] error[%lx]\n",
9163 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
9164
9165 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
9166 regs->tpc, tl);
9167 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
9168 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
9169 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9170 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
9171 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
9172 (void *) regs->u_regs[UREG_I7]);
9173 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
9174 "pte[%lx] error[%lx]\n",
9175 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9176 fp = (unsigned long)sf->fp + STACK_BIAS;
9177 }
9178
9179 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9180 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9181 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9182 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
9183 int index = tsk->curr_ret_stack;
9184 if (tsk->ret_stack && index >= graph) {
9185 pc = tsk->ret_stack[index - graph].ret;
9186 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9187 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9188 graph++;
9189 }
9190 }
9191 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
9192 return (struct reg_window *) (fp + STACK_BIAS);
9193 }
9194
9195 +extern void gr_handle_kernel_exploit(void);
9196 +
9197 void die_if_kernel(char *str, struct pt_regs *regs)
9198 {
9199 static int die_counter;
9200 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9201 while (rw &&
9202 count++ < 30 &&
9203 kstack_valid(tp, (unsigned long) rw)) {
9204 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
9205 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
9206 (void *) rw->ins[7]);
9207
9208 rw = kernel_stack_up(rw);
9209 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9210 }
9211 user_instruction_dump ((unsigned int __user *) regs->tpc);
9212 }
9213 - if (regs->tstate & TSTATE_PRIV)
9214 + if (regs->tstate & TSTATE_PRIV) {
9215 + gr_handle_kernel_exploit();
9216 do_exit(SIGKILL);
9217 + }
9218 do_exit(SIGSEGV);
9219 }
9220 EXPORT_SYMBOL(die_if_kernel);
9221 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
9222 index 8201c25e..072a2a7 100644
9223 --- a/arch/sparc/kernel/unaligned_64.c
9224 +++ b/arch/sparc/kernel/unaligned_64.c
9225 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
9226 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
9227
9228 if (__ratelimit(&ratelimit)) {
9229 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
9230 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
9231 regs->tpc, (void *) regs->tpc);
9232 }
9233 }
9234 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
9235 index dbe119b..089c7c1 100644
9236 --- a/arch/sparc/lib/Makefile
9237 +++ b/arch/sparc/lib/Makefile
9238 @@ -2,7 +2,7 @@
9239 #
9240
9241 asflags-y := -ansi -DST_DIV0=0x02
9242 -ccflags-y := -Werror
9243 +#ccflags-y := -Werror
9244
9245 lib-$(CONFIG_SPARC32) += ashrdi3.o
9246 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
9247 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
9248 index 85c233d..68500e0 100644
9249 --- a/arch/sparc/lib/atomic_64.S
9250 +++ b/arch/sparc/lib/atomic_64.S
9251 @@ -17,7 +17,12 @@
9252 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9253 BACKOFF_SETUP(%o2)
9254 1: lduw [%o1], %g1
9255 - add %g1, %o0, %g7
9256 + addcc %g1, %o0, %g7
9257 +
9258 +#ifdef CONFIG_PAX_REFCOUNT
9259 + tvs %icc, 6
9260 +#endif
9261 +
9262 cas [%o1], %g1, %g7
9263 cmp %g1, %g7
9264 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9265 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9266 2: BACKOFF_SPIN(%o2, %o3, 1b)
9267 ENDPROC(atomic_add)
9268
9269 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9270 + BACKOFF_SETUP(%o2)
9271 +1: lduw [%o1], %g1
9272 + add %g1, %o0, %g7
9273 + cas [%o1], %g1, %g7
9274 + cmp %g1, %g7
9275 + bne,pn %icc, 2f
9276 + nop
9277 + retl
9278 + nop
9279 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9280 +ENDPROC(atomic_add_unchecked)
9281 +
9282 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9283 BACKOFF_SETUP(%o2)
9284 1: lduw [%o1], %g1
9285 - sub %g1, %o0, %g7
9286 + subcc %g1, %o0, %g7
9287 +
9288 +#ifdef CONFIG_PAX_REFCOUNT
9289 + tvs %icc, 6
9290 +#endif
9291 +
9292 cas [%o1], %g1, %g7
9293 cmp %g1, %g7
9294 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9295 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9296 2: BACKOFF_SPIN(%o2, %o3, 1b)
9297 ENDPROC(atomic_sub)
9298
9299 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9300 + BACKOFF_SETUP(%o2)
9301 +1: lduw [%o1], %g1
9302 + sub %g1, %o0, %g7
9303 + cas [%o1], %g1, %g7
9304 + cmp %g1, %g7
9305 + bne,pn %icc, 2f
9306 + nop
9307 + retl
9308 + nop
9309 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9310 +ENDPROC(atomic_sub_unchecked)
9311 +
9312 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9313 BACKOFF_SETUP(%o2)
9314 1: lduw [%o1], %g1
9315 - add %g1, %o0, %g7
9316 + addcc %g1, %o0, %g7
9317 +
9318 +#ifdef CONFIG_PAX_REFCOUNT
9319 + tvs %icc, 6
9320 +#endif
9321 +
9322 cas [%o1], %g1, %g7
9323 cmp %g1, %g7
9324 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9325 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9326 2: BACKOFF_SPIN(%o2, %o3, 1b)
9327 ENDPROC(atomic_add_ret)
9328
9329 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9330 + BACKOFF_SETUP(%o2)
9331 +1: lduw [%o1], %g1
9332 + addcc %g1, %o0, %g7
9333 + cas [%o1], %g1, %g7
9334 + cmp %g1, %g7
9335 + bne,pn %icc, 2f
9336 + add %g7, %o0, %g7
9337 + sra %g7, 0, %o0
9338 + retl
9339 + nop
9340 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9341 +ENDPROC(atomic_add_ret_unchecked)
9342 +
9343 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9344 BACKOFF_SETUP(%o2)
9345 1: lduw [%o1], %g1
9346 - sub %g1, %o0, %g7
9347 + subcc %g1, %o0, %g7
9348 +
9349 +#ifdef CONFIG_PAX_REFCOUNT
9350 + tvs %icc, 6
9351 +#endif
9352 +
9353 cas [%o1], %g1, %g7
9354 cmp %g1, %g7
9355 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9356 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9357 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9358 BACKOFF_SETUP(%o2)
9359 1: ldx [%o1], %g1
9360 - add %g1, %o0, %g7
9361 + addcc %g1, %o0, %g7
9362 +
9363 +#ifdef CONFIG_PAX_REFCOUNT
9364 + tvs %xcc, 6
9365 +#endif
9366 +
9367 casx [%o1], %g1, %g7
9368 cmp %g1, %g7
9369 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9370 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9371 2: BACKOFF_SPIN(%o2, %o3, 1b)
9372 ENDPROC(atomic64_add)
9373
9374 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9375 + BACKOFF_SETUP(%o2)
9376 +1: ldx [%o1], %g1
9377 + addcc %g1, %o0, %g7
9378 + casx [%o1], %g1, %g7
9379 + cmp %g1, %g7
9380 + bne,pn %xcc, 2f
9381 + nop
9382 + retl
9383 + nop
9384 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9385 +ENDPROC(atomic64_add_unchecked)
9386 +
9387 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9388 BACKOFF_SETUP(%o2)
9389 1: ldx [%o1], %g1
9390 - sub %g1, %o0, %g7
9391 + subcc %g1, %o0, %g7
9392 +
9393 +#ifdef CONFIG_PAX_REFCOUNT
9394 + tvs %xcc, 6
9395 +#endif
9396 +
9397 casx [%o1], %g1, %g7
9398 cmp %g1, %g7
9399 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9400 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9401 2: BACKOFF_SPIN(%o2, %o3, 1b)
9402 ENDPROC(atomic64_sub)
9403
9404 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9405 + BACKOFF_SETUP(%o2)
9406 +1: ldx [%o1], %g1
9407 + subcc %g1, %o0, %g7
9408 + casx [%o1], %g1, %g7
9409 + cmp %g1, %g7
9410 + bne,pn %xcc, 2f
9411 + nop
9412 + retl
9413 + nop
9414 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9415 +ENDPROC(atomic64_sub_unchecked)
9416 +
9417 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9418 BACKOFF_SETUP(%o2)
9419 1: ldx [%o1], %g1
9420 - add %g1, %o0, %g7
9421 + addcc %g1, %o0, %g7
9422 +
9423 +#ifdef CONFIG_PAX_REFCOUNT
9424 + tvs %xcc, 6
9425 +#endif
9426 +
9427 casx [%o1], %g1, %g7
9428 cmp %g1, %g7
9429 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9430 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9431 2: BACKOFF_SPIN(%o2, %o3, 1b)
9432 ENDPROC(atomic64_add_ret)
9433
9434 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9435 + BACKOFF_SETUP(%o2)
9436 +1: ldx [%o1], %g1
9437 + addcc %g1, %o0, %g7
9438 + casx [%o1], %g1, %g7
9439 + cmp %g1, %g7
9440 + bne,pn %xcc, 2f
9441 + add %g7, %o0, %g7
9442 + mov %g7, %o0
9443 + retl
9444 + nop
9445 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9446 +ENDPROC(atomic64_add_ret_unchecked)
9447 +
9448 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9449 BACKOFF_SETUP(%o2)
9450 1: ldx [%o1], %g1
9451 - sub %g1, %o0, %g7
9452 + subcc %g1, %o0, %g7
9453 +
9454 +#ifdef CONFIG_PAX_REFCOUNT
9455 + tvs %xcc, 6
9456 +#endif
9457 +
9458 casx [%o1], %g1, %g7
9459 cmp %g1, %g7
9460 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9461 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9462 index 0c4e35e..745d3e4 100644
9463 --- a/arch/sparc/lib/ksyms.c
9464 +++ b/arch/sparc/lib/ksyms.c
9465 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9466
9467 /* Atomic counter implementation. */
9468 EXPORT_SYMBOL(atomic_add);
9469 +EXPORT_SYMBOL(atomic_add_unchecked);
9470 EXPORT_SYMBOL(atomic_add_ret);
9471 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9472 EXPORT_SYMBOL(atomic_sub);
9473 +EXPORT_SYMBOL(atomic_sub_unchecked);
9474 EXPORT_SYMBOL(atomic_sub_ret);
9475 EXPORT_SYMBOL(atomic64_add);
9476 +EXPORT_SYMBOL(atomic64_add_unchecked);
9477 EXPORT_SYMBOL(atomic64_add_ret);
9478 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9479 EXPORT_SYMBOL(atomic64_sub);
9480 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9481 EXPORT_SYMBOL(atomic64_sub_ret);
9482 EXPORT_SYMBOL(atomic64_dec_if_positive);
9483
9484 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9485 index 30c3ecc..736f015 100644
9486 --- a/arch/sparc/mm/Makefile
9487 +++ b/arch/sparc/mm/Makefile
9488 @@ -2,7 +2,7 @@
9489 #
9490
9491 asflags-y := -ansi
9492 -ccflags-y := -Werror
9493 +#ccflags-y := -Werror
9494
9495 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9496 obj-y += fault_$(BITS).o
9497 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9498 index e98bfda..ea8d221 100644
9499 --- a/arch/sparc/mm/fault_32.c
9500 +++ b/arch/sparc/mm/fault_32.c
9501 @@ -21,6 +21,9 @@
9502 #include <linux/perf_event.h>
9503 #include <linux/interrupt.h>
9504 #include <linux/kdebug.h>
9505 +#include <linux/slab.h>
9506 +#include <linux/pagemap.h>
9507 +#include <linux/compiler.h>
9508
9509 #include <asm/page.h>
9510 #include <asm/pgtable.h>
9511 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9512 return safe_compute_effective_address(regs, insn);
9513 }
9514
9515 +#ifdef CONFIG_PAX_PAGEEXEC
9516 +#ifdef CONFIG_PAX_DLRESOLVE
9517 +static void pax_emuplt_close(struct vm_area_struct *vma)
9518 +{
9519 + vma->vm_mm->call_dl_resolve = 0UL;
9520 +}
9521 +
9522 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9523 +{
9524 + unsigned int *kaddr;
9525 +
9526 + vmf->page = alloc_page(GFP_HIGHUSER);
9527 + if (!vmf->page)
9528 + return VM_FAULT_OOM;
9529 +
9530 + kaddr = kmap(vmf->page);
9531 + memset(kaddr, 0, PAGE_SIZE);
9532 + kaddr[0] = 0x9DE3BFA8U; /* save */
9533 + flush_dcache_page(vmf->page);
9534 + kunmap(vmf->page);
9535 + return VM_FAULT_MAJOR;
9536 +}
9537 +
9538 +static const struct vm_operations_struct pax_vm_ops = {
9539 + .close = pax_emuplt_close,
9540 + .fault = pax_emuplt_fault
9541 +};
9542 +
9543 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9544 +{
9545 + int ret;
9546 +
9547 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9548 + vma->vm_mm = current->mm;
9549 + vma->vm_start = addr;
9550 + vma->vm_end = addr + PAGE_SIZE;
9551 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9552 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9553 + vma->vm_ops = &pax_vm_ops;
9554 +
9555 + ret = insert_vm_struct(current->mm, vma);
9556 + if (ret)
9557 + return ret;
9558 +
9559 + ++current->mm->total_vm;
9560 + return 0;
9561 +}
9562 +#endif
9563 +
9564 +/*
9565 + * PaX: decide what to do with offenders (regs->pc = fault address)
9566 + *
9567 + * returns 1 when task should be killed
9568 + * 2 when patched PLT trampoline was detected
9569 + * 3 when unpatched PLT trampoline was detected
9570 + */
9571 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9572 +{
9573 +
9574 +#ifdef CONFIG_PAX_EMUPLT
9575 + int err;
9576 +
9577 + do { /* PaX: patched PLT emulation #1 */
9578 + unsigned int sethi1, sethi2, jmpl;
9579 +
9580 + err = get_user(sethi1, (unsigned int *)regs->pc);
9581 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9582 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9583 +
9584 + if (err)
9585 + break;
9586 +
9587 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9588 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9589 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9590 + {
9591 + unsigned int addr;
9592 +
9593 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9594 + addr = regs->u_regs[UREG_G1];
9595 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9596 + regs->pc = addr;
9597 + regs->npc = addr+4;
9598 + return 2;
9599 + }
9600 + } while (0);
9601 +
9602 + do { /* PaX: patched PLT emulation #2 */
9603 + unsigned int ba;
9604 +
9605 + err = get_user(ba, (unsigned int *)regs->pc);
9606 +
9607 + if (err)
9608 + break;
9609 +
9610 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9611 + unsigned int addr;
9612 +
9613 + if ((ba & 0xFFC00000U) == 0x30800000U)
9614 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9615 + else
9616 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9617 + regs->pc = addr;
9618 + regs->npc = addr+4;
9619 + return 2;
9620 + }
9621 + } while (0);
9622 +
9623 + do { /* PaX: patched PLT emulation #3 */
9624 + unsigned int sethi, bajmpl, nop;
9625 +
9626 + err = get_user(sethi, (unsigned int *)regs->pc);
9627 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9628 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9629 +
9630 + if (err)
9631 + break;
9632 +
9633 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9634 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9635 + nop == 0x01000000U)
9636 + {
9637 + unsigned int addr;
9638 +
9639 + addr = (sethi & 0x003FFFFFU) << 10;
9640 + regs->u_regs[UREG_G1] = addr;
9641 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9642 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9643 + else
9644 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9645 + regs->pc = addr;
9646 + regs->npc = addr+4;
9647 + return 2;
9648 + }
9649 + } while (0);
9650 +
9651 + do { /* PaX: unpatched PLT emulation step 1 */
9652 + unsigned int sethi, ba, nop;
9653 +
9654 + err = get_user(sethi, (unsigned int *)regs->pc);
9655 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9656 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9657 +
9658 + if (err)
9659 + break;
9660 +
9661 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9662 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9663 + nop == 0x01000000U)
9664 + {
9665 + unsigned int addr, save, call;
9666 +
9667 + if ((ba & 0xFFC00000U) == 0x30800000U)
9668 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9669 + else
9670 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9671 +
9672 + err = get_user(save, (unsigned int *)addr);
9673 + err |= get_user(call, (unsigned int *)(addr+4));
9674 + err |= get_user(nop, (unsigned int *)(addr+8));
9675 + if (err)
9676 + break;
9677 +
9678 +#ifdef CONFIG_PAX_DLRESOLVE
9679 + if (save == 0x9DE3BFA8U &&
9680 + (call & 0xC0000000U) == 0x40000000U &&
9681 + nop == 0x01000000U)
9682 + {
9683 + struct vm_area_struct *vma;
9684 + unsigned long call_dl_resolve;
9685 +
9686 + down_read(&current->mm->mmap_sem);
9687 + call_dl_resolve = current->mm->call_dl_resolve;
9688 + up_read(&current->mm->mmap_sem);
9689 + if (likely(call_dl_resolve))
9690 + goto emulate;
9691 +
9692 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9693 +
9694 + down_write(&current->mm->mmap_sem);
9695 + if (current->mm->call_dl_resolve) {
9696 + call_dl_resolve = current->mm->call_dl_resolve;
9697 + up_write(&current->mm->mmap_sem);
9698 + if (vma)
9699 + kmem_cache_free(vm_area_cachep, vma);
9700 + goto emulate;
9701 + }
9702 +
9703 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9704 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9705 + up_write(&current->mm->mmap_sem);
9706 + if (vma)
9707 + kmem_cache_free(vm_area_cachep, vma);
9708 + return 1;
9709 + }
9710 +
9711 + if (pax_insert_vma(vma, call_dl_resolve)) {
9712 + up_write(&current->mm->mmap_sem);
9713 + kmem_cache_free(vm_area_cachep, vma);
9714 + return 1;
9715 + }
9716 +
9717 + current->mm->call_dl_resolve = call_dl_resolve;
9718 + up_write(&current->mm->mmap_sem);
9719 +
9720 +emulate:
9721 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9722 + regs->pc = call_dl_resolve;
9723 + regs->npc = addr+4;
9724 + return 3;
9725 + }
9726 +#endif
9727 +
9728 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9729 + if ((save & 0xFFC00000U) == 0x05000000U &&
9730 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9731 + nop == 0x01000000U)
9732 + {
9733 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9734 + regs->u_regs[UREG_G2] = addr + 4;
9735 + addr = (save & 0x003FFFFFU) << 10;
9736 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9737 + regs->pc = addr;
9738 + regs->npc = addr+4;
9739 + return 3;
9740 + }
9741 + }
9742 + } while (0);
9743 +
9744 + do { /* PaX: unpatched PLT emulation step 2 */
9745 + unsigned int save, call, nop;
9746 +
9747 + err = get_user(save, (unsigned int *)(regs->pc-4));
9748 + err |= get_user(call, (unsigned int *)regs->pc);
9749 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9750 + if (err)
9751 + break;
9752 +
9753 + if (save == 0x9DE3BFA8U &&
9754 + (call & 0xC0000000U) == 0x40000000U &&
9755 + nop == 0x01000000U)
9756 + {
9757 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9758 +
9759 + regs->u_regs[UREG_RETPC] = regs->pc;
9760 + regs->pc = dl_resolve;
9761 + regs->npc = dl_resolve+4;
9762 + return 3;
9763 + }
9764 + } while (0);
9765 +#endif
9766 +
9767 + return 1;
9768 +}
9769 +
9770 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9771 +{
9772 + unsigned long i;
9773 +
9774 + printk(KERN_ERR "PAX: bytes at PC: ");
9775 + for (i = 0; i < 8; i++) {
9776 + unsigned int c;
9777 + if (get_user(c, (unsigned int *)pc+i))
9778 + printk(KERN_CONT "???????? ");
9779 + else
9780 + printk(KERN_CONT "%08x ", c);
9781 + }
9782 + printk("\n");
9783 +}
9784 +#endif
9785 +
9786 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9787 int text_fault)
9788 {
9789 @@ -230,6 +504,24 @@ good_area:
9790 if (!(vma->vm_flags & VM_WRITE))
9791 goto bad_area;
9792 } else {
9793 +
9794 +#ifdef CONFIG_PAX_PAGEEXEC
9795 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9796 + up_read(&mm->mmap_sem);
9797 + switch (pax_handle_fetch_fault(regs)) {
9798 +
9799 +#ifdef CONFIG_PAX_EMUPLT
9800 + case 2:
9801 + case 3:
9802 + return;
9803 +#endif
9804 +
9805 + }
9806 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9807 + do_group_exit(SIGKILL);
9808 + }
9809 +#endif
9810 +
9811 /* Allow reads even for write-only mappings */
9812 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9813 goto bad_area;
9814 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9815 index 5062ff3..e0b75f3 100644
9816 --- a/arch/sparc/mm/fault_64.c
9817 +++ b/arch/sparc/mm/fault_64.c
9818 @@ -21,6 +21,9 @@
9819 #include <linux/kprobes.h>
9820 #include <linux/kdebug.h>
9821 #include <linux/percpu.h>
9822 +#include <linux/slab.h>
9823 +#include <linux/pagemap.h>
9824 +#include <linux/compiler.h>
9825
9826 #include <asm/page.h>
9827 #include <asm/pgtable.h>
9828 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9829 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9830 regs->tpc);
9831 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9832 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9833 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9834 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9835 dump_stack();
9836 unhandled_fault(regs->tpc, current, regs);
9837 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9838 show_regs(regs);
9839 }
9840
9841 +#ifdef CONFIG_PAX_PAGEEXEC
9842 +#ifdef CONFIG_PAX_DLRESOLVE
9843 +static void pax_emuplt_close(struct vm_area_struct *vma)
9844 +{
9845 + vma->vm_mm->call_dl_resolve = 0UL;
9846 +}
9847 +
9848 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9849 +{
9850 + unsigned int *kaddr;
9851 +
9852 + vmf->page = alloc_page(GFP_HIGHUSER);
9853 + if (!vmf->page)
9854 + return VM_FAULT_OOM;
9855 +
9856 + kaddr = kmap(vmf->page);
9857 + memset(kaddr, 0, PAGE_SIZE);
9858 + kaddr[0] = 0x9DE3BFA8U; /* save */
9859 + flush_dcache_page(vmf->page);
9860 + kunmap(vmf->page);
9861 + return VM_FAULT_MAJOR;
9862 +}
9863 +
9864 +static const struct vm_operations_struct pax_vm_ops = {
9865 + .close = pax_emuplt_close,
9866 + .fault = pax_emuplt_fault
9867 +};
9868 +
9869 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9870 +{
9871 + int ret;
9872 +
9873 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9874 + vma->vm_mm = current->mm;
9875 + vma->vm_start = addr;
9876 + vma->vm_end = addr + PAGE_SIZE;
9877 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9878 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9879 + vma->vm_ops = &pax_vm_ops;
9880 +
9881 + ret = insert_vm_struct(current->mm, vma);
9882 + if (ret)
9883 + return ret;
9884 +
9885 + ++current->mm->total_vm;
9886 + return 0;
9887 +}
9888 +#endif
9889 +
9890 +/*
9891 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9892 + *
9893 + * returns 1 when task should be killed
9894 + * 2 when patched PLT trampoline was detected
9895 + * 3 when unpatched PLT trampoline was detected
9896 + */
9897 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9898 +{
9899 +
9900 +#ifdef CONFIG_PAX_EMUPLT
9901 + int err;
9902 +
9903 + do { /* PaX: patched PLT emulation #1 */
9904 + unsigned int sethi1, sethi2, jmpl;
9905 +
9906 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9907 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9908 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9909 +
9910 + if (err)
9911 + break;
9912 +
9913 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9914 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9915 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9916 + {
9917 + unsigned long addr;
9918 +
9919 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9920 + addr = regs->u_regs[UREG_G1];
9921 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9922 +
9923 + if (test_thread_flag(TIF_32BIT))
9924 + addr &= 0xFFFFFFFFUL;
9925 +
9926 + regs->tpc = addr;
9927 + regs->tnpc = addr+4;
9928 + return 2;
9929 + }
9930 + } while (0);
9931 +
9932 + do { /* PaX: patched PLT emulation #2 */
9933 + unsigned int ba;
9934 +
9935 + err = get_user(ba, (unsigned int *)regs->tpc);
9936 +
9937 + if (err)
9938 + break;
9939 +
9940 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9941 + unsigned long addr;
9942 +
9943 + if ((ba & 0xFFC00000U) == 0x30800000U)
9944 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9945 + else
9946 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9947 +
9948 + if (test_thread_flag(TIF_32BIT))
9949 + addr &= 0xFFFFFFFFUL;
9950 +
9951 + regs->tpc = addr;
9952 + regs->tnpc = addr+4;
9953 + return 2;
9954 + }
9955 + } while (0);
9956 +
9957 + do { /* PaX: patched PLT emulation #3 */
9958 + unsigned int sethi, bajmpl, nop;
9959 +
9960 + err = get_user(sethi, (unsigned int *)regs->tpc);
9961 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9962 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9963 +
9964 + if (err)
9965 + break;
9966 +
9967 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9968 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9969 + nop == 0x01000000U)
9970 + {
9971 + unsigned long addr;
9972 +
9973 + addr = (sethi & 0x003FFFFFU) << 10;
9974 + regs->u_regs[UREG_G1] = addr;
9975 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9976 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9977 + else
9978 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9979 +
9980 + if (test_thread_flag(TIF_32BIT))
9981 + addr &= 0xFFFFFFFFUL;
9982 +
9983 + regs->tpc = addr;
9984 + regs->tnpc = addr+4;
9985 + return 2;
9986 + }
9987 + } while (0);
9988 +
9989 + do { /* PaX: patched PLT emulation #4 */
9990 + unsigned int sethi, mov1, call, mov2;
9991 +
9992 + err = get_user(sethi, (unsigned int *)regs->tpc);
9993 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9994 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9995 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9996 +
9997 + if (err)
9998 + break;
9999 +
10000 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10001 + mov1 == 0x8210000FU &&
10002 + (call & 0xC0000000U) == 0x40000000U &&
10003 + mov2 == 0x9E100001U)
10004 + {
10005 + unsigned long addr;
10006 +
10007 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10008 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10009 +
10010 + if (test_thread_flag(TIF_32BIT))
10011 + addr &= 0xFFFFFFFFUL;
10012 +
10013 + regs->tpc = addr;
10014 + regs->tnpc = addr+4;
10015 + return 2;
10016 + }
10017 + } while (0);
10018 +
10019 + do { /* PaX: patched PLT emulation #5 */
10020 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10021 +
10022 + err = get_user(sethi, (unsigned int *)regs->tpc);
10023 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10024 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10025 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10026 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10027 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10028 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10029 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10030 +
10031 + if (err)
10032 + break;
10033 +
10034 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10035 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10036 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10037 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10038 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10039 + sllx == 0x83287020U &&
10040 + jmpl == 0x81C04005U &&
10041 + nop == 0x01000000U)
10042 + {
10043 + unsigned long addr;
10044 +
10045 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10046 + regs->u_regs[UREG_G1] <<= 32;
10047 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10048 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10049 + regs->tpc = addr;
10050 + regs->tnpc = addr+4;
10051 + return 2;
10052 + }
10053 + } while (0);
10054 +
10055 + do { /* PaX: patched PLT emulation #6 */
10056 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10057 +
10058 + err = get_user(sethi, (unsigned int *)regs->tpc);
10059 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10060 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10061 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10062 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10063 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10064 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10065 +
10066 + if (err)
10067 + break;
10068 +
10069 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10070 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10071 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10072 + sllx == 0x83287020U &&
10073 + (or & 0xFFFFE000U) == 0x8A116000U &&
10074 + jmpl == 0x81C04005U &&
10075 + nop == 0x01000000U)
10076 + {
10077 + unsigned long addr;
10078 +
10079 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10080 + regs->u_regs[UREG_G1] <<= 32;
10081 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10082 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10083 + regs->tpc = addr;
10084 + regs->tnpc = addr+4;
10085 + return 2;
10086 + }
10087 + } while (0);
10088 +
10089 + do { /* PaX: unpatched PLT emulation step 1 */
10090 + unsigned int sethi, ba, nop;
10091 +
10092 + err = get_user(sethi, (unsigned int *)regs->tpc);
10093 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10094 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10095 +
10096 + if (err)
10097 + break;
10098 +
10099 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10100 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10101 + nop == 0x01000000U)
10102 + {
10103 + unsigned long addr;
10104 + unsigned int save, call;
10105 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10106 +
10107 + if ((ba & 0xFFC00000U) == 0x30800000U)
10108 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10109 + else
10110 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10111 +
10112 + if (test_thread_flag(TIF_32BIT))
10113 + addr &= 0xFFFFFFFFUL;
10114 +
10115 + err = get_user(save, (unsigned int *)addr);
10116 + err |= get_user(call, (unsigned int *)(addr+4));
10117 + err |= get_user(nop, (unsigned int *)(addr+8));
10118 + if (err)
10119 + break;
10120 +
10121 +#ifdef CONFIG_PAX_DLRESOLVE
10122 + if (save == 0x9DE3BFA8U &&
10123 + (call & 0xC0000000U) == 0x40000000U &&
10124 + nop == 0x01000000U)
10125 + {
10126 + struct vm_area_struct *vma;
10127 + unsigned long call_dl_resolve;
10128 +
10129 + down_read(&current->mm->mmap_sem);
10130 + call_dl_resolve = current->mm->call_dl_resolve;
10131 + up_read(&current->mm->mmap_sem);
10132 + if (likely(call_dl_resolve))
10133 + goto emulate;
10134 +
10135 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10136 +
10137 + down_write(&current->mm->mmap_sem);
10138 + if (current->mm->call_dl_resolve) {
10139 + call_dl_resolve = current->mm->call_dl_resolve;
10140 + up_write(&current->mm->mmap_sem);
10141 + if (vma)
10142 + kmem_cache_free(vm_area_cachep, vma);
10143 + goto emulate;
10144 + }
10145 +
10146 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10147 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10148 + up_write(&current->mm->mmap_sem);
10149 + if (vma)
10150 + kmem_cache_free(vm_area_cachep, vma);
10151 + return 1;
10152 + }
10153 +
10154 + if (pax_insert_vma(vma, call_dl_resolve)) {
10155 + up_write(&current->mm->mmap_sem);
10156 + kmem_cache_free(vm_area_cachep, vma);
10157 + return 1;
10158 + }
10159 +
10160 + current->mm->call_dl_resolve = call_dl_resolve;
10161 + up_write(&current->mm->mmap_sem);
10162 +
10163 +emulate:
10164 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10165 + regs->tpc = call_dl_resolve;
10166 + regs->tnpc = addr+4;
10167 + return 3;
10168 + }
10169 +#endif
10170 +
10171 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10172 + if ((save & 0xFFC00000U) == 0x05000000U &&
10173 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10174 + nop == 0x01000000U)
10175 + {
10176 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10177 + regs->u_regs[UREG_G2] = addr + 4;
10178 + addr = (save & 0x003FFFFFU) << 10;
10179 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10180 +
10181 + if (test_thread_flag(TIF_32BIT))
10182 + addr &= 0xFFFFFFFFUL;
10183 +
10184 + regs->tpc = addr;
10185 + regs->tnpc = addr+4;
10186 + return 3;
10187 + }
10188 +
10189 + /* PaX: 64-bit PLT stub */
10190 + err = get_user(sethi1, (unsigned int *)addr);
10191 + err |= get_user(sethi2, (unsigned int *)(addr+4));
10192 + err |= get_user(or1, (unsigned int *)(addr+8));
10193 + err |= get_user(or2, (unsigned int *)(addr+12));
10194 + err |= get_user(sllx, (unsigned int *)(addr+16));
10195 + err |= get_user(add, (unsigned int *)(addr+20));
10196 + err |= get_user(jmpl, (unsigned int *)(addr+24));
10197 + err |= get_user(nop, (unsigned int *)(addr+28));
10198 + if (err)
10199 + break;
10200 +
10201 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
10202 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10203 + (or1 & 0xFFFFE000U) == 0x88112000U &&
10204 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10205 + sllx == 0x89293020U &&
10206 + add == 0x8A010005U &&
10207 + jmpl == 0x89C14000U &&
10208 + nop == 0x01000000U)
10209 + {
10210 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10211 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10212 + regs->u_regs[UREG_G4] <<= 32;
10213 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10214 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
10215 + regs->u_regs[UREG_G4] = addr + 24;
10216 + addr = regs->u_regs[UREG_G5];
10217 + regs->tpc = addr;
10218 + regs->tnpc = addr+4;
10219 + return 3;
10220 + }
10221 + }
10222 + } while (0);
10223 +
10224 +#ifdef CONFIG_PAX_DLRESOLVE
10225 + do { /* PaX: unpatched PLT emulation step 2 */
10226 + unsigned int save, call, nop;
10227 +
10228 + err = get_user(save, (unsigned int *)(regs->tpc-4));
10229 + err |= get_user(call, (unsigned int *)regs->tpc);
10230 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
10231 + if (err)
10232 + break;
10233 +
10234 + if (save == 0x9DE3BFA8U &&
10235 + (call & 0xC0000000U) == 0x40000000U &&
10236 + nop == 0x01000000U)
10237 + {
10238 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10239 +
10240 + if (test_thread_flag(TIF_32BIT))
10241 + dl_resolve &= 0xFFFFFFFFUL;
10242 +
10243 + regs->u_regs[UREG_RETPC] = regs->tpc;
10244 + regs->tpc = dl_resolve;
10245 + regs->tnpc = dl_resolve+4;
10246 + return 3;
10247 + }
10248 + } while (0);
10249 +#endif
10250 +
10251 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
10252 + unsigned int sethi, ba, nop;
10253 +
10254 + err = get_user(sethi, (unsigned int *)regs->tpc);
10255 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10256 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10257 +
10258 + if (err)
10259 + break;
10260 +
10261 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10262 + (ba & 0xFFF00000U) == 0x30600000U &&
10263 + nop == 0x01000000U)
10264 + {
10265 + unsigned long addr;
10266 +
10267 + addr = (sethi & 0x003FFFFFU) << 10;
10268 + regs->u_regs[UREG_G1] = addr;
10269 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10270 +
10271 + if (test_thread_flag(TIF_32BIT))
10272 + addr &= 0xFFFFFFFFUL;
10273 +
10274 + regs->tpc = addr;
10275 + regs->tnpc = addr+4;
10276 + return 2;
10277 + }
10278 + } while (0);
10279 +
10280 +#endif
10281 +
10282 + return 1;
10283 +}
10284 +
10285 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10286 +{
10287 + unsigned long i;
10288 +
10289 + printk(KERN_ERR "PAX: bytes at PC: ");
10290 + for (i = 0; i < 8; i++) {
10291 + unsigned int c;
10292 + if (get_user(c, (unsigned int *)pc+i))
10293 + printk(KERN_CONT "???????? ");
10294 + else
10295 + printk(KERN_CONT "%08x ", c);
10296 + }
10297 + printk("\n");
10298 +}
10299 +#endif
10300 +
10301 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
10302 {
10303 struct mm_struct *mm = current->mm;
10304 @@ -341,6 +804,29 @@ retry:
10305 if (!vma)
10306 goto bad_area;
10307
10308 +#ifdef CONFIG_PAX_PAGEEXEC
10309 + /* PaX: detect ITLB misses on non-exec pages */
10310 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
10311 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
10312 + {
10313 + if (address != regs->tpc)
10314 + goto good_area;
10315 +
10316 + up_read(&mm->mmap_sem);
10317 + switch (pax_handle_fetch_fault(regs)) {
10318 +
10319 +#ifdef CONFIG_PAX_EMUPLT
10320 + case 2:
10321 + case 3:
10322 + return;
10323 +#endif
10324 +
10325 + }
10326 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
10327 + do_group_exit(SIGKILL);
10328 + }
10329 +#endif
10330 +
10331 /* Pure DTLB misses do not tell us whether the fault causing
10332 * load/store/atomic was a write or not, it only says that there
10333 * was no match. So in such a case we (carefully) read the
10334 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10335 index d2b5944..d878f3c 100644
10336 --- a/arch/sparc/mm/hugetlbpage.c
10337 +++ b/arch/sparc/mm/hugetlbpage.c
10338 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10339 unsigned long addr,
10340 unsigned long len,
10341 unsigned long pgoff,
10342 - unsigned long flags)
10343 + unsigned long flags,
10344 + unsigned long offset)
10345 {
10346 unsigned long task_size = TASK_SIZE;
10347 struct vm_unmapped_area_info info;
10348 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10349
10350 info.flags = 0;
10351 info.length = len;
10352 - info.low_limit = TASK_UNMAPPED_BASE;
10353 + info.low_limit = mm->mmap_base;
10354 info.high_limit = min(task_size, VA_EXCLUDE_START);
10355 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10356 info.align_offset = 0;
10357 + info.threadstack_offset = offset;
10358 addr = vm_unmapped_area(&info);
10359
10360 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10361 VM_BUG_ON(addr != -ENOMEM);
10362 info.low_limit = VA_EXCLUDE_END;
10363 +
10364 +#ifdef CONFIG_PAX_RANDMMAP
10365 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10366 + info.low_limit += mm->delta_mmap;
10367 +#endif
10368 +
10369 info.high_limit = task_size;
10370 addr = vm_unmapped_area(&info);
10371 }
10372 @@ -58,7 +66,8 @@ static unsigned long
10373 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10374 const unsigned long len,
10375 const unsigned long pgoff,
10376 - const unsigned long flags)
10377 + const unsigned long flags,
10378 + const unsigned long offset)
10379 {
10380 struct mm_struct *mm = current->mm;
10381 unsigned long addr = addr0;
10382 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10383 info.high_limit = mm->mmap_base;
10384 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10385 info.align_offset = 0;
10386 + info.threadstack_offset = offset;
10387 addr = vm_unmapped_area(&info);
10388
10389 /*
10390 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10391 VM_BUG_ON(addr != -ENOMEM);
10392 info.flags = 0;
10393 info.low_limit = TASK_UNMAPPED_BASE;
10394 +
10395 +#ifdef CONFIG_PAX_RANDMMAP
10396 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10397 + info.low_limit += mm->delta_mmap;
10398 +#endif
10399 +
10400 info.high_limit = STACK_TOP32;
10401 addr = vm_unmapped_area(&info);
10402 }
10403 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10404 struct mm_struct *mm = current->mm;
10405 struct vm_area_struct *vma;
10406 unsigned long task_size = TASK_SIZE;
10407 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10408
10409 if (test_thread_flag(TIF_32BIT))
10410 task_size = STACK_TOP32;
10411 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10412 return addr;
10413 }
10414
10415 +#ifdef CONFIG_PAX_RANDMMAP
10416 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10417 +#endif
10418 +
10419 if (addr) {
10420 addr = ALIGN(addr, HPAGE_SIZE);
10421 vma = find_vma(mm, addr);
10422 - if (task_size - len >= addr &&
10423 - (!vma || addr + len <= vma->vm_start))
10424 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10425 return addr;
10426 }
10427 if (mm->get_unmapped_area == arch_get_unmapped_area)
10428 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
10429 - pgoff, flags);
10430 + pgoff, flags, offset);
10431 else
10432 return hugetlb_get_unmapped_area_topdown(file, addr, len,
10433 - pgoff, flags);
10434 + pgoff, flags, offset);
10435 }
10436
10437 pte_t *huge_pte_alloc(struct mm_struct *mm,
10438 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10439 index f4500c6..889656c 100644
10440 --- a/arch/tile/include/asm/atomic_64.h
10441 +++ b/arch/tile/include/asm/atomic_64.h
10442 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10443
10444 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10445
10446 +#define atomic64_read_unchecked(v) atomic64_read(v)
10447 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10448 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10449 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10450 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10451 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10452 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10453 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10454 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10455 +
10456 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10457 #define smp_mb__before_atomic_dec() smp_mb()
10458 #define smp_mb__after_atomic_dec() smp_mb()
10459 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10460 index a9a5299..0fce79e 100644
10461 --- a/arch/tile/include/asm/cache.h
10462 +++ b/arch/tile/include/asm/cache.h
10463 @@ -15,11 +15,12 @@
10464 #ifndef _ASM_TILE_CACHE_H
10465 #define _ASM_TILE_CACHE_H
10466
10467 +#include <linux/const.h>
10468 #include <arch/chip.h>
10469
10470 /* bytes per L1 data cache line */
10471 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10472 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10473 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10474
10475 /* bytes per L2 cache line */
10476 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10477 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10478 index 8a082bc..7a6bf87 100644
10479 --- a/arch/tile/include/asm/uaccess.h
10480 +++ b/arch/tile/include/asm/uaccess.h
10481 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10482 const void __user *from,
10483 unsigned long n)
10484 {
10485 - int sz = __compiletime_object_size(to);
10486 + size_t sz = __compiletime_object_size(to);
10487
10488 - if (likely(sz == -1 || sz >= n))
10489 + if (likely(sz == (size_t)-1 || sz >= n))
10490 n = _copy_from_user(to, from, n);
10491 else
10492 copy_from_user_overflow();
10493 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10494 index 650ccff..45fe2d6 100644
10495 --- a/arch/tile/mm/hugetlbpage.c
10496 +++ b/arch/tile/mm/hugetlbpage.c
10497 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10498 info.high_limit = TASK_SIZE;
10499 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10500 info.align_offset = 0;
10501 + info.threadstack_offset = 0;
10502 return vm_unmapped_area(&info);
10503 }
10504
10505 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10506 info.high_limit = current->mm->mmap_base;
10507 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10508 info.align_offset = 0;
10509 + info.threadstack_offset = 0;
10510 addr = vm_unmapped_area(&info);
10511
10512 /*
10513 diff --git a/arch/um/Makefile b/arch/um/Makefile
10514 index 133f7de..1d6f2f1 100644
10515 --- a/arch/um/Makefile
10516 +++ b/arch/um/Makefile
10517 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10518 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10519 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10520
10521 +ifdef CONSTIFY_PLUGIN
10522 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10523 +endif
10524 +
10525 #This will adjust *FLAGS accordingly to the platform.
10526 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10527
10528 diff --git a/arch/um/defconfig b/arch/um/defconfig
10529 index 08107a7..ab22afe 100644
10530 --- a/arch/um/defconfig
10531 +++ b/arch/um/defconfig
10532 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10533 CONFIG_X86_L1_CACHE_SHIFT=5
10534 CONFIG_X86_XADD=y
10535 CONFIG_X86_PPRO_FENCE=y
10536 -CONFIG_X86_WP_WORKS_OK=y
10537 CONFIG_X86_INVLPG=y
10538 CONFIG_X86_BSWAP=y
10539 CONFIG_X86_POPAD_OK=y
10540 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10541 index 19e1bdd..3665b77 100644
10542 --- a/arch/um/include/asm/cache.h
10543 +++ b/arch/um/include/asm/cache.h
10544 @@ -1,6 +1,7 @@
10545 #ifndef __UM_CACHE_H
10546 #define __UM_CACHE_H
10547
10548 +#include <linux/const.h>
10549
10550 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10551 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10552 @@ -12,6 +13,6 @@
10553 # define L1_CACHE_SHIFT 5
10554 #endif
10555
10556 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10557 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10558
10559 #endif
10560 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10561 index 2e0a6b1..a64d0f5 100644
10562 --- a/arch/um/include/asm/kmap_types.h
10563 +++ b/arch/um/include/asm/kmap_types.h
10564 @@ -8,6 +8,6 @@
10565
10566 /* No more #include "asm/arch/kmap_types.h" ! */
10567
10568 -#define KM_TYPE_NR 14
10569 +#define KM_TYPE_NR 15
10570
10571 #endif
10572 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10573 index 5ff53d9..5850cdf 100644
10574 --- a/arch/um/include/asm/page.h
10575 +++ b/arch/um/include/asm/page.h
10576 @@ -14,6 +14,9 @@
10577 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10578 #define PAGE_MASK (~(PAGE_SIZE-1))
10579
10580 +#define ktla_ktva(addr) (addr)
10581 +#define ktva_ktla(addr) (addr)
10582 +
10583 #ifndef __ASSEMBLY__
10584
10585 struct page;
10586 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10587 index 0032f92..cd151e0 100644
10588 --- a/arch/um/include/asm/pgtable-3level.h
10589 +++ b/arch/um/include/asm/pgtable-3level.h
10590 @@ -58,6 +58,7 @@
10591 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10592 #define pud_populate(mm, pud, pmd) \
10593 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10594 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10595
10596 #ifdef CONFIG_64BIT
10597 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10598 diff --git a/arch/um/include/asm/tlb.h b/arch/um/include/asm/tlb.h
10599 index 4febacd..29b0301 100644
10600 --- a/arch/um/include/asm/tlb.h
10601 +++ b/arch/um/include/asm/tlb.h
10602 @@ -45,10 +45,12 @@ static inline void init_tlb_gather(struct mmu_gather *tlb)
10603 }
10604
10605 static inline void
10606 -tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int full_mm_flush)
10607 +tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
10608 {
10609 tlb->mm = mm;
10610 - tlb->fullmm = full_mm_flush;
10611 + tlb->start = start;
10612 + tlb->end = end;
10613 + tlb->fullmm = !(start | (end+1));
10614
10615 init_tlb_gather(tlb);
10616 }
10617 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10618 index bbcef52..6a2a483 100644
10619 --- a/arch/um/kernel/process.c
10620 +++ b/arch/um/kernel/process.c
10621 @@ -367,22 +367,6 @@ int singlestepping(void * t)
10622 return 2;
10623 }
10624
10625 -/*
10626 - * Only x86 and x86_64 have an arch_align_stack().
10627 - * All other arches have "#define arch_align_stack(x) (x)"
10628 - * in their asm/system.h
10629 - * As this is included in UML from asm-um/system-generic.h,
10630 - * we can use it to behave as the subarch does.
10631 - */
10632 -#ifndef arch_align_stack
10633 -unsigned long arch_align_stack(unsigned long sp)
10634 -{
10635 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10636 - sp -= get_random_int() % 8192;
10637 - return sp & ~0xf;
10638 -}
10639 -#endif
10640 -
10641 unsigned long get_wchan(struct task_struct *p)
10642 {
10643 unsigned long stack_page, sp, ip;
10644 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10645 index ad8f795..2c7eec6 100644
10646 --- a/arch/unicore32/include/asm/cache.h
10647 +++ b/arch/unicore32/include/asm/cache.h
10648 @@ -12,8 +12,10 @@
10649 #ifndef __UNICORE_CACHE_H__
10650 #define __UNICORE_CACHE_H__
10651
10652 -#define L1_CACHE_SHIFT (5)
10653 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10654 +#include <linux/const.h>
10655 +
10656 +#define L1_CACHE_SHIFT 5
10657 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10658
10659 /*
10660 * Memory returned by kmalloc() may be used for DMA, so we must make
10661 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10662 index fe120da..24177f7 100644
10663 --- a/arch/x86/Kconfig
10664 +++ b/arch/x86/Kconfig
10665 @@ -239,7 +239,7 @@ config X86_HT
10666
10667 config X86_32_LAZY_GS
10668 def_bool y
10669 - depends on X86_32 && !CC_STACKPROTECTOR
10670 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10671
10672 config ARCH_HWEIGHT_CFLAGS
10673 string
10674 @@ -1073,6 +1073,7 @@ config MICROCODE_EARLY
10675
10676 config X86_MSR
10677 tristate "/dev/cpu/*/msr - Model-specific register support"
10678 + depends on !GRKERNSEC_KMEM
10679 ---help---
10680 This device gives privileged processes access to the x86
10681 Model-Specific Registers (MSRs). It is a character device with
10682 @@ -1096,7 +1097,7 @@ choice
10683
10684 config NOHIGHMEM
10685 bool "off"
10686 - depends on !X86_NUMAQ
10687 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10688 ---help---
10689 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10690 However, the address space of 32-bit x86 processors is only 4
10691 @@ -1133,7 +1134,7 @@ config NOHIGHMEM
10692
10693 config HIGHMEM4G
10694 bool "4GB"
10695 - depends on !X86_NUMAQ
10696 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10697 ---help---
10698 Select this if you have a 32-bit processor and between 1 and 4
10699 gigabytes of physical RAM.
10700 @@ -1186,7 +1187,7 @@ config PAGE_OFFSET
10701 hex
10702 default 0xB0000000 if VMSPLIT_3G_OPT
10703 default 0x80000000 if VMSPLIT_2G
10704 - default 0x78000000 if VMSPLIT_2G_OPT
10705 + default 0x70000000 if VMSPLIT_2G_OPT
10706 default 0x40000000 if VMSPLIT_1G
10707 default 0xC0000000
10708 depends on X86_32
10709 @@ -1584,6 +1585,7 @@ config SECCOMP
10710
10711 config CC_STACKPROTECTOR
10712 bool "Enable -fstack-protector buffer overflow detection"
10713 + depends on X86_64 || !PAX_MEMORY_UDEREF
10714 ---help---
10715 This option turns on the -fstack-protector GCC feature. This
10716 feature puts, at the beginning of functions, a canary value on
10717 @@ -1703,6 +1705,8 @@ config X86_NEED_RELOCS
10718 config PHYSICAL_ALIGN
10719 hex "Alignment value to which kernel should be aligned" if X86_32
10720 default "0x1000000"
10721 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10722 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10723 range 0x2000 0x1000000
10724 ---help---
10725 This value puts the alignment restrictions on physical address
10726 @@ -1778,9 +1782,10 @@ config DEBUG_HOTPLUG_CPU0
10727 If unsure, say N.
10728
10729 config COMPAT_VDSO
10730 - def_bool y
10731 + def_bool n
10732 prompt "Compat VDSO support"
10733 depends on X86_32 || IA32_EMULATION
10734 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10735 ---help---
10736 Map the 32-bit VDSO to the predictable old-style address too.
10737
10738 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10739 index c026cca..14657ae 100644
10740 --- a/arch/x86/Kconfig.cpu
10741 +++ b/arch/x86/Kconfig.cpu
10742 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10743
10744 config X86_F00F_BUG
10745 def_bool y
10746 - depends on M586MMX || M586TSC || M586 || M486
10747 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10748
10749 config X86_INVD_BUG
10750 def_bool y
10751 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10752
10753 config X86_ALIGNMENT_16
10754 def_bool y
10755 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10756 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10757
10758 config X86_INTEL_USERCOPY
10759 def_bool y
10760 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10761 # generates cmov.
10762 config X86_CMOV
10763 def_bool y
10764 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10765 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10766
10767 config X86_MINIMUM_CPU_FAMILY
10768 int
10769 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10770 index c198b7e..63eea60 100644
10771 --- a/arch/x86/Kconfig.debug
10772 +++ b/arch/x86/Kconfig.debug
10773 @@ -84,7 +84,7 @@ config X86_PTDUMP
10774 config DEBUG_RODATA
10775 bool "Write protect kernel read-only data structures"
10776 default y
10777 - depends on DEBUG_KERNEL
10778 + depends on DEBUG_KERNEL && BROKEN
10779 ---help---
10780 Mark the kernel read-only data as write-protected in the pagetables,
10781 in order to catch accidental (and incorrect) writes to such const
10782 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10783
10784 config DEBUG_SET_MODULE_RONX
10785 bool "Set loadable kernel module data as NX and text as RO"
10786 - depends on MODULES
10787 + depends on MODULES && BROKEN
10788 ---help---
10789 This option helps catch unintended modifications to loadable
10790 kernel module's text and read-only data. It also prevents execution
10791 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10792 index 5c47726..8c4fa67 100644
10793 --- a/arch/x86/Makefile
10794 +++ b/arch/x86/Makefile
10795 @@ -54,6 +54,7 @@ else
10796 UTS_MACHINE := x86_64
10797 CHECKFLAGS += -D__x86_64__ -m64
10798
10799 + biarch := $(call cc-option,-m64)
10800 KBUILD_AFLAGS += -m64
10801 KBUILD_CFLAGS += -m64
10802
10803 @@ -234,3 +235,12 @@ define archhelp
10804 echo ' FDARGS="..." arguments for the booted kernel'
10805 echo ' FDINITRD=file initrd for the booted kernel'
10806 endef
10807 +
10808 +define OLD_LD
10809 +
10810 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10811 +*** Please upgrade your binutils to 2.18 or newer
10812 +endef
10813 +
10814 +archprepare:
10815 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10816 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10817 index 379814b..add62ce 100644
10818 --- a/arch/x86/boot/Makefile
10819 +++ b/arch/x86/boot/Makefile
10820 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10821 $(call cc-option, -fno-stack-protector) \
10822 $(call cc-option, -mpreferred-stack-boundary=2)
10823 KBUILD_CFLAGS += $(call cc-option, -m32)
10824 +ifdef CONSTIFY_PLUGIN
10825 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10826 +endif
10827 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10828 GCOV_PROFILE := n
10829
10830 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10831 index 878e4b9..20537ab 100644
10832 --- a/arch/x86/boot/bitops.h
10833 +++ b/arch/x86/boot/bitops.h
10834 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10835 u8 v;
10836 const u32 *p = (const u32 *)addr;
10837
10838 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10839 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10840 return v;
10841 }
10842
10843 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10844
10845 static inline void set_bit(int nr, void *addr)
10846 {
10847 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10848 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10849 }
10850
10851 #endif /* BOOT_BITOPS_H */
10852 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10853 index 5b75319..331a4ca 100644
10854 --- a/arch/x86/boot/boot.h
10855 +++ b/arch/x86/boot/boot.h
10856 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10857 static inline u16 ds(void)
10858 {
10859 u16 seg;
10860 - asm("movw %%ds,%0" : "=rm" (seg));
10861 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10862 return seg;
10863 }
10864
10865 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10866 static inline int memcmp(const void *s1, const void *s2, size_t len)
10867 {
10868 u8 diff;
10869 - asm("repe; cmpsb; setnz %0"
10870 + asm volatile("repe; cmpsb; setnz %0"
10871 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10872 return diff;
10873 }
10874 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10875 index 5ef205c..342191d 100644
10876 --- a/arch/x86/boot/compressed/Makefile
10877 +++ b/arch/x86/boot/compressed/Makefile
10878 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10879 KBUILD_CFLAGS += $(cflags-y)
10880 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10881 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10882 +ifdef CONSTIFY_PLUGIN
10883 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10884 +endif
10885
10886 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10887 GCOV_PROFILE := n
10888 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10889 index d606463..b887794 100644
10890 --- a/arch/x86/boot/compressed/eboot.c
10891 +++ b/arch/x86/boot/compressed/eboot.c
10892 @@ -150,7 +150,6 @@ again:
10893 *addr = max_addr;
10894 }
10895
10896 -free_pool:
10897 efi_call_phys1(sys_table->boottime->free_pool, map);
10898
10899 fail:
10900 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10901 if (i == map_size / desc_size)
10902 status = EFI_NOT_FOUND;
10903
10904 -free_pool:
10905 efi_call_phys1(sys_table->boottime->free_pool, map);
10906 fail:
10907 return status;
10908 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
10909 index a53440e..c3dbf1e 100644
10910 --- a/arch/x86/boot/compressed/efi_stub_32.S
10911 +++ b/arch/x86/boot/compressed/efi_stub_32.S
10912 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
10913 * parameter 2, ..., param n. To make things easy, we save the return
10914 * address of efi_call_phys in a global variable.
10915 */
10916 - popl %ecx
10917 - movl %ecx, saved_return_addr(%edx)
10918 - /* get the function pointer into ECX*/
10919 - popl %ecx
10920 - movl %ecx, efi_rt_function_ptr(%edx)
10921 + popl saved_return_addr(%edx)
10922 + popl efi_rt_function_ptr(%edx)
10923
10924 /*
10925 * 3. Call the physical function.
10926 */
10927 - call *%ecx
10928 + call *efi_rt_function_ptr(%edx)
10929
10930 /*
10931 * 4. Balance the stack. And because EAX contain the return value,
10932 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
10933 1: popl %edx
10934 subl $1b, %edx
10935
10936 - movl efi_rt_function_ptr(%edx), %ecx
10937 - pushl %ecx
10938 + pushl efi_rt_function_ptr(%edx)
10939
10940 /*
10941 * 10. Push the saved return address onto the stack and return.
10942 */
10943 - movl saved_return_addr(%edx), %ecx
10944 - pushl %ecx
10945 - ret
10946 + jmpl *saved_return_addr(%edx)
10947 ENDPROC(efi_call_phys)
10948 .previous
10949
10950 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10951 index 1e3184f..0d11e2e 100644
10952 --- a/arch/x86/boot/compressed/head_32.S
10953 +++ b/arch/x86/boot/compressed/head_32.S
10954 @@ -118,7 +118,7 @@ preferred_addr:
10955 notl %eax
10956 andl %eax, %ebx
10957 #else
10958 - movl $LOAD_PHYSICAL_ADDR, %ebx
10959 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10960 #endif
10961
10962 /* Target address to relocate to for decompression */
10963 @@ -204,7 +204,7 @@ relocated:
10964 * and where it was actually loaded.
10965 */
10966 movl %ebp, %ebx
10967 - subl $LOAD_PHYSICAL_ADDR, %ebx
10968 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10969 jz 2f /* Nothing to be done if loaded at compiled addr. */
10970 /*
10971 * Process relocations.
10972 @@ -212,8 +212,7 @@ relocated:
10973
10974 1: subl $4, %edi
10975 movl (%edi), %ecx
10976 - testl %ecx, %ecx
10977 - jz 2f
10978 + jecxz 2f
10979 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10980 jmp 1b
10981 2:
10982 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10983 index 16f24e6..47491a3 100644
10984 --- a/arch/x86/boot/compressed/head_64.S
10985 +++ b/arch/x86/boot/compressed/head_64.S
10986 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10987 notl %eax
10988 andl %eax, %ebx
10989 #else
10990 - movl $LOAD_PHYSICAL_ADDR, %ebx
10991 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10992 #endif
10993
10994 /* Target address to relocate to for decompression */
10995 @@ -272,7 +272,7 @@ preferred_addr:
10996 notq %rax
10997 andq %rax, %rbp
10998 #else
10999 - movq $LOAD_PHYSICAL_ADDR, %rbp
11000 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11001 #endif
11002
11003 /* Target address to relocate to for decompression */
11004 @@ -363,8 +363,8 @@ gdt:
11005 .long gdt
11006 .word 0
11007 .quad 0x0000000000000000 /* NULL descriptor */
11008 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11009 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11010 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11011 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11012 .quad 0x0080890000000000 /* TS descriptor */
11013 .quad 0x0000000000000000 /* TS continued */
11014 gdt_end:
11015 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11016 index 7cb56c6..d382d84 100644
11017 --- a/arch/x86/boot/compressed/misc.c
11018 +++ b/arch/x86/boot/compressed/misc.c
11019 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
11020 case PT_LOAD:
11021 #ifdef CONFIG_RELOCATABLE
11022 dest = output;
11023 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11024 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11025 #else
11026 dest = (void *)(phdr->p_paddr);
11027 #endif
11028 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11029 error("Destination address too large");
11030 #endif
11031 #ifndef CONFIG_RELOCATABLE
11032 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11033 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11034 error("Wrong destination address");
11035 #endif
11036
11037 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11038 index 4d3ff03..e4972ff 100644
11039 --- a/arch/x86/boot/cpucheck.c
11040 +++ b/arch/x86/boot/cpucheck.c
11041 @@ -74,7 +74,7 @@ static int has_fpu(void)
11042 u16 fcw = -1, fsw = -1;
11043 u32 cr0;
11044
11045 - asm("movl %%cr0,%0" : "=r" (cr0));
11046 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11047 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11048 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11049 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11050 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11051 {
11052 u32 f0, f1;
11053
11054 - asm("pushfl ; "
11055 + asm volatile("pushfl ; "
11056 "pushfl ; "
11057 "popl %0 ; "
11058 "movl %0,%1 ; "
11059 @@ -115,7 +115,7 @@ static void get_flags(void)
11060 set_bit(X86_FEATURE_FPU, cpu.flags);
11061
11062 if (has_eflag(X86_EFLAGS_ID)) {
11063 - asm("cpuid"
11064 + asm volatile("cpuid"
11065 : "=a" (max_intel_level),
11066 "=b" (cpu_vendor[0]),
11067 "=d" (cpu_vendor[1]),
11068 @@ -124,7 +124,7 @@ static void get_flags(void)
11069
11070 if (max_intel_level >= 0x00000001 &&
11071 max_intel_level <= 0x0000ffff) {
11072 - asm("cpuid"
11073 + asm volatile("cpuid"
11074 : "=a" (tfms),
11075 "=c" (cpu.flags[4]),
11076 "=d" (cpu.flags[0])
11077 @@ -136,7 +136,7 @@ static void get_flags(void)
11078 cpu.model += ((tfms >> 16) & 0xf) << 4;
11079 }
11080
11081 - asm("cpuid"
11082 + asm volatile("cpuid"
11083 : "=a" (max_amd_level)
11084 : "a" (0x80000000)
11085 : "ebx", "ecx", "edx");
11086 @@ -144,7 +144,7 @@ static void get_flags(void)
11087 if (max_amd_level >= 0x80000001 &&
11088 max_amd_level <= 0x8000ffff) {
11089 u32 eax = 0x80000001;
11090 - asm("cpuid"
11091 + asm volatile("cpuid"
11092 : "+a" (eax),
11093 "=c" (cpu.flags[6]),
11094 "=d" (cpu.flags[1])
11095 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11096 u32 ecx = MSR_K7_HWCR;
11097 u32 eax, edx;
11098
11099 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11100 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11101 eax &= ~(1 << 15);
11102 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11103 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11104
11105 get_flags(); /* Make sure it really did something */
11106 err = check_flags();
11107 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11108 u32 ecx = MSR_VIA_FCR;
11109 u32 eax, edx;
11110
11111 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11112 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11113 eax |= (1<<1)|(1<<7);
11114 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11115 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11116
11117 set_bit(X86_FEATURE_CX8, cpu.flags);
11118 err = check_flags();
11119 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11120 u32 eax, edx;
11121 u32 level = 1;
11122
11123 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11124 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11125 - asm("cpuid"
11126 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11127 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11128 + asm volatile("cpuid"
11129 : "+a" (level), "=d" (cpu.flags[0])
11130 : : "ecx", "ebx");
11131 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11132 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11133
11134 err = check_flags();
11135 }
11136 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
11137 index 9ec06a1..2c25e79 100644
11138 --- a/arch/x86/boot/header.S
11139 +++ b/arch/x86/boot/header.S
11140 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
11141 # single linked list of
11142 # struct setup_data
11143
11144 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
11145 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
11146
11147 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
11148 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
11149 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
11150 +#else
11151 #define VO_INIT_SIZE (VO__end - VO__text)
11152 +#endif
11153 #if ZO_INIT_SIZE > VO_INIT_SIZE
11154 #define INIT_SIZE ZO_INIT_SIZE
11155 #else
11156 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
11157 index db75d07..8e6d0af 100644
11158 --- a/arch/x86/boot/memory.c
11159 +++ b/arch/x86/boot/memory.c
11160 @@ -19,7 +19,7 @@
11161
11162 static int detect_memory_e820(void)
11163 {
11164 - int count = 0;
11165 + unsigned int count = 0;
11166 struct biosregs ireg, oreg;
11167 struct e820entry *desc = boot_params.e820_map;
11168 static struct e820entry buf; /* static so it is zeroed */
11169 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
11170 index 11e8c6e..fdbb1ed 100644
11171 --- a/arch/x86/boot/video-vesa.c
11172 +++ b/arch/x86/boot/video-vesa.c
11173 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
11174
11175 boot_params.screen_info.vesapm_seg = oreg.es;
11176 boot_params.screen_info.vesapm_off = oreg.di;
11177 + boot_params.screen_info.vesapm_size = oreg.cx;
11178 }
11179
11180 /*
11181 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
11182 index 43eda28..5ab5fdb 100644
11183 --- a/arch/x86/boot/video.c
11184 +++ b/arch/x86/boot/video.c
11185 @@ -96,7 +96,7 @@ static void store_mode_params(void)
11186 static unsigned int get_entry(void)
11187 {
11188 char entry_buf[4];
11189 - int i, len = 0;
11190 + unsigned int i, len = 0;
11191 int key;
11192 unsigned int v;
11193
11194 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
11195 index 9105655..5e37f27 100644
11196 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
11197 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
11198 @@ -8,6 +8,8 @@
11199 * including this sentence is retained in full.
11200 */
11201
11202 +#include <asm/alternative-asm.h>
11203 +
11204 .extern crypto_ft_tab
11205 .extern crypto_it_tab
11206 .extern crypto_fl_tab
11207 @@ -70,6 +72,8 @@
11208 je B192; \
11209 leaq 32(r9),r9;
11210
11211 +#define ret pax_force_retaddr 0, 1; ret
11212 +
11213 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
11214 movq r1,r2; \
11215 movq r3,r4; \
11216 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
11217 index 477e9d7..3ab339f 100644
11218 --- a/arch/x86/crypto/aesni-intel_asm.S
11219 +++ b/arch/x86/crypto/aesni-intel_asm.S
11220 @@ -31,6 +31,7 @@
11221
11222 #include <linux/linkage.h>
11223 #include <asm/inst.h>
11224 +#include <asm/alternative-asm.h>
11225
11226 #ifdef __x86_64__
11227 .data
11228 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
11229 pop %r14
11230 pop %r13
11231 pop %r12
11232 + pax_force_retaddr 0, 1
11233 ret
11234 ENDPROC(aesni_gcm_dec)
11235
11236 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
11237 pop %r14
11238 pop %r13
11239 pop %r12
11240 + pax_force_retaddr 0, 1
11241 ret
11242 ENDPROC(aesni_gcm_enc)
11243
11244 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
11245 pxor %xmm1, %xmm0
11246 movaps %xmm0, (TKEYP)
11247 add $0x10, TKEYP
11248 + pax_force_retaddr_bts
11249 ret
11250 ENDPROC(_key_expansion_128)
11251 ENDPROC(_key_expansion_256a)
11252 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
11253 shufps $0b01001110, %xmm2, %xmm1
11254 movaps %xmm1, 0x10(TKEYP)
11255 add $0x20, TKEYP
11256 + pax_force_retaddr_bts
11257 ret
11258 ENDPROC(_key_expansion_192a)
11259
11260 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
11261
11262 movaps %xmm0, (TKEYP)
11263 add $0x10, TKEYP
11264 + pax_force_retaddr_bts
11265 ret
11266 ENDPROC(_key_expansion_192b)
11267
11268 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
11269 pxor %xmm1, %xmm2
11270 movaps %xmm2, (TKEYP)
11271 add $0x10, TKEYP
11272 + pax_force_retaddr_bts
11273 ret
11274 ENDPROC(_key_expansion_256b)
11275
11276 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
11277 #ifndef __x86_64__
11278 popl KEYP
11279 #endif
11280 + pax_force_retaddr 0, 1
11281 ret
11282 ENDPROC(aesni_set_key)
11283
11284 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
11285 popl KLEN
11286 popl KEYP
11287 #endif
11288 + pax_force_retaddr 0, 1
11289 ret
11290 ENDPROC(aesni_enc)
11291
11292 @@ -1974,6 +1983,7 @@ _aesni_enc1:
11293 AESENC KEY STATE
11294 movaps 0x70(TKEYP), KEY
11295 AESENCLAST KEY STATE
11296 + pax_force_retaddr_bts
11297 ret
11298 ENDPROC(_aesni_enc1)
11299
11300 @@ -2083,6 +2093,7 @@ _aesni_enc4:
11301 AESENCLAST KEY STATE2
11302 AESENCLAST KEY STATE3
11303 AESENCLAST KEY STATE4
11304 + pax_force_retaddr_bts
11305 ret
11306 ENDPROC(_aesni_enc4)
11307
11308 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
11309 popl KLEN
11310 popl KEYP
11311 #endif
11312 + pax_force_retaddr 0, 1
11313 ret
11314 ENDPROC(aesni_dec)
11315
11316 @@ -2164,6 +2176,7 @@ _aesni_dec1:
11317 AESDEC KEY STATE
11318 movaps 0x70(TKEYP), KEY
11319 AESDECLAST KEY STATE
11320 + pax_force_retaddr_bts
11321 ret
11322 ENDPROC(_aesni_dec1)
11323
11324 @@ -2273,6 +2286,7 @@ _aesni_dec4:
11325 AESDECLAST KEY STATE2
11326 AESDECLAST KEY STATE3
11327 AESDECLAST KEY STATE4
11328 + pax_force_retaddr_bts
11329 ret
11330 ENDPROC(_aesni_dec4)
11331
11332 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
11333 popl KEYP
11334 popl LEN
11335 #endif
11336 + pax_force_retaddr 0, 1
11337 ret
11338 ENDPROC(aesni_ecb_enc)
11339
11340 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
11341 popl KEYP
11342 popl LEN
11343 #endif
11344 + pax_force_retaddr 0, 1
11345 ret
11346 ENDPROC(aesni_ecb_dec)
11347
11348 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
11349 popl LEN
11350 popl IVP
11351 #endif
11352 + pax_force_retaddr 0, 1
11353 ret
11354 ENDPROC(aesni_cbc_enc)
11355
11356 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
11357 popl LEN
11358 popl IVP
11359 #endif
11360 + pax_force_retaddr 0, 1
11361 ret
11362 ENDPROC(aesni_cbc_dec)
11363
11364 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
11365 mov $1, TCTR_LOW
11366 MOVQ_R64_XMM TCTR_LOW INC
11367 MOVQ_R64_XMM CTR TCTR_LOW
11368 + pax_force_retaddr_bts
11369 ret
11370 ENDPROC(_aesni_inc_init)
11371
11372 @@ -2579,6 +2598,7 @@ _aesni_inc:
11373 .Linc_low:
11374 movaps CTR, IV
11375 PSHUFB_XMM BSWAP_MASK IV
11376 + pax_force_retaddr_bts
11377 ret
11378 ENDPROC(_aesni_inc)
11379
11380 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
11381 .Lctr_enc_ret:
11382 movups IV, (IVP)
11383 .Lctr_enc_just_ret:
11384 + pax_force_retaddr 0, 1
11385 ret
11386 ENDPROC(aesni_ctr_enc)
11387
11388 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
11389 pxor INC, STATE4
11390 movdqu STATE4, 0x70(OUTP)
11391
11392 + pax_force_retaddr 0, 1
11393 ret
11394 ENDPROC(aesni_xts_crypt8)
11395
11396 diff --git a/arch/x86/crypto/blowfish-avx2-asm_64.S b/arch/x86/crypto/blowfish-avx2-asm_64.S
11397 index 784452e..46982c7 100644
11398 --- a/arch/x86/crypto/blowfish-avx2-asm_64.S
11399 +++ b/arch/x86/crypto/blowfish-avx2-asm_64.S
11400 @@ -221,6 +221,7 @@ __blowfish_enc_blk32:
11401
11402 write_block(RXl, RXr);
11403
11404 + pax_force_retaddr 0, 1
11405 ret;
11406 ENDPROC(__blowfish_enc_blk32)
11407
11408 @@ -250,6 +251,7 @@ __blowfish_dec_blk32:
11409
11410 write_block(RXl, RXr);
11411
11412 + pax_force_retaddr 0, 1
11413 ret;
11414 ENDPROC(__blowfish_dec_blk32)
11415
11416 @@ -284,6 +286,7 @@ ENTRY(blowfish_ecb_enc_32way)
11417
11418 vzeroupper;
11419
11420 + pax_force_retaddr 0, 1
11421 ret;
11422 ENDPROC(blowfish_ecb_enc_32way)
11423
11424 @@ -318,6 +321,7 @@ ENTRY(blowfish_ecb_dec_32way)
11425
11426 vzeroupper;
11427
11428 + pax_force_retaddr 0, 1
11429 ret;
11430 ENDPROC(blowfish_ecb_dec_32way)
11431
11432 @@ -365,6 +369,7 @@ ENTRY(blowfish_cbc_dec_32way)
11433
11434 vzeroupper;
11435
11436 + pax_force_retaddr 0, 1
11437 ret;
11438 ENDPROC(blowfish_cbc_dec_32way)
11439
11440 @@ -445,5 +450,6 @@ ENTRY(blowfish_ctr_32way)
11441
11442 vzeroupper;
11443
11444 + pax_force_retaddr 0, 1
11445 ret;
11446 ENDPROC(blowfish_ctr_32way)
11447 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11448 index 246c670..4d1ed00 100644
11449 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
11450 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11451 @@ -21,6 +21,7 @@
11452 */
11453
11454 #include <linux/linkage.h>
11455 +#include <asm/alternative-asm.h>
11456
11457 .file "blowfish-x86_64-asm.S"
11458 .text
11459 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
11460 jnz .L__enc_xor;
11461
11462 write_block();
11463 + pax_force_retaddr 0, 1
11464 ret;
11465 .L__enc_xor:
11466 xor_block();
11467 + pax_force_retaddr 0, 1
11468 ret;
11469 ENDPROC(__blowfish_enc_blk)
11470
11471 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
11472
11473 movq %r11, %rbp;
11474
11475 + pax_force_retaddr 0, 1
11476 ret;
11477 ENDPROC(blowfish_dec_blk)
11478
11479 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
11480
11481 popq %rbx;
11482 popq %rbp;
11483 + pax_force_retaddr 0, 1
11484 ret;
11485
11486 .L__enc_xor4:
11487 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
11488
11489 popq %rbx;
11490 popq %rbp;
11491 + pax_force_retaddr 0, 1
11492 ret;
11493 ENDPROC(__blowfish_enc_blk_4way)
11494
11495 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
11496 popq %rbx;
11497 popq %rbp;
11498
11499 + pax_force_retaddr 0, 1
11500 ret;
11501 ENDPROC(blowfish_dec_blk_4way)
11502 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
11503 index ce71f92..2dd5b1e 100644
11504 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
11505 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
11506 @@ -16,6 +16,7 @@
11507 */
11508
11509 #include <linux/linkage.h>
11510 +#include <asm/alternative-asm.h>
11511
11512 #define CAMELLIA_TABLE_BYTE_LEN 272
11513
11514 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
11515 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
11516 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
11517 %rcx, (%r9));
11518 + pax_force_retaddr_bts
11519 ret;
11520 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
11521
11522 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
11523 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
11524 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
11525 %rax, (%r9));
11526 + pax_force_retaddr_bts
11527 ret;
11528 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
11529
11530 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
11531 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
11532 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
11533
11534 + pax_force_retaddr_bts
11535 ret;
11536
11537 .align 8
11538 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
11539 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
11540 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
11541
11542 + pax_force_retaddr_bts
11543 ret;
11544
11545 .align 8
11546 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
11547 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
11548 %xmm8, %rsi);
11549
11550 + pax_force_retaddr 0, 1
11551 ret;
11552 ENDPROC(camellia_ecb_enc_16way)
11553
11554 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
11555 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
11556 %xmm8, %rsi);
11557
11558 + pax_force_retaddr 0, 1
11559 ret;
11560 ENDPROC(camellia_ecb_dec_16way)
11561
11562 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
11563 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
11564 %xmm8, %rsi);
11565
11566 + pax_force_retaddr 0, 1
11567 ret;
11568 ENDPROC(camellia_cbc_dec_16way)
11569
11570 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
11571 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
11572 %xmm8, %rsi);
11573
11574 + pax_force_retaddr 0, 1
11575 ret;
11576 ENDPROC(camellia_ctr_16way)
11577
11578 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
11579 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
11580 %xmm8, %rsi);
11581
11582 + pax_force_retaddr 0, 1
11583 ret;
11584 ENDPROC(camellia_xts_crypt_16way)
11585
11586 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
11587 index 91a1878..bcf340a 100644
11588 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
11589 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
11590 @@ -11,6 +11,7 @@
11591 */
11592
11593 #include <linux/linkage.h>
11594 +#include <asm/alternative-asm.h>
11595
11596 #define CAMELLIA_TABLE_BYTE_LEN 272
11597
11598 @@ -212,6 +213,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
11599 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
11600 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
11601 %rcx, (%r9));
11602 + pax_force_retaddr_bts
11603 ret;
11604 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
11605
11606 @@ -220,6 +222,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
11607 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
11608 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
11609 %rax, (%r9));
11610 + pax_force_retaddr_bts
11611 ret;
11612 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
11613
11614 @@ -802,6 +805,7 @@ __camellia_enc_blk32:
11615 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
11616 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
11617
11618 + pax_force_retaddr_bts
11619 ret;
11620
11621 .align 8
11622 @@ -887,6 +891,7 @@ __camellia_dec_blk32:
11623 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
11624 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
11625
11626 + pax_force_retaddr_bts
11627 ret;
11628
11629 .align 8
11630 @@ -930,6 +935,7 @@ ENTRY(camellia_ecb_enc_32way)
11631
11632 vzeroupper;
11633
11634 + pax_force_retaddr 0, 1
11635 ret;
11636 ENDPROC(camellia_ecb_enc_32way)
11637
11638 @@ -962,6 +968,7 @@ ENTRY(camellia_ecb_dec_32way)
11639
11640 vzeroupper;
11641
11642 + pax_force_retaddr 0, 1
11643 ret;
11644 ENDPROC(camellia_ecb_dec_32way)
11645
11646 @@ -1028,6 +1035,7 @@ ENTRY(camellia_cbc_dec_32way)
11647
11648 vzeroupper;
11649
11650 + pax_force_retaddr 0, 1
11651 ret;
11652 ENDPROC(camellia_cbc_dec_32way)
11653
11654 @@ -1166,6 +1174,7 @@ ENTRY(camellia_ctr_32way)
11655
11656 vzeroupper;
11657
11658 + pax_force_retaddr 0, 1
11659 ret;
11660 ENDPROC(camellia_ctr_32way)
11661
11662 @@ -1331,6 +1340,7 @@ camellia_xts_crypt_32way:
11663
11664 vzeroupper;
11665
11666 + pax_force_retaddr 0, 1
11667 ret;
11668 ENDPROC(camellia_xts_crypt_32way)
11669
11670 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11671 index 310319c..ce174a4 100644
11672 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11673 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11674 @@ -21,6 +21,7 @@
11675 */
11676
11677 #include <linux/linkage.h>
11678 +#include <asm/alternative-asm.h>
11679
11680 .file "camellia-x86_64-asm_64.S"
11681 .text
11682 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
11683 enc_outunpack(mov, RT1);
11684
11685 movq RRBP, %rbp;
11686 + pax_force_retaddr 0, 1
11687 ret;
11688
11689 .L__enc_xor:
11690 enc_outunpack(xor, RT1);
11691
11692 movq RRBP, %rbp;
11693 + pax_force_retaddr 0, 1
11694 ret;
11695 ENDPROC(__camellia_enc_blk)
11696
11697 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11698 dec_outunpack();
11699
11700 movq RRBP, %rbp;
11701 + pax_force_retaddr 0, 1
11702 ret;
11703 ENDPROC(camellia_dec_blk)
11704
11705 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11706
11707 movq RRBP, %rbp;
11708 popq %rbx;
11709 + pax_force_retaddr 0, 1
11710 ret;
11711
11712 .L__enc2_xor:
11713 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11714
11715 movq RRBP, %rbp;
11716 popq %rbx;
11717 + pax_force_retaddr 0, 1
11718 ret;
11719 ENDPROC(__camellia_enc_blk_2way)
11720
11721 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11722
11723 movq RRBP, %rbp;
11724 movq RXOR, %rbx;
11725 + pax_force_retaddr 0, 1
11726 ret;
11727 ENDPROC(camellia_dec_blk_2way)
11728 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11729 index c35fd5d..c1ee236 100644
11730 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11731 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11732 @@ -24,6 +24,7 @@
11733 */
11734
11735 #include <linux/linkage.h>
11736 +#include <asm/alternative-asm.h>
11737
11738 .file "cast5-avx-x86_64-asm_64.S"
11739
11740 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11741 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11742 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11743
11744 + pax_force_retaddr 0, 1
11745 ret;
11746 ENDPROC(__cast5_enc_blk16)
11747
11748 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11749 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11750 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11751
11752 + pax_force_retaddr 0, 1
11753 ret;
11754
11755 .L__skip_dec:
11756 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11757 vmovdqu RR4, (6*4*4)(%r11);
11758 vmovdqu RL4, (7*4*4)(%r11);
11759
11760 + pax_force_retaddr
11761 ret;
11762 ENDPROC(cast5_ecb_enc_16way)
11763
11764 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11765 vmovdqu RR4, (6*4*4)(%r11);
11766 vmovdqu RL4, (7*4*4)(%r11);
11767
11768 + pax_force_retaddr
11769 ret;
11770 ENDPROC(cast5_ecb_dec_16way)
11771
11772 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11773
11774 popq %r12;
11775
11776 + pax_force_retaddr
11777 ret;
11778 ENDPROC(cast5_cbc_dec_16way)
11779
11780 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11781
11782 popq %r12;
11783
11784 + pax_force_retaddr
11785 ret;
11786 ENDPROC(cast5_ctr_16way)
11787 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11788 index e3531f8..18ded3a 100644
11789 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11790 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11791 @@ -24,6 +24,7 @@
11792 */
11793
11794 #include <linux/linkage.h>
11795 +#include <asm/alternative-asm.h>
11796 #include "glue_helper-asm-avx.S"
11797
11798 .file "cast6-avx-x86_64-asm_64.S"
11799 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
11800 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11801 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11802
11803 + pax_force_retaddr 0, 1
11804 ret;
11805 ENDPROC(__cast6_enc_blk8)
11806
11807 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
11808 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11809 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11810
11811 + pax_force_retaddr 0, 1
11812 ret;
11813 ENDPROC(__cast6_dec_blk8)
11814
11815 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
11816
11817 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11818
11819 + pax_force_retaddr
11820 ret;
11821 ENDPROC(cast6_ecb_enc_8way)
11822
11823 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
11824
11825 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11826
11827 + pax_force_retaddr
11828 ret;
11829 ENDPROC(cast6_ecb_dec_8way)
11830
11831 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
11832
11833 popq %r12;
11834
11835 + pax_force_retaddr
11836 ret;
11837 ENDPROC(cast6_cbc_dec_8way)
11838
11839 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
11840
11841 popq %r12;
11842
11843 + pax_force_retaddr
11844 ret;
11845 ENDPROC(cast6_ctr_8way)
11846
11847 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
11848 /* dst <= regs xor IVs(in dst) */
11849 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11850
11851 + pax_force_retaddr
11852 ret;
11853 ENDPROC(cast6_xts_enc_8way)
11854
11855 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
11856 /* dst <= regs xor IVs(in dst) */
11857 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11858
11859 + pax_force_retaddr
11860 ret;
11861 ENDPROC(cast6_xts_dec_8way)
11862 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
11863 index dbc4339..3d868c5 100644
11864 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
11865 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
11866 @@ -45,6 +45,7 @@
11867
11868 #include <asm/inst.h>
11869 #include <linux/linkage.h>
11870 +#include <asm/alternative-asm.h>
11871
11872 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
11873
11874 @@ -312,6 +313,7 @@ do_return:
11875 popq %rsi
11876 popq %rdi
11877 popq %rbx
11878 + pax_force_retaddr 0, 1
11879 ret
11880
11881 ################################################################
11882 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
11883 index 586f41a..d02851e 100644
11884 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
11885 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
11886 @@ -18,6 +18,7 @@
11887
11888 #include <linux/linkage.h>
11889 #include <asm/inst.h>
11890 +#include <asm/alternative-asm.h>
11891
11892 .data
11893
11894 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
11895 psrlq $1, T2
11896 pxor T2, T1
11897 pxor T1, DATA
11898 + pax_force_retaddr
11899 ret
11900 ENDPROC(__clmul_gf128mul_ble)
11901
11902 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
11903 call __clmul_gf128mul_ble
11904 PSHUFB_XMM BSWAP DATA
11905 movups DATA, (%rdi)
11906 + pax_force_retaddr
11907 ret
11908 ENDPROC(clmul_ghash_mul)
11909
11910 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
11911 PSHUFB_XMM BSWAP DATA
11912 movups DATA, (%rdi)
11913 .Lupdate_just_ret:
11914 + pax_force_retaddr
11915 ret
11916 ENDPROC(clmul_ghash_update)
11917
11918 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
11919 pand .Lpoly, %xmm1
11920 pxor %xmm1, %xmm0
11921 movups %xmm0, (%rdi)
11922 + pax_force_retaddr
11923 ret
11924 ENDPROC(clmul_ghash_setkey)
11925 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11926 index 9279e0b..9270820 100644
11927 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11928 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11929 @@ -1,4 +1,5 @@
11930 #include <linux/linkage.h>
11931 +#include <asm/alternative-asm.h>
11932
11933 # enter salsa20_encrypt_bytes
11934 ENTRY(salsa20_encrypt_bytes)
11935 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11936 add %r11,%rsp
11937 mov %rdi,%rax
11938 mov %rsi,%rdx
11939 + pax_force_retaddr 0, 1
11940 ret
11941 # bytesatleast65:
11942 ._bytesatleast65:
11943 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11944 add %r11,%rsp
11945 mov %rdi,%rax
11946 mov %rsi,%rdx
11947 + pax_force_retaddr
11948 ret
11949 ENDPROC(salsa20_keysetup)
11950
11951 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11952 add %r11,%rsp
11953 mov %rdi,%rax
11954 mov %rsi,%rdx
11955 + pax_force_retaddr
11956 ret
11957 ENDPROC(salsa20_ivsetup)
11958 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11959 index 2f202f4..d9164d6 100644
11960 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11961 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11962 @@ -24,6 +24,7 @@
11963 */
11964
11965 #include <linux/linkage.h>
11966 +#include <asm/alternative-asm.h>
11967 #include "glue_helper-asm-avx.S"
11968
11969 .file "serpent-avx-x86_64-asm_64.S"
11970 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
11971 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11972 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11973
11974 + pax_force_retaddr
11975 ret;
11976 ENDPROC(__serpent_enc_blk8_avx)
11977
11978 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
11979 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11980 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11981
11982 + pax_force_retaddr
11983 ret;
11984 ENDPROC(__serpent_dec_blk8_avx)
11985
11986 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11987
11988 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11989
11990 + pax_force_retaddr
11991 ret;
11992 ENDPROC(serpent_ecb_enc_8way_avx)
11993
11994 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11995
11996 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11997
11998 + pax_force_retaddr
11999 ret;
12000 ENDPROC(serpent_ecb_dec_8way_avx)
12001
12002 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12003
12004 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12005
12006 + pax_force_retaddr
12007 ret;
12008 ENDPROC(serpent_cbc_dec_8way_avx)
12009
12010 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12011
12012 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12013
12014 + pax_force_retaddr
12015 ret;
12016 ENDPROC(serpent_ctr_8way_avx)
12017
12018 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12019 /* dst <= regs xor IVs(in dst) */
12020 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12021
12022 + pax_force_retaddr
12023 ret;
12024 ENDPROC(serpent_xts_enc_8way_avx)
12025
12026 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12027 /* dst <= regs xor IVs(in dst) */
12028 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12029
12030 + pax_force_retaddr
12031 ret;
12032 ENDPROC(serpent_xts_dec_8way_avx)
12033 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12034 index b222085..abd483c 100644
12035 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12036 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12037 @@ -15,6 +15,7 @@
12038 */
12039
12040 #include <linux/linkage.h>
12041 +#include <asm/alternative-asm.h>
12042 #include "glue_helper-asm-avx2.S"
12043
12044 .file "serpent-avx2-asm_64.S"
12045 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12046 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12047 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12048
12049 + pax_force_retaddr
12050 ret;
12051 ENDPROC(__serpent_enc_blk16)
12052
12053 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12054 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12055 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12056
12057 + pax_force_retaddr
12058 ret;
12059 ENDPROC(__serpent_dec_blk16)
12060
12061 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12062
12063 vzeroupper;
12064
12065 + pax_force_retaddr
12066 ret;
12067 ENDPROC(serpent_ecb_enc_16way)
12068
12069 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12070
12071 vzeroupper;
12072
12073 + pax_force_retaddr
12074 ret;
12075 ENDPROC(serpent_ecb_dec_16way)
12076
12077 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12078
12079 vzeroupper;
12080
12081 + pax_force_retaddr
12082 ret;
12083 ENDPROC(serpent_cbc_dec_16way)
12084
12085 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12086
12087 vzeroupper;
12088
12089 + pax_force_retaddr
12090 ret;
12091 ENDPROC(serpent_ctr_16way)
12092
12093 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12094
12095 vzeroupper;
12096
12097 + pax_force_retaddr
12098 ret;
12099 ENDPROC(serpent_xts_enc_16way)
12100
12101 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12102
12103 vzeroupper;
12104
12105 + pax_force_retaddr
12106 ret;
12107 ENDPROC(serpent_xts_dec_16way)
12108 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12109 index acc066c..1559cc4 100644
12110 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12111 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12112 @@ -25,6 +25,7 @@
12113 */
12114
12115 #include <linux/linkage.h>
12116 +#include <asm/alternative-asm.h>
12117
12118 .file "serpent-sse2-x86_64-asm_64.S"
12119 .text
12120 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12121 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12122 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12123
12124 + pax_force_retaddr
12125 ret;
12126
12127 .L__enc_xor8:
12128 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12129 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12130
12131 + pax_force_retaddr
12132 ret;
12133 ENDPROC(__serpent_enc_blk_8way)
12134
12135 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12136 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12137 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12138
12139 + pax_force_retaddr
12140 ret;
12141 ENDPROC(serpent_dec_blk_8way)
12142 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12143 index a410950..3356d42 100644
12144 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12145 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12146 @@ -29,6 +29,7 @@
12147 */
12148
12149 #include <linux/linkage.h>
12150 +#include <asm/alternative-asm.h>
12151
12152 #define CTX %rdi // arg1
12153 #define BUF %rsi // arg2
12154 @@ -104,6 +105,7 @@
12155 pop %r12
12156 pop %rbp
12157 pop %rbx
12158 + pax_force_retaddr 0, 1
12159 ret
12160
12161 ENDPROC(\name)
12162 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
12163 index 642f156..4ab07b9 100644
12164 --- a/arch/x86/crypto/sha256-avx-asm.S
12165 +++ b/arch/x86/crypto/sha256-avx-asm.S
12166 @@ -49,6 +49,7 @@
12167
12168 #ifdef CONFIG_AS_AVX
12169 #include <linux/linkage.h>
12170 +#include <asm/alternative-asm.h>
12171
12172 ## assume buffers not aligned
12173 #define VMOVDQ vmovdqu
12174 @@ -460,6 +461,7 @@ done_hash:
12175 popq %r13
12176 popq %rbp
12177 popq %rbx
12178 + pax_force_retaddr 0, 1
12179 ret
12180 ENDPROC(sha256_transform_avx)
12181
12182 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
12183 index 9e86944..2e7f95a 100644
12184 --- a/arch/x86/crypto/sha256-avx2-asm.S
12185 +++ b/arch/x86/crypto/sha256-avx2-asm.S
12186 @@ -50,6 +50,7 @@
12187
12188 #ifdef CONFIG_AS_AVX2
12189 #include <linux/linkage.h>
12190 +#include <asm/alternative-asm.h>
12191
12192 ## assume buffers not aligned
12193 #define VMOVDQ vmovdqu
12194 @@ -720,6 +721,7 @@ done_hash:
12195 popq %r12
12196 popq %rbp
12197 popq %rbx
12198 + pax_force_retaddr 0, 1
12199 ret
12200 ENDPROC(sha256_transform_rorx)
12201
12202 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
12203 index f833b74..c36ed14 100644
12204 --- a/arch/x86/crypto/sha256-ssse3-asm.S
12205 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
12206 @@ -47,6 +47,7 @@
12207 ########################################################################
12208
12209 #include <linux/linkage.h>
12210 +#include <asm/alternative-asm.h>
12211
12212 ## assume buffers not aligned
12213 #define MOVDQ movdqu
12214 @@ -471,6 +472,7 @@ done_hash:
12215 popq %rbp
12216 popq %rbx
12217
12218 + pax_force_retaddr 0, 1
12219 ret
12220 ENDPROC(sha256_transform_ssse3)
12221
12222 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
12223 index 974dde9..4533d34 100644
12224 --- a/arch/x86/crypto/sha512-avx-asm.S
12225 +++ b/arch/x86/crypto/sha512-avx-asm.S
12226 @@ -49,6 +49,7 @@
12227
12228 #ifdef CONFIG_AS_AVX
12229 #include <linux/linkage.h>
12230 +#include <asm/alternative-asm.h>
12231
12232 .text
12233
12234 @@ -364,6 +365,7 @@ updateblock:
12235 mov frame_RSPSAVE(%rsp), %rsp
12236
12237 nowork:
12238 + pax_force_retaddr 0, 1
12239 ret
12240 ENDPROC(sha512_transform_avx)
12241
12242 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
12243 index 568b961..061ef1d 100644
12244 --- a/arch/x86/crypto/sha512-avx2-asm.S
12245 +++ b/arch/x86/crypto/sha512-avx2-asm.S
12246 @@ -51,6 +51,7 @@
12247
12248 #ifdef CONFIG_AS_AVX2
12249 #include <linux/linkage.h>
12250 +#include <asm/alternative-asm.h>
12251
12252 .text
12253
12254 @@ -678,6 +679,7 @@ done_hash:
12255
12256 # Restore Stack Pointer
12257 mov frame_RSPSAVE(%rsp), %rsp
12258 + pax_force_retaddr 0, 1
12259 ret
12260 ENDPROC(sha512_transform_rorx)
12261
12262 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
12263 index fb56855..e23914f 100644
12264 --- a/arch/x86/crypto/sha512-ssse3-asm.S
12265 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
12266 @@ -48,6 +48,7 @@
12267 ########################################################################
12268
12269 #include <linux/linkage.h>
12270 +#include <asm/alternative-asm.h>
12271
12272 .text
12273
12274 @@ -363,6 +364,7 @@ updateblock:
12275 mov frame_RSPSAVE(%rsp), %rsp
12276
12277 nowork:
12278 + pax_force_retaddr 0, 1
12279 ret
12280 ENDPROC(sha512_transform_ssse3)
12281
12282 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
12283 index 0505813..63b1d00 100644
12284 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
12285 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
12286 @@ -24,6 +24,7 @@
12287 */
12288
12289 #include <linux/linkage.h>
12290 +#include <asm/alternative-asm.h>
12291 #include "glue_helper-asm-avx.S"
12292
12293 .file "twofish-avx-x86_64-asm_64.S"
12294 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
12295 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
12296 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
12297
12298 + pax_force_retaddr 0, 1
12299 ret;
12300 ENDPROC(__twofish_enc_blk8)
12301
12302 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
12303 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
12304 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
12305
12306 + pax_force_retaddr 0, 1
12307 ret;
12308 ENDPROC(__twofish_dec_blk8)
12309
12310 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
12311
12312 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
12313
12314 + pax_force_retaddr 0, 1
12315 ret;
12316 ENDPROC(twofish_ecb_enc_8way)
12317
12318 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
12319
12320 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12321
12322 + pax_force_retaddr 0, 1
12323 ret;
12324 ENDPROC(twofish_ecb_dec_8way)
12325
12326 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
12327
12328 popq %r12;
12329
12330 + pax_force_retaddr 0, 1
12331 ret;
12332 ENDPROC(twofish_cbc_dec_8way)
12333
12334 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
12335
12336 popq %r12;
12337
12338 + pax_force_retaddr 0, 1
12339 ret;
12340 ENDPROC(twofish_ctr_8way)
12341
12342 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
12343 /* dst <= regs xor IVs(in dst) */
12344 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
12345
12346 + pax_force_retaddr 0, 1
12347 ret;
12348 ENDPROC(twofish_xts_enc_8way)
12349
12350 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
12351 /* dst <= regs xor IVs(in dst) */
12352 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12353
12354 + pax_force_retaddr 0, 1
12355 ret;
12356 ENDPROC(twofish_xts_dec_8way)
12357 diff --git a/arch/x86/crypto/twofish-avx2-asm_64.S b/arch/x86/crypto/twofish-avx2-asm_64.S
12358 index e1a83b9..33006b9 100644
12359 --- a/arch/x86/crypto/twofish-avx2-asm_64.S
12360 +++ b/arch/x86/crypto/twofish-avx2-asm_64.S
12361 @@ -11,6 +11,7 @@
12362 */
12363
12364 #include <linux/linkage.h>
12365 +#include <asm/alternative-asm.h>
12366 #include "glue_helper-asm-avx2.S"
12367
12368 .file "twofish-avx2-asm_64.S"
12369 @@ -422,6 +423,7 @@ __twofish_enc_blk16:
12370 outunpack_enc16(RA, RB, RC, RD);
12371 write_blocks16(RA, RB, RC, RD);
12372
12373 + pax_force_retaddr_bts
12374 ret;
12375 ENDPROC(__twofish_enc_blk16)
12376
12377 @@ -454,6 +456,7 @@ __twofish_dec_blk16:
12378 outunpack_dec16(RA, RB, RC, RD);
12379 write_blocks16(RA, RB, RC, RD);
12380
12381 + pax_force_retaddr_bts
12382 ret;
12383 ENDPROC(__twofish_dec_blk16)
12384
12385 @@ -476,6 +479,7 @@ ENTRY(twofish_ecb_enc_16way)
12386 popq %r12;
12387 vzeroupper;
12388
12389 + pax_force_retaddr 0, 1
12390 ret;
12391 ENDPROC(twofish_ecb_enc_16way)
12392
12393 @@ -498,6 +502,7 @@ ENTRY(twofish_ecb_dec_16way)
12394 popq %r12;
12395 vzeroupper;
12396
12397 + pax_force_retaddr 0, 1
12398 ret;
12399 ENDPROC(twofish_ecb_dec_16way)
12400
12401 @@ -521,6 +526,7 @@ ENTRY(twofish_cbc_dec_16way)
12402 popq %r12;
12403 vzeroupper;
12404
12405 + pax_force_retaddr 0, 1
12406 ret;
12407 ENDPROC(twofish_cbc_dec_16way)
12408
12409 @@ -546,6 +552,7 @@ ENTRY(twofish_ctr_16way)
12410 popq %r12;
12411 vzeroupper;
12412
12413 + pax_force_retaddr 0, 1
12414 ret;
12415 ENDPROC(twofish_ctr_16way)
12416
12417 @@ -574,6 +581,7 @@ twofish_xts_crypt_16way:
12418 popq %r12;
12419 vzeroupper;
12420
12421 + pax_force_retaddr 0, 1
12422 ret;
12423 ENDPROC(twofish_xts_crypt_16way)
12424
12425 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
12426 index 1c3b7ce..b365c5e 100644
12427 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
12428 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
12429 @@ -21,6 +21,7 @@
12430 */
12431
12432 #include <linux/linkage.h>
12433 +#include <asm/alternative-asm.h>
12434
12435 .file "twofish-x86_64-asm-3way.S"
12436 .text
12437 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
12438 popq %r13;
12439 popq %r14;
12440 popq %r15;
12441 + pax_force_retaddr 0, 1
12442 ret;
12443
12444 .L__enc_xor3:
12445 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
12446 popq %r13;
12447 popq %r14;
12448 popq %r15;
12449 + pax_force_retaddr 0, 1
12450 ret;
12451 ENDPROC(__twofish_enc_blk_3way)
12452
12453 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
12454 popq %r13;
12455 popq %r14;
12456 popq %r15;
12457 + pax_force_retaddr 0, 1
12458 ret;
12459 ENDPROC(twofish_dec_blk_3way)
12460 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
12461 index a039d21..29e7615 100644
12462 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
12463 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
12464 @@ -22,6 +22,7 @@
12465
12466 #include <linux/linkage.h>
12467 #include <asm/asm-offsets.h>
12468 +#include <asm/alternative-asm.h>
12469
12470 #define a_offset 0
12471 #define b_offset 4
12472 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
12473
12474 popq R1
12475 movq $1,%rax
12476 + pax_force_retaddr 0, 1
12477 ret
12478 ENDPROC(twofish_enc_blk)
12479
12480 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
12481
12482 popq R1
12483 movq $1,%rax
12484 + pax_force_retaddr 0, 1
12485 ret
12486 ENDPROC(twofish_dec_blk)
12487 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
12488 index 52ff81c..98af645 100644
12489 --- a/arch/x86/ia32/ia32_aout.c
12490 +++ b/arch/x86/ia32/ia32_aout.c
12491 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
12492 unsigned long dump_start, dump_size;
12493 struct user32 dump;
12494
12495 + memset(&dump, 0, sizeof(dump));
12496 +
12497 fs = get_fs();
12498 set_fs(KERNEL_DS);
12499 has_dumped = 1;
12500 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
12501 index cf1a471..5ba2673 100644
12502 --- a/arch/x86/ia32/ia32_signal.c
12503 +++ b/arch/x86/ia32/ia32_signal.c
12504 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
12505 sp -= frame_size;
12506 /* Align the stack pointer according to the i386 ABI,
12507 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
12508 - sp = ((sp + 4) & -16ul) - 4;
12509 + sp = ((sp - 12) & -16ul) - 4;
12510 return (void __user *) sp;
12511 }
12512
12513 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
12514 * These are actually not used anymore, but left because some
12515 * gdb versions depend on them as a marker.
12516 */
12517 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
12518 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
12519 } put_user_catch(err);
12520
12521 if (err)
12522 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
12523 0xb8,
12524 __NR_ia32_rt_sigreturn,
12525 0x80cd,
12526 - 0,
12527 + 0
12528 };
12529
12530 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
12531 @@ -459,20 +459,22 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
12532 else
12533 put_user_ex(0, &frame->uc.uc_flags);
12534 put_user_ex(0, &frame->uc.uc_link);
12535 - err |= __compat_save_altstack(&frame->uc.uc_stack, regs->sp);
12536 + __compat_save_altstack_ex(&frame->uc.uc_stack, regs->sp);
12537
12538 if (ksig->ka.sa.sa_flags & SA_RESTORER)
12539 restorer = ksig->ka.sa.sa_restorer;
12540 + else if (current->mm->context.vdso)
12541 + /* Return stub is in 32bit vsyscall page */
12542 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
12543 else
12544 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
12545 - rt_sigreturn);
12546 + restorer = &frame->retcode;
12547 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
12548
12549 /*
12550 * Not actually used anymore, but left because some gdb
12551 * versions need it.
12552 */
12553 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
12554 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
12555 } put_user_catch(err);
12556
12557 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
12558 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
12559 index 474dc1b..9297c58 100644
12560 --- a/arch/x86/ia32/ia32entry.S
12561 +++ b/arch/x86/ia32/ia32entry.S
12562 @@ -15,8 +15,10 @@
12563 #include <asm/irqflags.h>
12564 #include <asm/asm.h>
12565 #include <asm/smap.h>
12566 +#include <asm/pgtable.h>
12567 #include <linux/linkage.h>
12568 #include <linux/err.h>
12569 +#include <asm/alternative-asm.h>
12570
12571 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
12572 #include <linux/elf-em.h>
12573 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
12574 ENDPROC(native_irq_enable_sysexit)
12575 #endif
12576
12577 + .macro pax_enter_kernel_user
12578 + pax_set_fptr_mask
12579 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12580 + call pax_enter_kernel_user
12581 +#endif
12582 + .endm
12583 +
12584 + .macro pax_exit_kernel_user
12585 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12586 + call pax_exit_kernel_user
12587 +#endif
12588 +#ifdef CONFIG_PAX_RANDKSTACK
12589 + pushq %rax
12590 + pushq %r11
12591 + call pax_randomize_kstack
12592 + popq %r11
12593 + popq %rax
12594 +#endif
12595 + .endm
12596 +
12597 + .macro pax_erase_kstack
12598 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
12599 + call pax_erase_kstack
12600 +#endif
12601 + .endm
12602 +
12603 /*
12604 * 32bit SYSENTER instruction entry.
12605 *
12606 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
12607 CFI_REGISTER rsp,rbp
12608 SWAPGS_UNSAFE_STACK
12609 movq PER_CPU_VAR(kernel_stack), %rsp
12610 - addq $(KERNEL_STACK_OFFSET),%rsp
12611 - /*
12612 - * No need to follow this irqs on/off section: the syscall
12613 - * disabled irqs, here we enable it straight after entry:
12614 - */
12615 - ENABLE_INTERRUPTS(CLBR_NONE)
12616 movl %ebp,%ebp /* zero extension */
12617 pushq_cfi $__USER32_DS
12618 /*CFI_REL_OFFSET ss,0*/
12619 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
12620 CFI_REL_OFFSET rsp,0
12621 pushfq_cfi
12622 /*CFI_REL_OFFSET rflags,0*/
12623 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
12624 - CFI_REGISTER rip,r10
12625 + orl $X86_EFLAGS_IF,(%rsp)
12626 + GET_THREAD_INFO(%r11)
12627 + movl TI_sysenter_return(%r11), %r11d
12628 + CFI_REGISTER rip,r11
12629 pushq_cfi $__USER32_CS
12630 /*CFI_REL_OFFSET cs,0*/
12631 movl %eax, %eax
12632 - pushq_cfi %r10
12633 + pushq_cfi %r11
12634 CFI_REL_OFFSET rip,0
12635 pushq_cfi %rax
12636 cld
12637 SAVE_ARGS 0,1,0
12638 + pax_enter_kernel_user
12639 +
12640 +#ifdef CONFIG_PAX_RANDKSTACK
12641 + pax_erase_kstack
12642 +#endif
12643 +
12644 + /*
12645 + * No need to follow this irqs on/off section: the syscall
12646 + * disabled irqs, here we enable it straight after entry:
12647 + */
12648 + ENABLE_INTERRUPTS(CLBR_NONE)
12649 /* no need to do an access_ok check here because rbp has been
12650 32bit zero extended */
12651 +
12652 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12653 + addq pax_user_shadow_base,%rbp
12654 + ASM_PAX_OPEN_USERLAND
12655 +#endif
12656 +
12657 ASM_STAC
12658 1: movl (%rbp),%ebp
12659 _ASM_EXTABLE(1b,ia32_badarg)
12660 ASM_CLAC
12661 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12662 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12663 +
12664 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12665 + ASM_PAX_CLOSE_USERLAND
12666 +#endif
12667 +
12668 + GET_THREAD_INFO(%r11)
12669 + orl $TS_COMPAT,TI_status(%r11)
12670 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12671 CFI_REMEMBER_STATE
12672 jnz sysenter_tracesys
12673 cmpq $(IA32_NR_syscalls-1),%rax
12674 @@ -162,12 +209,15 @@ sysenter_do_call:
12675 sysenter_dispatch:
12676 call *ia32_sys_call_table(,%rax,8)
12677 movq %rax,RAX-ARGOFFSET(%rsp)
12678 + GET_THREAD_INFO(%r11)
12679 DISABLE_INTERRUPTS(CLBR_NONE)
12680 TRACE_IRQS_OFF
12681 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12682 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12683 jnz sysexit_audit
12684 sysexit_from_sys_call:
12685 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12686 + pax_exit_kernel_user
12687 + pax_erase_kstack
12688 + andl $~TS_COMPAT,TI_status(%r11)
12689 /* clear IF, that popfq doesn't enable interrupts early */
12690 andl $~0x200,EFLAGS-R11(%rsp)
12691 movl RIP-R11(%rsp),%edx /* User %eip */
12692 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
12693 movl %eax,%esi /* 2nd arg: syscall number */
12694 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
12695 call __audit_syscall_entry
12696 +
12697 + pax_erase_kstack
12698 +
12699 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
12700 cmpq $(IA32_NR_syscalls-1),%rax
12701 ja ia32_badsys
12702 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
12703 .endm
12704
12705 .macro auditsys_exit exit
12706 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12707 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12708 jnz ia32_ret_from_sys_call
12709 TRACE_IRQS_ON
12710 ENABLE_INTERRUPTS(CLBR_NONE)
12711 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
12712 1: setbe %al /* 1 if error, 0 if not */
12713 movzbl %al,%edi /* zero-extend that into %edi */
12714 call __audit_syscall_exit
12715 + GET_THREAD_INFO(%r11)
12716 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
12717 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
12718 DISABLE_INTERRUPTS(CLBR_NONE)
12719 TRACE_IRQS_OFF
12720 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12721 + testl %edi,TI_flags(%r11)
12722 jz \exit
12723 CLEAR_RREGS -ARGOFFSET
12724 jmp int_with_check
12725 @@ -237,7 +291,7 @@ sysexit_audit:
12726
12727 sysenter_tracesys:
12728 #ifdef CONFIG_AUDITSYSCALL
12729 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12730 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12731 jz sysenter_auditsys
12732 #endif
12733 SAVE_REST
12734 @@ -249,6 +303,9 @@ sysenter_tracesys:
12735 RESTORE_REST
12736 cmpq $(IA32_NR_syscalls-1),%rax
12737 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
12738 +
12739 + pax_erase_kstack
12740 +
12741 jmp sysenter_do_call
12742 CFI_ENDPROC
12743 ENDPROC(ia32_sysenter_target)
12744 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
12745 ENTRY(ia32_cstar_target)
12746 CFI_STARTPROC32 simple
12747 CFI_SIGNAL_FRAME
12748 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
12749 + CFI_DEF_CFA rsp,0
12750 CFI_REGISTER rip,rcx
12751 /*CFI_REGISTER rflags,r11*/
12752 SWAPGS_UNSAFE_STACK
12753 movl %esp,%r8d
12754 CFI_REGISTER rsp,r8
12755 movq PER_CPU_VAR(kernel_stack),%rsp
12756 + SAVE_ARGS 8*6,0,0
12757 + pax_enter_kernel_user
12758 +
12759 +#ifdef CONFIG_PAX_RANDKSTACK
12760 + pax_erase_kstack
12761 +#endif
12762 +
12763 /*
12764 * No need to follow this irqs on/off section: the syscall
12765 * disabled irqs and here we enable it straight after entry:
12766 */
12767 ENABLE_INTERRUPTS(CLBR_NONE)
12768 - SAVE_ARGS 8,0,0
12769 movl %eax,%eax /* zero extension */
12770 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
12771 movq %rcx,RIP-ARGOFFSET(%rsp)
12772 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
12773 /* no need to do an access_ok check here because r8 has been
12774 32bit zero extended */
12775 /* hardware stack frame is complete now */
12776 +
12777 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12778 + ASM_PAX_OPEN_USERLAND
12779 + movq pax_user_shadow_base,%r8
12780 + addq RSP-ARGOFFSET(%rsp),%r8
12781 +#endif
12782 +
12783 ASM_STAC
12784 1: movl (%r8),%r9d
12785 _ASM_EXTABLE(1b,ia32_badarg)
12786 ASM_CLAC
12787 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12788 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12789 +
12790 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12791 + ASM_PAX_CLOSE_USERLAND
12792 +#endif
12793 +
12794 + GET_THREAD_INFO(%r11)
12795 + orl $TS_COMPAT,TI_status(%r11)
12796 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12797 CFI_REMEMBER_STATE
12798 jnz cstar_tracesys
12799 cmpq $IA32_NR_syscalls-1,%rax
12800 @@ -319,12 +395,15 @@ cstar_do_call:
12801 cstar_dispatch:
12802 call *ia32_sys_call_table(,%rax,8)
12803 movq %rax,RAX-ARGOFFSET(%rsp)
12804 + GET_THREAD_INFO(%r11)
12805 DISABLE_INTERRUPTS(CLBR_NONE)
12806 TRACE_IRQS_OFF
12807 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12808 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12809 jnz sysretl_audit
12810 sysretl_from_sys_call:
12811 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12812 + pax_exit_kernel_user
12813 + pax_erase_kstack
12814 + andl $~TS_COMPAT,TI_status(%r11)
12815 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
12816 movl RIP-ARGOFFSET(%rsp),%ecx
12817 CFI_REGISTER rip,rcx
12818 @@ -352,7 +431,7 @@ sysretl_audit:
12819
12820 cstar_tracesys:
12821 #ifdef CONFIG_AUDITSYSCALL
12822 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12823 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12824 jz cstar_auditsys
12825 #endif
12826 xchgl %r9d,%ebp
12827 @@ -366,11 +445,19 @@ cstar_tracesys:
12828 xchgl %ebp,%r9d
12829 cmpq $(IA32_NR_syscalls-1),%rax
12830 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
12831 +
12832 + pax_erase_kstack
12833 +
12834 jmp cstar_do_call
12835 END(ia32_cstar_target)
12836
12837 ia32_badarg:
12838 ASM_CLAC
12839 +
12840 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12841 + ASM_PAX_CLOSE_USERLAND
12842 +#endif
12843 +
12844 movq $-EFAULT,%rax
12845 jmp ia32_sysret
12846 CFI_ENDPROC
12847 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
12848 CFI_REL_OFFSET rip,RIP-RIP
12849 PARAVIRT_ADJUST_EXCEPTION_FRAME
12850 SWAPGS
12851 - /*
12852 - * No need to follow this irqs on/off section: the syscall
12853 - * disabled irqs and here we enable it straight after entry:
12854 - */
12855 - ENABLE_INTERRUPTS(CLBR_NONE)
12856 movl %eax,%eax
12857 pushq_cfi %rax
12858 cld
12859 /* note the registers are not zero extended to the sf.
12860 this could be a problem. */
12861 SAVE_ARGS 0,1,0
12862 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12863 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12864 + pax_enter_kernel_user
12865 +
12866 +#ifdef CONFIG_PAX_RANDKSTACK
12867 + pax_erase_kstack
12868 +#endif
12869 +
12870 + /*
12871 + * No need to follow this irqs on/off section: the syscall
12872 + * disabled irqs and here we enable it straight after entry:
12873 + */
12874 + ENABLE_INTERRUPTS(CLBR_NONE)
12875 + GET_THREAD_INFO(%r11)
12876 + orl $TS_COMPAT,TI_status(%r11)
12877 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12878 jnz ia32_tracesys
12879 cmpq $(IA32_NR_syscalls-1),%rax
12880 ja ia32_badsys
12881 @@ -442,6 +536,9 @@ ia32_tracesys:
12882 RESTORE_REST
12883 cmpq $(IA32_NR_syscalls-1),%rax
12884 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
12885 +
12886 + pax_erase_kstack
12887 +
12888 jmp ia32_do_call
12889 END(ia32_syscall)
12890
12891 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
12892 index 8e0ceec..af13504 100644
12893 --- a/arch/x86/ia32/sys_ia32.c
12894 +++ b/arch/x86/ia32/sys_ia32.c
12895 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
12896 */
12897 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
12898 {
12899 - typeof(ubuf->st_uid) uid = 0;
12900 - typeof(ubuf->st_gid) gid = 0;
12901 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
12902 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
12903 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
12904 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
12905 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
12906 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
12907 index 372231c..a5aa1a1 100644
12908 --- a/arch/x86/include/asm/alternative-asm.h
12909 +++ b/arch/x86/include/asm/alternative-asm.h
12910 @@ -18,6 +18,45 @@
12911 .endm
12912 #endif
12913
12914 +#ifdef KERNEXEC_PLUGIN
12915 + .macro pax_force_retaddr_bts rip=0
12916 + btsq $63,\rip(%rsp)
12917 + .endm
12918 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
12919 + .macro pax_force_retaddr rip=0, reload=0
12920 + btsq $63,\rip(%rsp)
12921 + .endm
12922 + .macro pax_force_fptr ptr
12923 + btsq $63,\ptr
12924 + .endm
12925 + .macro pax_set_fptr_mask
12926 + .endm
12927 +#endif
12928 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
12929 + .macro pax_force_retaddr rip=0, reload=0
12930 + .if \reload
12931 + pax_set_fptr_mask
12932 + .endif
12933 + orq %r10,\rip(%rsp)
12934 + .endm
12935 + .macro pax_force_fptr ptr
12936 + orq %r10,\ptr
12937 + .endm
12938 + .macro pax_set_fptr_mask
12939 + movabs $0x8000000000000000,%r10
12940 + .endm
12941 +#endif
12942 +#else
12943 + .macro pax_force_retaddr rip=0, reload=0
12944 + .endm
12945 + .macro pax_force_fptr ptr
12946 + .endm
12947 + .macro pax_force_retaddr_bts rip=0
12948 + .endm
12949 + .macro pax_set_fptr_mask
12950 + .endm
12951 +#endif
12952 +
12953 .macro altinstruction_entry orig alt feature orig_len alt_len
12954 .long \orig - .
12955 .long \alt - .
12956 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
12957 index 58ed6d9..f1cbe58 100644
12958 --- a/arch/x86/include/asm/alternative.h
12959 +++ b/arch/x86/include/asm/alternative.h
12960 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12961 ".pushsection .discard,\"aw\",@progbits\n" \
12962 DISCARD_ENTRY(1) \
12963 ".popsection\n" \
12964 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12965 + ".pushsection .altinstr_replacement, \"a\"\n" \
12966 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
12967 ".popsection"
12968
12969 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12970 DISCARD_ENTRY(1) \
12971 DISCARD_ENTRY(2) \
12972 ".popsection\n" \
12973 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12974 + ".pushsection .altinstr_replacement, \"a\"\n" \
12975 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
12976 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
12977 ".popsection"
12978 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
12979 index 3388034..050f0b9 100644
12980 --- a/arch/x86/include/asm/apic.h
12981 +++ b/arch/x86/include/asm/apic.h
12982 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
12983
12984 #ifdef CONFIG_X86_LOCAL_APIC
12985
12986 -extern unsigned int apic_verbosity;
12987 +extern int apic_verbosity;
12988 extern int local_apic_timer_c2_ok;
12989
12990 extern int disable_apic;
12991 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
12992 index 20370c6..a2eb9b0 100644
12993 --- a/arch/x86/include/asm/apm.h
12994 +++ b/arch/x86/include/asm/apm.h
12995 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
12996 __asm__ __volatile__(APM_DO_ZERO_SEGS
12997 "pushl %%edi\n\t"
12998 "pushl %%ebp\n\t"
12999 - "lcall *%%cs:apm_bios_entry\n\t"
13000 + "lcall *%%ss:apm_bios_entry\n\t"
13001 "setc %%al\n\t"
13002 "popl %%ebp\n\t"
13003 "popl %%edi\n\t"
13004 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13005 __asm__ __volatile__(APM_DO_ZERO_SEGS
13006 "pushl %%edi\n\t"
13007 "pushl %%ebp\n\t"
13008 - "lcall *%%cs:apm_bios_entry\n\t"
13009 + "lcall *%%ss:apm_bios_entry\n\t"
13010 "setc %%bl\n\t"
13011 "popl %%ebp\n\t"
13012 "popl %%edi\n\t"
13013 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13014 index 722aa3b..3a0bb27 100644
13015 --- a/arch/x86/include/asm/atomic.h
13016 +++ b/arch/x86/include/asm/atomic.h
13017 @@ -22,7 +22,18 @@
13018 */
13019 static inline int atomic_read(const atomic_t *v)
13020 {
13021 - return (*(volatile int *)&(v)->counter);
13022 + return (*(volatile const int *)&(v)->counter);
13023 +}
13024 +
13025 +/**
13026 + * atomic_read_unchecked - read atomic variable
13027 + * @v: pointer of type atomic_unchecked_t
13028 + *
13029 + * Atomically reads the value of @v.
13030 + */
13031 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13032 +{
13033 + return (*(volatile const int *)&(v)->counter);
13034 }
13035
13036 /**
13037 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13038 }
13039
13040 /**
13041 + * atomic_set_unchecked - set atomic variable
13042 + * @v: pointer of type atomic_unchecked_t
13043 + * @i: required value
13044 + *
13045 + * Atomically sets the value of @v to @i.
13046 + */
13047 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13048 +{
13049 + v->counter = i;
13050 +}
13051 +
13052 +/**
13053 * atomic_add - add integer to atomic variable
13054 * @i: integer value to add
13055 * @v: pointer of type atomic_t
13056 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13057 */
13058 static inline void atomic_add(int i, atomic_t *v)
13059 {
13060 - asm volatile(LOCK_PREFIX "addl %1,%0"
13061 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13062 +
13063 +#ifdef CONFIG_PAX_REFCOUNT
13064 + "jno 0f\n"
13065 + LOCK_PREFIX "subl %1,%0\n"
13066 + "int $4\n0:\n"
13067 + _ASM_EXTABLE(0b, 0b)
13068 +#endif
13069 +
13070 + : "+m" (v->counter)
13071 + : "ir" (i));
13072 +}
13073 +
13074 +/**
13075 + * atomic_add_unchecked - add integer to atomic variable
13076 + * @i: integer value to add
13077 + * @v: pointer of type atomic_unchecked_t
13078 + *
13079 + * Atomically adds @i to @v.
13080 + */
13081 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13082 +{
13083 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13084 : "+m" (v->counter)
13085 : "ir" (i));
13086 }
13087 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13088 */
13089 static inline void atomic_sub(int i, atomic_t *v)
13090 {
13091 - asm volatile(LOCK_PREFIX "subl %1,%0"
13092 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13093 +
13094 +#ifdef CONFIG_PAX_REFCOUNT
13095 + "jno 0f\n"
13096 + LOCK_PREFIX "addl %1,%0\n"
13097 + "int $4\n0:\n"
13098 + _ASM_EXTABLE(0b, 0b)
13099 +#endif
13100 +
13101 + : "+m" (v->counter)
13102 + : "ir" (i));
13103 +}
13104 +
13105 +/**
13106 + * atomic_sub_unchecked - subtract integer from atomic variable
13107 + * @i: integer value to subtract
13108 + * @v: pointer of type atomic_unchecked_t
13109 + *
13110 + * Atomically subtracts @i from @v.
13111 + */
13112 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13113 +{
13114 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13115 : "+m" (v->counter)
13116 : "ir" (i));
13117 }
13118 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13119 {
13120 unsigned char c;
13121
13122 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13123 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13124 +
13125 +#ifdef CONFIG_PAX_REFCOUNT
13126 + "jno 0f\n"
13127 + LOCK_PREFIX "addl %2,%0\n"
13128 + "int $4\n0:\n"
13129 + _ASM_EXTABLE(0b, 0b)
13130 +#endif
13131 +
13132 + "sete %1\n"
13133 : "+m" (v->counter), "=qm" (c)
13134 : "ir" (i) : "memory");
13135 return c;
13136 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13137 */
13138 static inline void atomic_inc(atomic_t *v)
13139 {
13140 - asm volatile(LOCK_PREFIX "incl %0"
13141 + asm volatile(LOCK_PREFIX "incl %0\n"
13142 +
13143 +#ifdef CONFIG_PAX_REFCOUNT
13144 + "jno 0f\n"
13145 + LOCK_PREFIX "decl %0\n"
13146 + "int $4\n0:\n"
13147 + _ASM_EXTABLE(0b, 0b)
13148 +#endif
13149 +
13150 + : "+m" (v->counter));
13151 +}
13152 +
13153 +/**
13154 + * atomic_inc_unchecked - increment atomic variable
13155 + * @v: pointer of type atomic_unchecked_t
13156 + *
13157 + * Atomically increments @v by 1.
13158 + */
13159 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13160 +{
13161 + asm volatile(LOCK_PREFIX "incl %0\n"
13162 : "+m" (v->counter));
13163 }
13164
13165 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13166 */
13167 static inline void atomic_dec(atomic_t *v)
13168 {
13169 - asm volatile(LOCK_PREFIX "decl %0"
13170 + asm volatile(LOCK_PREFIX "decl %0\n"
13171 +
13172 +#ifdef CONFIG_PAX_REFCOUNT
13173 + "jno 0f\n"
13174 + LOCK_PREFIX "incl %0\n"
13175 + "int $4\n0:\n"
13176 + _ASM_EXTABLE(0b, 0b)
13177 +#endif
13178 +
13179 + : "+m" (v->counter));
13180 +}
13181 +
13182 +/**
13183 + * atomic_dec_unchecked - decrement atomic variable
13184 + * @v: pointer of type atomic_unchecked_t
13185 + *
13186 + * Atomically decrements @v by 1.
13187 + */
13188 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13189 +{
13190 + asm volatile(LOCK_PREFIX "decl %0\n"
13191 : "+m" (v->counter));
13192 }
13193
13194 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13195 {
13196 unsigned char c;
13197
13198 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13199 + asm volatile(LOCK_PREFIX "decl %0\n"
13200 +
13201 +#ifdef CONFIG_PAX_REFCOUNT
13202 + "jno 0f\n"
13203 + LOCK_PREFIX "incl %0\n"
13204 + "int $4\n0:\n"
13205 + _ASM_EXTABLE(0b, 0b)
13206 +#endif
13207 +
13208 + "sete %1\n"
13209 : "+m" (v->counter), "=qm" (c)
13210 : : "memory");
13211 return c != 0;
13212 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13213 {
13214 unsigned char c;
13215
13216 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13217 + asm volatile(LOCK_PREFIX "incl %0\n"
13218 +
13219 +#ifdef CONFIG_PAX_REFCOUNT
13220 + "jno 0f\n"
13221 + LOCK_PREFIX "decl %0\n"
13222 + "int $4\n0:\n"
13223 + _ASM_EXTABLE(0b, 0b)
13224 +#endif
13225 +
13226 + "sete %1\n"
13227 + : "+m" (v->counter), "=qm" (c)
13228 + : : "memory");
13229 + return c != 0;
13230 +}
13231 +
13232 +/**
13233 + * atomic_inc_and_test_unchecked - increment and test
13234 + * @v: pointer of type atomic_unchecked_t
13235 + *
13236 + * Atomically increments @v by 1
13237 + * and returns true if the result is zero, or false for all
13238 + * other cases.
13239 + */
13240 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
13241 +{
13242 + unsigned char c;
13243 +
13244 + asm volatile(LOCK_PREFIX "incl %0\n"
13245 + "sete %1\n"
13246 : "+m" (v->counter), "=qm" (c)
13247 : : "memory");
13248 return c != 0;
13249 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13250 {
13251 unsigned char c;
13252
13253 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
13254 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
13255 +
13256 +#ifdef CONFIG_PAX_REFCOUNT
13257 + "jno 0f\n"
13258 + LOCK_PREFIX "subl %2,%0\n"
13259 + "int $4\n0:\n"
13260 + _ASM_EXTABLE(0b, 0b)
13261 +#endif
13262 +
13263 + "sets %1\n"
13264 : "+m" (v->counter), "=qm" (c)
13265 : "ir" (i) : "memory");
13266 return c;
13267 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13268 */
13269 static inline int atomic_add_return(int i, atomic_t *v)
13270 {
13271 + return i + xadd_check_overflow(&v->counter, i);
13272 +}
13273 +
13274 +/**
13275 + * atomic_add_return_unchecked - add integer and return
13276 + * @i: integer value to add
13277 + * @v: pointer of type atomic_unchecked_t
13278 + *
13279 + * Atomically adds @i to @v and returns @i + @v
13280 + */
13281 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
13282 +{
13283 return i + xadd(&v->counter, i);
13284 }
13285
13286 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
13287 }
13288
13289 #define atomic_inc_return(v) (atomic_add_return(1, v))
13290 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
13291 +{
13292 + return atomic_add_return_unchecked(1, v);
13293 +}
13294 #define atomic_dec_return(v) (atomic_sub_return(1, v))
13295
13296 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
13297 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
13298 return cmpxchg(&v->counter, old, new);
13299 }
13300
13301 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
13302 +{
13303 + return cmpxchg(&v->counter, old, new);
13304 +}
13305 +
13306 static inline int atomic_xchg(atomic_t *v, int new)
13307 {
13308 return xchg(&v->counter, new);
13309 }
13310
13311 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
13312 +{
13313 + return xchg(&v->counter, new);
13314 +}
13315 +
13316 /**
13317 * __atomic_add_unless - add unless the number is already a given value
13318 * @v: pointer of type atomic_t
13319 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
13320 */
13321 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
13322 {
13323 - int c, old;
13324 + int c, old, new;
13325 c = atomic_read(v);
13326 for (;;) {
13327 - if (unlikely(c == (u)))
13328 + if (unlikely(c == u))
13329 break;
13330 - old = atomic_cmpxchg((v), c, c + (a));
13331 +
13332 + asm volatile("addl %2,%0\n"
13333 +
13334 +#ifdef CONFIG_PAX_REFCOUNT
13335 + "jno 0f\n"
13336 + "subl %2,%0\n"
13337 + "int $4\n0:\n"
13338 + _ASM_EXTABLE(0b, 0b)
13339 +#endif
13340 +
13341 + : "=r" (new)
13342 + : "0" (c), "ir" (a));
13343 +
13344 + old = atomic_cmpxchg(v, c, new);
13345 if (likely(old == c))
13346 break;
13347 c = old;
13348 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
13349 }
13350
13351 /**
13352 + * atomic_inc_not_zero_hint - increment if not null
13353 + * @v: pointer of type atomic_t
13354 + * @hint: probable value of the atomic before the increment
13355 + *
13356 + * This version of atomic_inc_not_zero() gives a hint of probable
13357 + * value of the atomic. This helps processor to not read the memory
13358 + * before doing the atomic read/modify/write cycle, lowering
13359 + * number of bus transactions on some arches.
13360 + *
13361 + * Returns: 0 if increment was not done, 1 otherwise.
13362 + */
13363 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
13364 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
13365 +{
13366 + int val, c = hint, new;
13367 +
13368 + /* sanity test, should be removed by compiler if hint is a constant */
13369 + if (!hint)
13370 + return __atomic_add_unless(v, 1, 0);
13371 +
13372 + do {
13373 + asm volatile("incl %0\n"
13374 +
13375 +#ifdef CONFIG_PAX_REFCOUNT
13376 + "jno 0f\n"
13377 + "decl %0\n"
13378 + "int $4\n0:\n"
13379 + _ASM_EXTABLE(0b, 0b)
13380 +#endif
13381 +
13382 + : "=r" (new)
13383 + : "0" (c));
13384 +
13385 + val = atomic_cmpxchg(v, c, new);
13386 + if (val == c)
13387 + return 1;
13388 + c = val;
13389 + } while (c);
13390 +
13391 + return 0;
13392 +}
13393 +
13394 +/**
13395 * atomic_inc_short - increment of a short integer
13396 * @v: pointer to type int
13397 *
13398 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
13399 #endif
13400
13401 /* These are x86-specific, used by some header files */
13402 -#define atomic_clear_mask(mask, addr) \
13403 - asm volatile(LOCK_PREFIX "andl %0,%1" \
13404 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
13405 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
13406 +{
13407 + asm volatile(LOCK_PREFIX "andl %1,%0"
13408 + : "+m" (v->counter)
13409 + : "r" (~(mask))
13410 + : "memory");
13411 +}
13412
13413 -#define atomic_set_mask(mask, addr) \
13414 - asm volatile(LOCK_PREFIX "orl %0,%1" \
13415 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
13416 - : "memory")
13417 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
13418 +{
13419 + asm volatile(LOCK_PREFIX "andl %1,%0"
13420 + : "+m" (v->counter)
13421 + : "r" (~(mask))
13422 + : "memory");
13423 +}
13424 +
13425 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
13426 +{
13427 + asm volatile(LOCK_PREFIX "orl %1,%0"
13428 + : "+m" (v->counter)
13429 + : "r" (mask)
13430 + : "memory");
13431 +}
13432 +
13433 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
13434 +{
13435 + asm volatile(LOCK_PREFIX "orl %1,%0"
13436 + : "+m" (v->counter)
13437 + : "r" (mask)
13438 + : "memory");
13439 +}
13440
13441 /* Atomic operations are already serializing on x86 */
13442 #define smp_mb__before_atomic_dec() barrier()
13443 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
13444 index b154de7..aadebd8 100644
13445 --- a/arch/x86/include/asm/atomic64_32.h
13446 +++ b/arch/x86/include/asm/atomic64_32.h
13447 @@ -12,6 +12,14 @@ typedef struct {
13448 u64 __aligned(8) counter;
13449 } atomic64_t;
13450
13451 +#ifdef CONFIG_PAX_REFCOUNT
13452 +typedef struct {
13453 + u64 __aligned(8) counter;
13454 +} atomic64_unchecked_t;
13455 +#else
13456 +typedef atomic64_t atomic64_unchecked_t;
13457 +#endif
13458 +
13459 #define ATOMIC64_INIT(val) { (val) }
13460
13461 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
13462 @@ -37,21 +45,31 @@ typedef struct {
13463 ATOMIC64_DECL_ONE(sym##_386)
13464
13465 ATOMIC64_DECL_ONE(add_386);
13466 +ATOMIC64_DECL_ONE(add_unchecked_386);
13467 ATOMIC64_DECL_ONE(sub_386);
13468 +ATOMIC64_DECL_ONE(sub_unchecked_386);
13469 ATOMIC64_DECL_ONE(inc_386);
13470 +ATOMIC64_DECL_ONE(inc_unchecked_386);
13471 ATOMIC64_DECL_ONE(dec_386);
13472 +ATOMIC64_DECL_ONE(dec_unchecked_386);
13473 #endif
13474
13475 #define alternative_atomic64(f, out, in...) \
13476 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
13477
13478 ATOMIC64_DECL(read);
13479 +ATOMIC64_DECL(read_unchecked);
13480 ATOMIC64_DECL(set);
13481 +ATOMIC64_DECL(set_unchecked);
13482 ATOMIC64_DECL(xchg);
13483 ATOMIC64_DECL(add_return);
13484 +ATOMIC64_DECL(add_return_unchecked);
13485 ATOMIC64_DECL(sub_return);
13486 +ATOMIC64_DECL(sub_return_unchecked);
13487 ATOMIC64_DECL(inc_return);
13488 +ATOMIC64_DECL(inc_return_unchecked);
13489 ATOMIC64_DECL(dec_return);
13490 +ATOMIC64_DECL(dec_return_unchecked);
13491 ATOMIC64_DECL(dec_if_positive);
13492 ATOMIC64_DECL(inc_not_zero);
13493 ATOMIC64_DECL(add_unless);
13494 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
13495 }
13496
13497 /**
13498 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
13499 + * @p: pointer to type atomic64_unchecked_t
13500 + * @o: expected value
13501 + * @n: new value
13502 + *
13503 + * Atomically sets @v to @n if it was equal to @o and returns
13504 + * the old value.
13505 + */
13506 +
13507 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
13508 +{
13509 + return cmpxchg64(&v->counter, o, n);
13510 +}
13511 +
13512 +/**
13513 * atomic64_xchg - xchg atomic64 variable
13514 * @v: pointer to type atomic64_t
13515 * @n: value to assign
13516 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
13517 }
13518
13519 /**
13520 + * atomic64_set_unchecked - set atomic64 variable
13521 + * @v: pointer to type atomic64_unchecked_t
13522 + * @n: value to assign
13523 + *
13524 + * Atomically sets the value of @v to @n.
13525 + */
13526 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
13527 +{
13528 + unsigned high = (unsigned)(i >> 32);
13529 + unsigned low = (unsigned)i;
13530 + alternative_atomic64(set, /* no output */,
13531 + "S" (v), "b" (low), "c" (high)
13532 + : "eax", "edx", "memory");
13533 +}
13534 +
13535 +/**
13536 * atomic64_read - read atomic64 variable
13537 * @v: pointer to type atomic64_t
13538 *
13539 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
13540 }
13541
13542 /**
13543 + * atomic64_read_unchecked - read atomic64 variable
13544 + * @v: pointer to type atomic64_unchecked_t
13545 + *
13546 + * Atomically reads the value of @v and returns it.
13547 + */
13548 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
13549 +{
13550 + long long r;
13551 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
13552 + return r;
13553 + }
13554 +
13555 +/**
13556 * atomic64_add_return - add and return
13557 * @i: integer value to add
13558 * @v: pointer to type atomic64_t
13559 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
13560 return i;
13561 }
13562
13563 +/**
13564 + * atomic64_add_return_unchecked - add and return
13565 + * @i: integer value to add
13566 + * @v: pointer to type atomic64_unchecked_t
13567 + *
13568 + * Atomically adds @i to @v and returns @i + *@v
13569 + */
13570 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
13571 +{
13572 + alternative_atomic64(add_return_unchecked,
13573 + ASM_OUTPUT2("+A" (i), "+c" (v)),
13574 + ASM_NO_INPUT_CLOBBER("memory"));
13575 + return i;
13576 +}
13577 +
13578 /*
13579 * Other variants with different arithmetic operators:
13580 */
13581 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
13582 return a;
13583 }
13584
13585 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13586 +{
13587 + long long a;
13588 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
13589 + "S" (v) : "memory", "ecx");
13590 + return a;
13591 +}
13592 +
13593 static inline long long atomic64_dec_return(atomic64_t *v)
13594 {
13595 long long a;
13596 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
13597 }
13598
13599 /**
13600 + * atomic64_add_unchecked - add integer to atomic64 variable
13601 + * @i: integer value to add
13602 + * @v: pointer to type atomic64_unchecked_t
13603 + *
13604 + * Atomically adds @i to @v.
13605 + */
13606 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
13607 +{
13608 + __alternative_atomic64(add_unchecked, add_return_unchecked,
13609 + ASM_OUTPUT2("+A" (i), "+c" (v)),
13610 + ASM_NO_INPUT_CLOBBER("memory"));
13611 + return i;
13612 +}
13613 +
13614 +/**
13615 * atomic64_sub - subtract the atomic64 variable
13616 * @i: integer value to subtract
13617 * @v: pointer to type atomic64_t
13618 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
13619 index 0e1cbfc..5623683 100644
13620 --- a/arch/x86/include/asm/atomic64_64.h
13621 +++ b/arch/x86/include/asm/atomic64_64.h
13622 @@ -18,7 +18,19 @@
13623 */
13624 static inline long atomic64_read(const atomic64_t *v)
13625 {
13626 - return (*(volatile long *)&(v)->counter);
13627 + return (*(volatile const long *)&(v)->counter);
13628 +}
13629 +
13630 +/**
13631 + * atomic64_read_unchecked - read atomic64 variable
13632 + * @v: pointer of type atomic64_unchecked_t
13633 + *
13634 + * Atomically reads the value of @v.
13635 + * Doesn't imply a read memory barrier.
13636 + */
13637 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
13638 +{
13639 + return (*(volatile const long *)&(v)->counter);
13640 }
13641
13642 /**
13643 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
13644 }
13645
13646 /**
13647 + * atomic64_set_unchecked - set atomic64 variable
13648 + * @v: pointer to type atomic64_unchecked_t
13649 + * @i: required value
13650 + *
13651 + * Atomically sets the value of @v to @i.
13652 + */
13653 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
13654 +{
13655 + v->counter = i;
13656 +}
13657 +
13658 +/**
13659 * atomic64_add - add integer to atomic64 variable
13660 * @i: integer value to add
13661 * @v: pointer to type atomic64_t
13662 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
13663 */
13664 static inline void atomic64_add(long i, atomic64_t *v)
13665 {
13666 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
13667 +
13668 +#ifdef CONFIG_PAX_REFCOUNT
13669 + "jno 0f\n"
13670 + LOCK_PREFIX "subq %1,%0\n"
13671 + "int $4\n0:\n"
13672 + _ASM_EXTABLE(0b, 0b)
13673 +#endif
13674 +
13675 + : "=m" (v->counter)
13676 + : "er" (i), "m" (v->counter));
13677 +}
13678 +
13679 +/**
13680 + * atomic64_add_unchecked - add integer to atomic64 variable
13681 + * @i: integer value to add
13682 + * @v: pointer to type atomic64_unchecked_t
13683 + *
13684 + * Atomically adds @i to @v.
13685 + */
13686 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
13687 +{
13688 asm volatile(LOCK_PREFIX "addq %1,%0"
13689 : "=m" (v->counter)
13690 : "er" (i), "m" (v->counter));
13691 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
13692 */
13693 static inline void atomic64_sub(long i, atomic64_t *v)
13694 {
13695 - asm volatile(LOCK_PREFIX "subq %1,%0"
13696 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13697 +
13698 +#ifdef CONFIG_PAX_REFCOUNT
13699 + "jno 0f\n"
13700 + LOCK_PREFIX "addq %1,%0\n"
13701 + "int $4\n0:\n"
13702 + _ASM_EXTABLE(0b, 0b)
13703 +#endif
13704 +
13705 + : "=m" (v->counter)
13706 + : "er" (i), "m" (v->counter));
13707 +}
13708 +
13709 +/**
13710 + * atomic64_sub_unchecked - subtract the atomic64 variable
13711 + * @i: integer value to subtract
13712 + * @v: pointer to type atomic64_unchecked_t
13713 + *
13714 + * Atomically subtracts @i from @v.
13715 + */
13716 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
13717 +{
13718 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13719 : "=m" (v->counter)
13720 : "er" (i), "m" (v->counter));
13721 }
13722 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13723 {
13724 unsigned char c;
13725
13726 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
13727 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
13728 +
13729 +#ifdef CONFIG_PAX_REFCOUNT
13730 + "jno 0f\n"
13731 + LOCK_PREFIX "addq %2,%0\n"
13732 + "int $4\n0:\n"
13733 + _ASM_EXTABLE(0b, 0b)
13734 +#endif
13735 +
13736 + "sete %1\n"
13737 : "=m" (v->counter), "=qm" (c)
13738 : "er" (i), "m" (v->counter) : "memory");
13739 return c;
13740 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13741 */
13742 static inline void atomic64_inc(atomic64_t *v)
13743 {
13744 + asm volatile(LOCK_PREFIX "incq %0\n"
13745 +
13746 +#ifdef CONFIG_PAX_REFCOUNT
13747 + "jno 0f\n"
13748 + LOCK_PREFIX "decq %0\n"
13749 + "int $4\n0:\n"
13750 + _ASM_EXTABLE(0b, 0b)
13751 +#endif
13752 +
13753 + : "=m" (v->counter)
13754 + : "m" (v->counter));
13755 +}
13756 +
13757 +/**
13758 + * atomic64_inc_unchecked - increment atomic64 variable
13759 + * @v: pointer to type atomic64_unchecked_t
13760 + *
13761 + * Atomically increments @v by 1.
13762 + */
13763 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
13764 +{
13765 asm volatile(LOCK_PREFIX "incq %0"
13766 : "=m" (v->counter)
13767 : "m" (v->counter));
13768 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
13769 */
13770 static inline void atomic64_dec(atomic64_t *v)
13771 {
13772 - asm volatile(LOCK_PREFIX "decq %0"
13773 + asm volatile(LOCK_PREFIX "decq %0\n"
13774 +
13775 +#ifdef CONFIG_PAX_REFCOUNT
13776 + "jno 0f\n"
13777 + LOCK_PREFIX "incq %0\n"
13778 + "int $4\n0:\n"
13779 + _ASM_EXTABLE(0b, 0b)
13780 +#endif
13781 +
13782 + : "=m" (v->counter)
13783 + : "m" (v->counter));
13784 +}
13785 +
13786 +/**
13787 + * atomic64_dec_unchecked - decrement atomic64 variable
13788 + * @v: pointer to type atomic64_t
13789 + *
13790 + * Atomically decrements @v by 1.
13791 + */
13792 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
13793 +{
13794 + asm volatile(LOCK_PREFIX "decq %0\n"
13795 : "=m" (v->counter)
13796 : "m" (v->counter));
13797 }
13798 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
13799 {
13800 unsigned char c;
13801
13802 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
13803 + asm volatile(LOCK_PREFIX "decq %0\n"
13804 +
13805 +#ifdef CONFIG_PAX_REFCOUNT
13806 + "jno 0f\n"
13807 + LOCK_PREFIX "incq %0\n"
13808 + "int $4\n0:\n"
13809 + _ASM_EXTABLE(0b, 0b)
13810 +#endif
13811 +
13812 + "sete %1\n"
13813 : "=m" (v->counter), "=qm" (c)
13814 : "m" (v->counter) : "memory");
13815 return c != 0;
13816 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
13817 {
13818 unsigned char c;
13819
13820 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
13821 + asm volatile(LOCK_PREFIX "incq %0\n"
13822 +
13823 +#ifdef CONFIG_PAX_REFCOUNT
13824 + "jno 0f\n"
13825 + LOCK_PREFIX "decq %0\n"
13826 + "int $4\n0:\n"
13827 + _ASM_EXTABLE(0b, 0b)
13828 +#endif
13829 +
13830 + "sete %1\n"
13831 : "=m" (v->counter), "=qm" (c)
13832 : "m" (v->counter) : "memory");
13833 return c != 0;
13834 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13835 {
13836 unsigned char c;
13837
13838 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
13839 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
13840 +
13841 +#ifdef CONFIG_PAX_REFCOUNT
13842 + "jno 0f\n"
13843 + LOCK_PREFIX "subq %2,%0\n"
13844 + "int $4\n0:\n"
13845 + _ASM_EXTABLE(0b, 0b)
13846 +#endif
13847 +
13848 + "sets %1\n"
13849 : "=m" (v->counter), "=qm" (c)
13850 : "er" (i), "m" (v->counter) : "memory");
13851 return c;
13852 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13853 */
13854 static inline long atomic64_add_return(long i, atomic64_t *v)
13855 {
13856 + return i + xadd_check_overflow(&v->counter, i);
13857 +}
13858 +
13859 +/**
13860 + * atomic64_add_return_unchecked - add and return
13861 + * @i: integer value to add
13862 + * @v: pointer to type atomic64_unchecked_t
13863 + *
13864 + * Atomically adds @i to @v and returns @i + @v
13865 + */
13866 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
13867 +{
13868 return i + xadd(&v->counter, i);
13869 }
13870
13871 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
13872 }
13873
13874 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
13875 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13876 +{
13877 + return atomic64_add_return_unchecked(1, v);
13878 +}
13879 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
13880
13881 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13882 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13883 return cmpxchg(&v->counter, old, new);
13884 }
13885
13886 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
13887 +{
13888 + return cmpxchg(&v->counter, old, new);
13889 +}
13890 +
13891 static inline long atomic64_xchg(atomic64_t *v, long new)
13892 {
13893 return xchg(&v->counter, new);
13894 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
13895 */
13896 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
13897 {
13898 - long c, old;
13899 + long c, old, new;
13900 c = atomic64_read(v);
13901 for (;;) {
13902 - if (unlikely(c == (u)))
13903 + if (unlikely(c == u))
13904 break;
13905 - old = atomic64_cmpxchg((v), c, c + (a));
13906 +
13907 + asm volatile("add %2,%0\n"
13908 +
13909 +#ifdef CONFIG_PAX_REFCOUNT
13910 + "jno 0f\n"
13911 + "sub %2,%0\n"
13912 + "int $4\n0:\n"
13913 + _ASM_EXTABLE(0b, 0b)
13914 +#endif
13915 +
13916 + : "=r" (new)
13917 + : "0" (c), "ir" (a));
13918 +
13919 + old = atomic64_cmpxchg(v, c, new);
13920 if (likely(old == c))
13921 break;
13922 c = old;
13923 }
13924 - return c != (u);
13925 + return c != u;
13926 }
13927
13928 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
13929 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
13930 index 6dfd019..28e188d 100644
13931 --- a/arch/x86/include/asm/bitops.h
13932 +++ b/arch/x86/include/asm/bitops.h
13933 @@ -40,7 +40,7 @@
13934 * a mask operation on a byte.
13935 */
13936 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
13937 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
13938 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
13939 #define CONST_MASK(nr) (1 << ((nr) & 7))
13940
13941 /**
13942 @@ -486,7 +486,7 @@ static inline int fls(int x)
13943 * at position 64.
13944 */
13945 #ifdef CONFIG_X86_64
13946 -static __always_inline int fls64(__u64 x)
13947 +static __always_inline long fls64(__u64 x)
13948 {
13949 int bitpos = -1;
13950 /*
13951 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
13952 index 4fa687a..60f2d39 100644
13953 --- a/arch/x86/include/asm/boot.h
13954 +++ b/arch/x86/include/asm/boot.h
13955 @@ -6,10 +6,15 @@
13956 #include <uapi/asm/boot.h>
13957
13958 /* Physical address where kernel should be loaded. */
13959 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13960 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13961 + (CONFIG_PHYSICAL_ALIGN - 1)) \
13962 & ~(CONFIG_PHYSICAL_ALIGN - 1))
13963
13964 +#ifndef __ASSEMBLY__
13965 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
13966 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
13967 +#endif
13968 +
13969 /* Minimum kernel alignment, as a power of two */
13970 #ifdef CONFIG_X86_64
13971 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
13972 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
13973 index 48f99f1..d78ebf9 100644
13974 --- a/arch/x86/include/asm/cache.h
13975 +++ b/arch/x86/include/asm/cache.h
13976 @@ -5,12 +5,13 @@
13977
13978 /* L1 cache line size */
13979 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
13980 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
13981 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
13982
13983 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
13984 +#define __read_only __attribute__((__section__(".data..read_only")))
13985
13986 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
13987 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
13988 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
13989
13990 #ifdef CONFIG_X86_VSMP
13991 #ifdef CONFIG_SMP
13992 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
13993 index 9863ee3..4a1f8e1 100644
13994 --- a/arch/x86/include/asm/cacheflush.h
13995 +++ b/arch/x86/include/asm/cacheflush.h
13996 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
13997 unsigned long pg_flags = pg->flags & _PGMT_MASK;
13998
13999 if (pg_flags == _PGMT_DEFAULT)
14000 - return -1;
14001 + return ~0UL;
14002 else if (pg_flags == _PGMT_WC)
14003 return _PAGE_CACHE_WC;
14004 else if (pg_flags == _PGMT_UC_MINUS)
14005 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14006 index 46fc474..b02b0f9 100644
14007 --- a/arch/x86/include/asm/checksum_32.h
14008 +++ b/arch/x86/include/asm/checksum_32.h
14009 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14010 int len, __wsum sum,
14011 int *src_err_ptr, int *dst_err_ptr);
14012
14013 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14014 + int len, __wsum sum,
14015 + int *src_err_ptr, int *dst_err_ptr);
14016 +
14017 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14018 + int len, __wsum sum,
14019 + int *src_err_ptr, int *dst_err_ptr);
14020 +
14021 /*
14022 * Note: when you get a NULL pointer exception here this means someone
14023 * passed in an incorrect kernel address to one of these functions.
14024 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14025 int *err_ptr)
14026 {
14027 might_sleep();
14028 - return csum_partial_copy_generic((__force void *)src, dst,
14029 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
14030 len, sum, err_ptr, NULL);
14031 }
14032
14033 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14034 {
14035 might_sleep();
14036 if (access_ok(VERIFY_WRITE, dst, len))
14037 - return csum_partial_copy_generic(src, (__force void *)dst,
14038 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
14039 len, sum, NULL, err_ptr);
14040
14041 if (len)
14042 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14043 index d47786a..ce1b05d 100644
14044 --- a/arch/x86/include/asm/cmpxchg.h
14045 +++ b/arch/x86/include/asm/cmpxchg.h
14046 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14047 __compiletime_error("Bad argument size for cmpxchg");
14048 extern void __xadd_wrong_size(void)
14049 __compiletime_error("Bad argument size for xadd");
14050 +extern void __xadd_check_overflow_wrong_size(void)
14051 + __compiletime_error("Bad argument size for xadd_check_overflow");
14052 extern void __add_wrong_size(void)
14053 __compiletime_error("Bad argument size for add");
14054 +extern void __add_check_overflow_wrong_size(void)
14055 + __compiletime_error("Bad argument size for add_check_overflow");
14056
14057 /*
14058 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14059 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14060 __ret; \
14061 })
14062
14063 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14064 + ({ \
14065 + __typeof__ (*(ptr)) __ret = (arg); \
14066 + switch (sizeof(*(ptr))) { \
14067 + case __X86_CASE_L: \
14068 + asm volatile (lock #op "l %0, %1\n" \
14069 + "jno 0f\n" \
14070 + "mov %0,%1\n" \
14071 + "int $4\n0:\n" \
14072 + _ASM_EXTABLE(0b, 0b) \
14073 + : "+r" (__ret), "+m" (*(ptr)) \
14074 + : : "memory", "cc"); \
14075 + break; \
14076 + case __X86_CASE_Q: \
14077 + asm volatile (lock #op "q %q0, %1\n" \
14078 + "jno 0f\n" \
14079 + "mov %0,%1\n" \
14080 + "int $4\n0:\n" \
14081 + _ASM_EXTABLE(0b, 0b) \
14082 + : "+r" (__ret), "+m" (*(ptr)) \
14083 + : : "memory", "cc"); \
14084 + break; \
14085 + default: \
14086 + __ ## op ## _check_overflow_wrong_size(); \
14087 + } \
14088 + __ret; \
14089 + })
14090 +
14091 /*
14092 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14093 * Since this is generally used to protect other memory information, we
14094 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14095 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14096 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14097
14098 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14099 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14100 +
14101 #define __add(ptr, inc, lock) \
14102 ({ \
14103 __typeof__ (*(ptr)) __ret = (inc); \
14104 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14105 index 59c6c40..5e0b22c 100644
14106 --- a/arch/x86/include/asm/compat.h
14107 +++ b/arch/x86/include/asm/compat.h
14108 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14109 typedef u32 compat_uint_t;
14110 typedef u32 compat_ulong_t;
14111 typedef u64 __attribute__((aligned(4))) compat_u64;
14112 -typedef u32 compat_uptr_t;
14113 +typedef u32 __user compat_uptr_t;
14114
14115 struct compat_timespec {
14116 compat_time_t tv_sec;
14117 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14118 index e99ac27..10d834e 100644
14119 --- a/arch/x86/include/asm/cpufeature.h
14120 +++ b/arch/x86/include/asm/cpufeature.h
14121 @@ -203,7 +203,7 @@
14122 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14123 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14124 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14125 -
14126 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14127
14128 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14129 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14130 @@ -211,7 +211,7 @@
14131 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14132 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14133 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14134 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14135 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14136 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14137 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14138 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14139 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14140 #undef cpu_has_centaur_mcr
14141 #define cpu_has_centaur_mcr 0
14142
14143 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14144 #endif /* CONFIG_X86_64 */
14145
14146 #if __GNUC__ >= 4
14147 @@ -394,7 +395,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14148 ".section .discard,\"aw\",@progbits\n"
14149 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14150 ".previous\n"
14151 - ".section .altinstr_replacement,\"ax\"\n"
14152 + ".section .altinstr_replacement,\"a\"\n"
14153 "3: movb $1,%0\n"
14154 "4:\n"
14155 ".previous\n"
14156 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14157 index 8bf1c06..b6ae785 100644
14158 --- a/arch/x86/include/asm/desc.h
14159 +++ b/arch/x86/include/asm/desc.h
14160 @@ -4,6 +4,7 @@
14161 #include <asm/desc_defs.h>
14162 #include <asm/ldt.h>
14163 #include <asm/mmu.h>
14164 +#include <asm/pgtable.h>
14165
14166 #include <linux/smp.h>
14167 #include <linux/percpu.h>
14168 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14169
14170 desc->type = (info->read_exec_only ^ 1) << 1;
14171 desc->type |= info->contents << 2;
14172 + desc->type |= info->seg_not_present ^ 1;
14173
14174 desc->s = 1;
14175 desc->dpl = 0x3;
14176 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14177 }
14178
14179 extern struct desc_ptr idt_descr;
14180 -extern gate_desc idt_table[];
14181 extern struct desc_ptr nmi_idt_descr;
14182 -extern gate_desc nmi_idt_table[];
14183 -
14184 -struct gdt_page {
14185 - struct desc_struct gdt[GDT_ENTRIES];
14186 -} __attribute__((aligned(PAGE_SIZE)));
14187 -
14188 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14189 +extern gate_desc idt_table[256];
14190 +extern gate_desc nmi_idt_table[256];
14191
14192 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14193 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14194 {
14195 - return per_cpu(gdt_page, cpu).gdt;
14196 + return cpu_gdt_table[cpu];
14197 }
14198
14199 #ifdef CONFIG_X86_64
14200 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
14201 unsigned long base, unsigned dpl, unsigned flags,
14202 unsigned short seg)
14203 {
14204 - gate->a = (seg << 16) | (base & 0xffff);
14205 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
14206 + gate->gate.offset_low = base;
14207 + gate->gate.seg = seg;
14208 + gate->gate.reserved = 0;
14209 + gate->gate.type = type;
14210 + gate->gate.s = 0;
14211 + gate->gate.dpl = dpl;
14212 + gate->gate.p = 1;
14213 + gate->gate.offset_high = base >> 16;
14214 }
14215
14216 #endif
14217 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
14218
14219 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
14220 {
14221 + pax_open_kernel();
14222 memcpy(&idt[entry], gate, sizeof(*gate));
14223 + pax_close_kernel();
14224 }
14225
14226 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
14227 {
14228 + pax_open_kernel();
14229 memcpy(&ldt[entry], desc, 8);
14230 + pax_close_kernel();
14231 }
14232
14233 static inline void
14234 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
14235 default: size = sizeof(*gdt); break;
14236 }
14237
14238 + pax_open_kernel();
14239 memcpy(&gdt[entry], desc, size);
14240 + pax_close_kernel();
14241 }
14242
14243 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
14244 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
14245
14246 static inline void native_load_tr_desc(void)
14247 {
14248 + pax_open_kernel();
14249 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
14250 + pax_close_kernel();
14251 }
14252
14253 static inline void native_load_gdt(const struct desc_ptr *dtr)
14254 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
14255 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
14256 unsigned int i;
14257
14258 + pax_open_kernel();
14259 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
14260 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
14261 + pax_close_kernel();
14262 }
14263
14264 #define _LDT_empty(info) \
14265 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
14266 preempt_enable();
14267 }
14268
14269 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
14270 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
14271 {
14272 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
14273 }
14274 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
14275 }
14276
14277 #ifdef CONFIG_X86_64
14278 -static inline void set_nmi_gate(int gate, void *addr)
14279 +static inline void set_nmi_gate(int gate, const void *addr)
14280 {
14281 gate_desc s;
14282
14283 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
14284 }
14285 #endif
14286
14287 -static inline void _set_gate(int gate, unsigned type, void *addr,
14288 +static inline void _set_gate(int gate, unsigned type, const void *addr,
14289 unsigned dpl, unsigned ist, unsigned seg)
14290 {
14291 gate_desc s;
14292 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
14293 * Pentium F0 0F bugfix can have resulted in the mapped
14294 * IDT being write-protected.
14295 */
14296 -static inline void set_intr_gate(unsigned int n, void *addr)
14297 +static inline void set_intr_gate(unsigned int n, const void *addr)
14298 {
14299 BUG_ON((unsigned)n > 0xFF);
14300 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
14301 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
14302 /*
14303 * This routine sets up an interrupt gate at directory privilege level 3.
14304 */
14305 -static inline void set_system_intr_gate(unsigned int n, void *addr)
14306 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
14307 {
14308 BUG_ON((unsigned)n > 0xFF);
14309 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
14310 }
14311
14312 -static inline void set_system_trap_gate(unsigned int n, void *addr)
14313 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
14314 {
14315 BUG_ON((unsigned)n > 0xFF);
14316 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
14317 }
14318
14319 -static inline void set_trap_gate(unsigned int n, void *addr)
14320 +static inline void set_trap_gate(unsigned int n, const void *addr)
14321 {
14322 BUG_ON((unsigned)n > 0xFF);
14323 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
14324 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
14325 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
14326 {
14327 BUG_ON((unsigned)n > 0xFF);
14328 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
14329 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
14330 }
14331
14332 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
14333 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
14334 {
14335 BUG_ON((unsigned)n > 0xFF);
14336 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
14337 }
14338
14339 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
14340 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
14341 {
14342 BUG_ON((unsigned)n > 0xFF);
14343 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
14344 }
14345
14346 +#ifdef CONFIG_X86_32
14347 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
14348 +{
14349 + struct desc_struct d;
14350 +
14351 + if (likely(limit))
14352 + limit = (limit - 1UL) >> PAGE_SHIFT;
14353 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
14354 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
14355 +}
14356 +#endif
14357 +
14358 #endif /* _ASM_X86_DESC_H */
14359 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
14360 index 278441f..b95a174 100644
14361 --- a/arch/x86/include/asm/desc_defs.h
14362 +++ b/arch/x86/include/asm/desc_defs.h
14363 @@ -31,6 +31,12 @@ struct desc_struct {
14364 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
14365 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
14366 };
14367 + struct {
14368 + u16 offset_low;
14369 + u16 seg;
14370 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
14371 + unsigned offset_high: 16;
14372 + } gate;
14373 };
14374 } __attribute__((packed));
14375
14376 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
14377 index ced283a..ffe04cc 100644
14378 --- a/arch/x86/include/asm/div64.h
14379 +++ b/arch/x86/include/asm/div64.h
14380 @@ -39,7 +39,7 @@
14381 __mod; \
14382 })
14383
14384 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
14385 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
14386 {
14387 union {
14388 u64 v64;
14389 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
14390 index 9c999c1..3860cb8 100644
14391 --- a/arch/x86/include/asm/elf.h
14392 +++ b/arch/x86/include/asm/elf.h
14393 @@ -243,7 +243,25 @@ extern int force_personality32;
14394 the loader. We need to make sure that it is out of the way of the program
14395 that it will "exec", and that there is sufficient room for the brk. */
14396
14397 +#ifdef CONFIG_PAX_SEGMEXEC
14398 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
14399 +#else
14400 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
14401 +#endif
14402 +
14403 +#ifdef CONFIG_PAX_ASLR
14404 +#ifdef CONFIG_X86_32
14405 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
14406 +
14407 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
14408 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
14409 +#else
14410 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
14411 +
14412 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
14413 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
14414 +#endif
14415 +#endif
14416
14417 /* This yields a mask that user programs can use to figure out what
14418 instruction set this CPU supports. This could be done in user space,
14419 @@ -296,16 +314,12 @@ do { \
14420
14421 #define ARCH_DLINFO \
14422 do { \
14423 - if (vdso_enabled) \
14424 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
14425 - (unsigned long)current->mm->context.vdso); \
14426 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
14427 } while (0)
14428
14429 #define ARCH_DLINFO_X32 \
14430 do { \
14431 - if (vdso_enabled) \
14432 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
14433 - (unsigned long)current->mm->context.vdso); \
14434 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
14435 } while (0)
14436
14437 #define AT_SYSINFO 32
14438 @@ -320,7 +334,7 @@ else \
14439
14440 #endif /* !CONFIG_X86_32 */
14441
14442 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
14443 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
14444
14445 #define VDSO_ENTRY \
14446 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
14447 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
14448 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
14449 #define compat_arch_setup_additional_pages syscall32_setup_pages
14450
14451 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
14452 -#define arch_randomize_brk arch_randomize_brk
14453 -
14454 /*
14455 * True on X86_32 or when emulating IA32 on X86_64
14456 */
14457 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
14458 index 75ce3f4..882e801 100644
14459 --- a/arch/x86/include/asm/emergency-restart.h
14460 +++ b/arch/x86/include/asm/emergency-restart.h
14461 @@ -13,6 +13,6 @@ enum reboot_type {
14462
14463 extern enum reboot_type reboot_type;
14464
14465 -extern void machine_emergency_restart(void);
14466 +extern void machine_emergency_restart(void) __noreturn;
14467
14468 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
14469 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
14470 index e25cc33..7d3ec01 100644
14471 --- a/arch/x86/include/asm/fpu-internal.h
14472 +++ b/arch/x86/include/asm/fpu-internal.h
14473 @@ -126,8 +126,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
14474 #define user_insn(insn, output, input...) \
14475 ({ \
14476 int err; \
14477 + pax_open_userland(); \
14478 asm volatile(ASM_STAC "\n" \
14479 - "1:" #insn "\n\t" \
14480 + "1:" \
14481 + __copyuser_seg \
14482 + #insn "\n\t" \
14483 "2: " ASM_CLAC "\n" \
14484 ".section .fixup,\"ax\"\n" \
14485 "3: movl $-1,%[err]\n" \
14486 @@ -136,6 +139,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
14487 _ASM_EXTABLE(1b, 3b) \
14488 : [err] "=r" (err), output \
14489 : "0"(0), input); \
14490 + pax_close_userland(); \
14491 err; \
14492 })
14493
14494 @@ -300,7 +304,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
14495 "emms\n\t" /* clear stack tags */
14496 "fildl %P[addr]", /* set F?P to defined value */
14497 X86_FEATURE_FXSAVE_LEAK,
14498 - [addr] "m" (tsk->thread.fpu.has_fpu));
14499 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
14500
14501 return fpu_restore_checking(&tsk->thread.fpu);
14502 }
14503 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
14504 index be27ba1..04a8801 100644
14505 --- a/arch/x86/include/asm/futex.h
14506 +++ b/arch/x86/include/asm/futex.h
14507 @@ -12,6 +12,7 @@
14508 #include <asm/smap.h>
14509
14510 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
14511 + typecheck(u32 __user *, uaddr); \
14512 asm volatile("\t" ASM_STAC "\n" \
14513 "1:\t" insn "\n" \
14514 "2:\t" ASM_CLAC "\n" \
14515 @@ -20,15 +21,16 @@
14516 "\tjmp\t2b\n" \
14517 "\t.previous\n" \
14518 _ASM_EXTABLE(1b, 3b) \
14519 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
14520 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
14521 : "i" (-EFAULT), "0" (oparg), "1" (0))
14522
14523 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
14524 + typecheck(u32 __user *, uaddr); \
14525 asm volatile("\t" ASM_STAC "\n" \
14526 "1:\tmovl %2, %0\n" \
14527 "\tmovl\t%0, %3\n" \
14528 "\t" insn "\n" \
14529 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
14530 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
14531 "\tjnz\t1b\n" \
14532 "3:\t" ASM_CLAC "\n" \
14533 "\t.section .fixup,\"ax\"\n" \
14534 @@ -38,7 +40,7 @@
14535 _ASM_EXTABLE(1b, 4b) \
14536 _ASM_EXTABLE(2b, 4b) \
14537 : "=&a" (oldval), "=&r" (ret), \
14538 - "+m" (*uaddr), "=&r" (tem) \
14539 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
14540 : "r" (oparg), "i" (-EFAULT), "1" (0))
14541
14542 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
14543 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
14544
14545 pagefault_disable();
14546
14547 + pax_open_userland();
14548 switch (op) {
14549 case FUTEX_OP_SET:
14550 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
14551 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
14552 break;
14553 case FUTEX_OP_ADD:
14554 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
14555 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
14556 uaddr, oparg);
14557 break;
14558 case FUTEX_OP_OR:
14559 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
14560 default:
14561 ret = -ENOSYS;
14562 }
14563 + pax_close_userland();
14564
14565 pagefault_enable();
14566
14567 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
14568 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
14569 return -EFAULT;
14570
14571 + pax_open_userland();
14572 asm volatile("\t" ASM_STAC "\n"
14573 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
14574 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
14575 "2:\t" ASM_CLAC "\n"
14576 "\t.section .fixup, \"ax\"\n"
14577 "3:\tmov %3, %0\n"
14578 "\tjmp 2b\n"
14579 "\t.previous\n"
14580 _ASM_EXTABLE(1b, 3b)
14581 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
14582 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
14583 : "i" (-EFAULT), "r" (newval), "1" (oldval)
14584 : "memory"
14585 );
14586 + pax_close_userland();
14587
14588 *uval = oldval;
14589 return ret;
14590 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
14591 index 1da97ef..9c2ebff 100644
14592 --- a/arch/x86/include/asm/hw_irq.h
14593 +++ b/arch/x86/include/asm/hw_irq.h
14594 @@ -148,8 +148,8 @@ extern void setup_ioapic_dest(void);
14595 extern void enable_IO_APIC(void);
14596
14597 /* Statistics */
14598 -extern atomic_t irq_err_count;
14599 -extern atomic_t irq_mis_count;
14600 +extern atomic_unchecked_t irq_err_count;
14601 +extern atomic_unchecked_t irq_mis_count;
14602
14603 /* EISA */
14604 extern void eisa_set_level_irq(unsigned int irq);
14605 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
14606 index a203659..9889f1c 100644
14607 --- a/arch/x86/include/asm/i8259.h
14608 +++ b/arch/x86/include/asm/i8259.h
14609 @@ -62,7 +62,7 @@ struct legacy_pic {
14610 void (*init)(int auto_eoi);
14611 int (*irq_pending)(unsigned int irq);
14612 void (*make_irq)(unsigned int irq);
14613 -};
14614 +} __do_const;
14615
14616 extern struct legacy_pic *legacy_pic;
14617 extern struct legacy_pic null_legacy_pic;
14618 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
14619 index d8e8eef..1765f78 100644
14620 --- a/arch/x86/include/asm/io.h
14621 +++ b/arch/x86/include/asm/io.h
14622 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
14623 "m" (*(volatile type __force *)addr) barrier); }
14624
14625 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
14626 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
14627 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
14628 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
14629 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
14630
14631 build_mmio_read(__readb, "b", unsigned char, "=q", )
14632 -build_mmio_read(__readw, "w", unsigned short, "=r", )
14633 -build_mmio_read(__readl, "l", unsigned int, "=r", )
14634 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
14635 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
14636
14637 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
14638 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
14639 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
14640 return ioremap_nocache(offset, size);
14641 }
14642
14643 -extern void iounmap(volatile void __iomem *addr);
14644 +extern void iounmap(const volatile void __iomem *addr);
14645
14646 extern void set_iounmap_nonlazy(void);
14647
14648 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
14649
14650 #include <linux/vmalloc.h>
14651
14652 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
14653 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
14654 +{
14655 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
14656 +}
14657 +
14658 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
14659 +{
14660 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
14661 +}
14662 +
14663 /*
14664 * Convert a virtual cached pointer to an uncached pointer
14665 */
14666 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
14667 index bba3cf8..06bc8da 100644
14668 --- a/arch/x86/include/asm/irqflags.h
14669 +++ b/arch/x86/include/asm/irqflags.h
14670 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
14671 sti; \
14672 sysexit
14673
14674 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
14675 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
14676 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
14677 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
14678 +
14679 #else
14680 #define INTERRUPT_RETURN iret
14681 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
14682 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
14683 index 5a6d287..f815789 100644
14684 --- a/arch/x86/include/asm/kprobes.h
14685 +++ b/arch/x86/include/asm/kprobes.h
14686 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
14687 #define RELATIVEJUMP_SIZE 5
14688 #define RELATIVECALL_OPCODE 0xe8
14689 #define RELATIVE_ADDR_SIZE 4
14690 -#define MAX_STACK_SIZE 64
14691 -#define MIN_STACK_SIZE(ADDR) \
14692 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
14693 - THREAD_SIZE - (unsigned long)(ADDR))) \
14694 - ? (MAX_STACK_SIZE) \
14695 - : (((unsigned long)current_thread_info()) + \
14696 - THREAD_SIZE - (unsigned long)(ADDR)))
14697 +#define MAX_STACK_SIZE 64UL
14698 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
14699
14700 #define flush_insn_slot(p) do { } while (0)
14701
14702 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
14703 index 2d89e39..baee879 100644
14704 --- a/arch/x86/include/asm/local.h
14705 +++ b/arch/x86/include/asm/local.h
14706 @@ -10,33 +10,97 @@ typedef struct {
14707 atomic_long_t a;
14708 } local_t;
14709
14710 +typedef struct {
14711 + atomic_long_unchecked_t a;
14712 +} local_unchecked_t;
14713 +
14714 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
14715
14716 #define local_read(l) atomic_long_read(&(l)->a)
14717 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
14718 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
14719 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
14720
14721 static inline void local_inc(local_t *l)
14722 {
14723 - asm volatile(_ASM_INC "%0"
14724 + asm volatile(_ASM_INC "%0\n"
14725 +
14726 +#ifdef CONFIG_PAX_REFCOUNT
14727 + "jno 0f\n"
14728 + _ASM_DEC "%0\n"
14729 + "int $4\n0:\n"
14730 + _ASM_EXTABLE(0b, 0b)
14731 +#endif
14732 +
14733 + : "+m" (l->a.counter));
14734 +}
14735 +
14736 +static inline void local_inc_unchecked(local_unchecked_t *l)
14737 +{
14738 + asm volatile(_ASM_INC "%0\n"
14739 : "+m" (l->a.counter));
14740 }
14741
14742 static inline void local_dec(local_t *l)
14743 {
14744 - asm volatile(_ASM_DEC "%0"
14745 + asm volatile(_ASM_DEC "%0\n"
14746 +
14747 +#ifdef CONFIG_PAX_REFCOUNT
14748 + "jno 0f\n"
14749 + _ASM_INC "%0\n"
14750 + "int $4\n0:\n"
14751 + _ASM_EXTABLE(0b, 0b)
14752 +#endif
14753 +
14754 + : "+m" (l->a.counter));
14755 +}
14756 +
14757 +static inline void local_dec_unchecked(local_unchecked_t *l)
14758 +{
14759 + asm volatile(_ASM_DEC "%0\n"
14760 : "+m" (l->a.counter));
14761 }
14762
14763 static inline void local_add(long i, local_t *l)
14764 {
14765 - asm volatile(_ASM_ADD "%1,%0"
14766 + asm volatile(_ASM_ADD "%1,%0\n"
14767 +
14768 +#ifdef CONFIG_PAX_REFCOUNT
14769 + "jno 0f\n"
14770 + _ASM_SUB "%1,%0\n"
14771 + "int $4\n0:\n"
14772 + _ASM_EXTABLE(0b, 0b)
14773 +#endif
14774 +
14775 + : "+m" (l->a.counter)
14776 + : "ir" (i));
14777 +}
14778 +
14779 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
14780 +{
14781 + asm volatile(_ASM_ADD "%1,%0\n"
14782 : "+m" (l->a.counter)
14783 : "ir" (i));
14784 }
14785
14786 static inline void local_sub(long i, local_t *l)
14787 {
14788 - asm volatile(_ASM_SUB "%1,%0"
14789 + asm volatile(_ASM_SUB "%1,%0\n"
14790 +
14791 +#ifdef CONFIG_PAX_REFCOUNT
14792 + "jno 0f\n"
14793 + _ASM_ADD "%1,%0\n"
14794 + "int $4\n0:\n"
14795 + _ASM_EXTABLE(0b, 0b)
14796 +#endif
14797 +
14798 + : "+m" (l->a.counter)
14799 + : "ir" (i));
14800 +}
14801 +
14802 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
14803 +{
14804 + asm volatile(_ASM_SUB "%1,%0\n"
14805 : "+m" (l->a.counter)
14806 : "ir" (i));
14807 }
14808 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
14809 {
14810 unsigned char c;
14811
14812 - asm volatile(_ASM_SUB "%2,%0; sete %1"
14813 + asm volatile(_ASM_SUB "%2,%0\n"
14814 +
14815 +#ifdef CONFIG_PAX_REFCOUNT
14816 + "jno 0f\n"
14817 + _ASM_ADD "%2,%0\n"
14818 + "int $4\n0:\n"
14819 + _ASM_EXTABLE(0b, 0b)
14820 +#endif
14821 +
14822 + "sete %1\n"
14823 : "+m" (l->a.counter), "=qm" (c)
14824 : "ir" (i) : "memory");
14825 return c;
14826 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
14827 {
14828 unsigned char c;
14829
14830 - asm volatile(_ASM_DEC "%0; sete %1"
14831 + asm volatile(_ASM_DEC "%0\n"
14832 +
14833 +#ifdef CONFIG_PAX_REFCOUNT
14834 + "jno 0f\n"
14835 + _ASM_INC "%0\n"
14836 + "int $4\n0:\n"
14837 + _ASM_EXTABLE(0b, 0b)
14838 +#endif
14839 +
14840 + "sete %1\n"
14841 : "+m" (l->a.counter), "=qm" (c)
14842 : : "memory");
14843 return c != 0;
14844 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
14845 {
14846 unsigned char c;
14847
14848 - asm volatile(_ASM_INC "%0; sete %1"
14849 + asm volatile(_ASM_INC "%0\n"
14850 +
14851 +#ifdef CONFIG_PAX_REFCOUNT
14852 + "jno 0f\n"
14853 + _ASM_DEC "%0\n"
14854 + "int $4\n0:\n"
14855 + _ASM_EXTABLE(0b, 0b)
14856 +#endif
14857 +
14858 + "sete %1\n"
14859 : "+m" (l->a.counter), "=qm" (c)
14860 : : "memory");
14861 return c != 0;
14862 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
14863 {
14864 unsigned char c;
14865
14866 - asm volatile(_ASM_ADD "%2,%0; sets %1"
14867 + asm volatile(_ASM_ADD "%2,%0\n"
14868 +
14869 +#ifdef CONFIG_PAX_REFCOUNT
14870 + "jno 0f\n"
14871 + _ASM_SUB "%2,%0\n"
14872 + "int $4\n0:\n"
14873 + _ASM_EXTABLE(0b, 0b)
14874 +#endif
14875 +
14876 + "sets %1\n"
14877 : "+m" (l->a.counter), "=qm" (c)
14878 : "ir" (i) : "memory");
14879 return c;
14880 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
14881 static inline long local_add_return(long i, local_t *l)
14882 {
14883 long __i = i;
14884 + asm volatile(_ASM_XADD "%0, %1\n"
14885 +
14886 +#ifdef CONFIG_PAX_REFCOUNT
14887 + "jno 0f\n"
14888 + _ASM_MOV "%0,%1\n"
14889 + "int $4\n0:\n"
14890 + _ASM_EXTABLE(0b, 0b)
14891 +#endif
14892 +
14893 + : "+r" (i), "+m" (l->a.counter)
14894 + : : "memory");
14895 + return i + __i;
14896 +}
14897 +
14898 +/**
14899 + * local_add_return_unchecked - add and return
14900 + * @i: integer value to add
14901 + * @l: pointer to type local_unchecked_t
14902 + *
14903 + * Atomically adds @i to @l and returns @i + @l
14904 + */
14905 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
14906 +{
14907 + long __i = i;
14908 asm volatile(_ASM_XADD "%0, %1;"
14909 : "+r" (i), "+m" (l->a.counter)
14910 : : "memory");
14911 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
14912
14913 #define local_cmpxchg(l, o, n) \
14914 (cmpxchg_local(&((l)->a.counter), (o), (n)))
14915 +#define local_cmpxchg_unchecked(l, o, n) \
14916 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
14917 /* Always has a lock prefix */
14918 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
14919
14920 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
14921 new file mode 100644
14922 index 0000000..2bfd3ba
14923 --- /dev/null
14924 +++ b/arch/x86/include/asm/mman.h
14925 @@ -0,0 +1,15 @@
14926 +#ifndef _X86_MMAN_H
14927 +#define _X86_MMAN_H
14928 +
14929 +#include <uapi/asm/mman.h>
14930 +
14931 +#ifdef __KERNEL__
14932 +#ifndef __ASSEMBLY__
14933 +#ifdef CONFIG_X86_32
14934 +#define arch_mmap_check i386_mmap_check
14935 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
14936 +#endif
14937 +#endif
14938 +#endif
14939 +
14940 +#endif /* X86_MMAN_H */
14941 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
14942 index 5f55e69..e20bfb1 100644
14943 --- a/arch/x86/include/asm/mmu.h
14944 +++ b/arch/x86/include/asm/mmu.h
14945 @@ -9,7 +9,7 @@
14946 * we put the segment information here.
14947 */
14948 typedef struct {
14949 - void *ldt;
14950 + struct desc_struct *ldt;
14951 int size;
14952
14953 #ifdef CONFIG_X86_64
14954 @@ -18,7 +18,19 @@ typedef struct {
14955 #endif
14956
14957 struct mutex lock;
14958 - void *vdso;
14959 + unsigned long vdso;
14960 +
14961 +#ifdef CONFIG_X86_32
14962 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
14963 + unsigned long user_cs_base;
14964 + unsigned long user_cs_limit;
14965 +
14966 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14967 + cpumask_t cpu_user_cs_mask;
14968 +#endif
14969 +
14970 +#endif
14971 +#endif
14972 } mm_context_t;
14973
14974 #ifdef CONFIG_SMP
14975 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
14976 index cdbf367..4c73c9e 100644
14977 --- a/arch/x86/include/asm/mmu_context.h
14978 +++ b/arch/x86/include/asm/mmu_context.h
14979 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
14980
14981 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
14982 {
14983 +
14984 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14985 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
14986 + unsigned int i;
14987 + pgd_t *pgd;
14988 +
14989 + pax_open_kernel();
14990 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
14991 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
14992 + set_pgd_batched(pgd+i, native_make_pgd(0));
14993 + pax_close_kernel();
14994 + }
14995 +#endif
14996 +
14997 #ifdef CONFIG_SMP
14998 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
14999 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15000 @@ -34,16 +48,55 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15001 struct task_struct *tsk)
15002 {
15003 unsigned cpu = smp_processor_id();
15004 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15005 + int tlbstate = TLBSTATE_OK;
15006 +#endif
15007
15008 if (likely(prev != next)) {
15009 #ifdef CONFIG_SMP
15010 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15011 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15012 +#endif
15013 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15014 this_cpu_write(cpu_tlbstate.active_mm, next);
15015 #endif
15016 cpumask_set_cpu(cpu, mm_cpumask(next));
15017
15018 /* Re-load page tables */
15019 +#ifdef CONFIG_PAX_PER_CPU_PGD
15020 + pax_open_kernel();
15021 +
15022 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15023 + if (static_cpu_has(X86_FEATURE_PCID))
15024 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15025 + else
15026 +#endif
15027 +
15028 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15029 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15030 + pax_close_kernel();
15031 + 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));
15032 +
15033 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15034 + if (static_cpu_has(X86_FEATURE_PCID)) {
15035 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15036 + unsigned long descriptor[2];
15037 + descriptor[0] = PCID_USER;
15038 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15039 + } else {
15040 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15041 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15042 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15043 + else
15044 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15045 + }
15046 + } else
15047 +#endif
15048 +
15049 + load_cr3(get_cpu_pgd(cpu, kernel));
15050 +#else
15051 load_cr3(next->pgd);
15052 +#endif
15053
15054 /* stop flush ipis for the previous mm */
15055 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15056 @@ -53,9 +106,63 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15057 */
15058 if (unlikely(prev->context.ldt != next->context.ldt))
15059 load_LDT_nolock(&next->context);
15060 - }
15061 +
15062 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15063 + if (!(__supported_pte_mask & _PAGE_NX)) {
15064 + smp_mb__before_clear_bit();
15065 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15066 + smp_mb__after_clear_bit();
15067 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15068 + }
15069 +#endif
15070 +
15071 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15072 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15073 + prev->context.user_cs_limit != next->context.user_cs_limit))
15074 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15075 #ifdef CONFIG_SMP
15076 + else if (unlikely(tlbstate != TLBSTATE_OK))
15077 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15078 +#endif
15079 +#endif
15080 +
15081 + }
15082 else {
15083 +
15084 +#ifdef CONFIG_PAX_PER_CPU_PGD
15085 + pax_open_kernel();
15086 +
15087 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15088 + if (static_cpu_has(X86_FEATURE_PCID))
15089 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15090 + else
15091 +#endif
15092 +
15093 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15094 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15095 + pax_close_kernel();
15096 + 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));
15097 +
15098 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15099 + if (static_cpu_has(X86_FEATURE_PCID)) {
15100 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15101 + unsigned long descriptor[2];
15102 + descriptor[0] = PCID_USER;
15103 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15104 + } else {
15105 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15106 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15107 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15108 + else
15109 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15110 + }
15111 + } else
15112 +#endif
15113 +
15114 + load_cr3(get_cpu_pgd(cpu, kernel));
15115 +#endif
15116 +
15117 +#ifdef CONFIG_SMP
15118 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15119 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15120
15121 @@ -64,11 +171,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15122 * tlb flush IPI delivery. We must reload CR3
15123 * to make sure to use no freed page tables.
15124 */
15125 +
15126 +#ifndef CONFIG_PAX_PER_CPU_PGD
15127 load_cr3(next->pgd);
15128 +#endif
15129 +
15130 load_LDT_nolock(&next->context);
15131 +
15132 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15133 + if (!(__supported_pte_mask & _PAGE_NX))
15134 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15135 +#endif
15136 +
15137 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15138 +#ifdef CONFIG_PAX_PAGEEXEC
15139 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15140 +#endif
15141 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15142 +#endif
15143 +
15144 }
15145 +#endif
15146 }
15147 -#endif
15148 }
15149
15150 #define activate_mm(prev, next) \
15151 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15152 index e3b7819..b257c64 100644
15153 --- a/arch/x86/include/asm/module.h
15154 +++ b/arch/x86/include/asm/module.h
15155 @@ -5,6 +5,7 @@
15156
15157 #ifdef CONFIG_X86_64
15158 /* X86_64 does not define MODULE_PROC_FAMILY */
15159 +#define MODULE_PROC_FAMILY ""
15160 #elif defined CONFIG_M486
15161 #define MODULE_PROC_FAMILY "486 "
15162 #elif defined CONFIG_M586
15163 @@ -57,8 +58,20 @@
15164 #error unknown processor family
15165 #endif
15166
15167 -#ifdef CONFIG_X86_32
15168 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
15169 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
15170 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
15171 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
15172 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
15173 +#else
15174 +#define MODULE_PAX_KERNEXEC ""
15175 #endif
15176
15177 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15178 +#define MODULE_PAX_UDEREF "UDEREF "
15179 +#else
15180 +#define MODULE_PAX_UDEREF ""
15181 +#endif
15182 +
15183 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
15184 +
15185 #endif /* _ASM_X86_MODULE_H */
15186 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
15187 index 86f9301..b365cda 100644
15188 --- a/arch/x86/include/asm/nmi.h
15189 +++ b/arch/x86/include/asm/nmi.h
15190 @@ -40,11 +40,11 @@ struct nmiaction {
15191 nmi_handler_t handler;
15192 unsigned long flags;
15193 const char *name;
15194 -};
15195 +} __do_const;
15196
15197 #define register_nmi_handler(t, fn, fg, n, init...) \
15198 ({ \
15199 - static struct nmiaction init fn##_na = { \
15200 + static const struct nmiaction init fn##_na = { \
15201 .handler = (fn), \
15202 .name = (n), \
15203 .flags = (fg), \
15204 @@ -52,7 +52,7 @@ struct nmiaction {
15205 __register_nmi_handler((t), &fn##_na); \
15206 })
15207
15208 -int __register_nmi_handler(unsigned int, struct nmiaction *);
15209 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
15210
15211 void unregister_nmi_handler(unsigned int, const char *);
15212
15213 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
15214 index c878924..21f4889 100644
15215 --- a/arch/x86/include/asm/page.h
15216 +++ b/arch/x86/include/asm/page.h
15217 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
15218 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
15219
15220 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
15221 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
15222
15223 #define __boot_va(x) __va(x)
15224 #define __boot_pa(x) __pa(x)
15225 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
15226 index 0f1ddee..e2fc3d1 100644
15227 --- a/arch/x86/include/asm/page_64.h
15228 +++ b/arch/x86/include/asm/page_64.h
15229 @@ -7,9 +7,9 @@
15230
15231 /* duplicated to the one in bootmem.h */
15232 extern unsigned long max_pfn;
15233 -extern unsigned long phys_base;
15234 +extern const unsigned long phys_base;
15235
15236 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
15237 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
15238 {
15239 unsigned long y = x - __START_KERNEL_map;
15240
15241 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
15242 index cfdc9ee..3f7b5d6 100644
15243 --- a/arch/x86/include/asm/paravirt.h
15244 +++ b/arch/x86/include/asm/paravirt.h
15245 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
15246 return (pmd_t) { ret };
15247 }
15248
15249 -static inline pmdval_t pmd_val(pmd_t pmd)
15250 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
15251 {
15252 pmdval_t ret;
15253
15254 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
15255 val);
15256 }
15257
15258 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
15259 +{
15260 + pgdval_t val = native_pgd_val(pgd);
15261 +
15262 + if (sizeof(pgdval_t) > sizeof(long))
15263 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
15264 + val, (u64)val >> 32);
15265 + else
15266 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
15267 + val);
15268 +}
15269 +
15270 static inline void pgd_clear(pgd_t *pgdp)
15271 {
15272 set_pgd(pgdp, __pgd(0));
15273 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
15274 pv_mmu_ops.set_fixmap(idx, phys, flags);
15275 }
15276
15277 +#ifdef CONFIG_PAX_KERNEXEC
15278 +static inline unsigned long pax_open_kernel(void)
15279 +{
15280 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
15281 +}
15282 +
15283 +static inline unsigned long pax_close_kernel(void)
15284 +{
15285 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
15286 +}
15287 +#else
15288 +static inline unsigned long pax_open_kernel(void) { return 0; }
15289 +static inline unsigned long pax_close_kernel(void) { return 0; }
15290 +#endif
15291 +
15292 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
15293
15294 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
15295 @@ -926,7 +953,7 @@ extern void default_banner(void);
15296
15297 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
15298 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
15299 -#define PARA_INDIRECT(addr) *%cs:addr
15300 +#define PARA_INDIRECT(addr) *%ss:addr
15301 #endif
15302
15303 #define INTERRUPT_RETURN \
15304 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
15305 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
15306 CLBR_NONE, \
15307 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
15308 +
15309 +#define GET_CR0_INTO_RDI \
15310 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
15311 + mov %rax,%rdi
15312 +
15313 +#define SET_RDI_INTO_CR0 \
15314 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
15315 +
15316 +#define GET_CR3_INTO_RDI \
15317 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
15318 + mov %rax,%rdi
15319 +
15320 +#define SET_RDI_INTO_CR3 \
15321 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
15322 +
15323 #endif /* CONFIG_X86_32 */
15324
15325 #endif /* __ASSEMBLY__ */
15326 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
15327 index 0db1fca..52310cc 100644
15328 --- a/arch/x86/include/asm/paravirt_types.h
15329 +++ b/arch/x86/include/asm/paravirt_types.h
15330 @@ -84,7 +84,7 @@ struct pv_init_ops {
15331 */
15332 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
15333 unsigned long addr, unsigned len);
15334 -};
15335 +} __no_const;
15336
15337
15338 struct pv_lazy_ops {
15339 @@ -98,7 +98,7 @@ struct pv_time_ops {
15340 unsigned long long (*sched_clock)(void);
15341 unsigned long long (*steal_clock)(int cpu);
15342 unsigned long (*get_tsc_khz)(void);
15343 -};
15344 +} __no_const;
15345
15346 struct pv_cpu_ops {
15347 /* hooks for various privileged instructions */
15348 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
15349
15350 void (*start_context_switch)(struct task_struct *prev);
15351 void (*end_context_switch)(struct task_struct *next);
15352 -};
15353 +} __no_const;
15354
15355 struct pv_irq_ops {
15356 /*
15357 @@ -223,7 +223,7 @@ struct pv_apic_ops {
15358 unsigned long start_eip,
15359 unsigned long start_esp);
15360 #endif
15361 -};
15362 +} __no_const;
15363
15364 struct pv_mmu_ops {
15365 unsigned long (*read_cr2)(void);
15366 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
15367 struct paravirt_callee_save make_pud;
15368
15369 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
15370 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
15371 #endif /* PAGETABLE_LEVELS == 4 */
15372 #endif /* PAGETABLE_LEVELS >= 3 */
15373
15374 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
15375 an mfn. We can tell which is which from the index. */
15376 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
15377 phys_addr_t phys, pgprot_t flags);
15378 +
15379 +#ifdef CONFIG_PAX_KERNEXEC
15380 + unsigned long (*pax_open_kernel)(void);
15381 + unsigned long (*pax_close_kernel)(void);
15382 +#endif
15383 +
15384 };
15385
15386 struct arch_spinlock;
15387 @@ -334,7 +341,7 @@ struct pv_lock_ops {
15388 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
15389 int (*spin_trylock)(struct arch_spinlock *lock);
15390 void (*spin_unlock)(struct arch_spinlock *lock);
15391 -};
15392 +} __no_const;
15393
15394 /* This contains all the paravirt structures: we get a convenient
15395 * number for each function using the offset which we use to indicate
15396 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
15397 index b4389a4..7024269 100644
15398 --- a/arch/x86/include/asm/pgalloc.h
15399 +++ b/arch/x86/include/asm/pgalloc.h
15400 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
15401 pmd_t *pmd, pte_t *pte)
15402 {
15403 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
15404 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
15405 +}
15406 +
15407 +static inline void pmd_populate_user(struct mm_struct *mm,
15408 + pmd_t *pmd, pte_t *pte)
15409 +{
15410 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
15411 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
15412 }
15413
15414 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
15415
15416 #ifdef CONFIG_X86_PAE
15417 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
15418 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
15419 +{
15420 + pud_populate(mm, pudp, pmd);
15421 +}
15422 #else /* !CONFIG_X86_PAE */
15423 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
15424 {
15425 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
15426 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
15427 }
15428 +
15429 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
15430 +{
15431 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
15432 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
15433 +}
15434 #endif /* CONFIG_X86_PAE */
15435
15436 #if PAGETABLE_LEVELS > 3
15437 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
15438 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
15439 }
15440
15441 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
15442 +{
15443 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
15444 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
15445 +}
15446 +
15447 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
15448 {
15449 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
15450 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
15451 index f2b489c..4f7e2e5 100644
15452 --- a/arch/x86/include/asm/pgtable-2level.h
15453 +++ b/arch/x86/include/asm/pgtable-2level.h
15454 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
15455
15456 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
15457 {
15458 + pax_open_kernel();
15459 *pmdp = pmd;
15460 + pax_close_kernel();
15461 }
15462
15463 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
15464 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
15465 index 4cc9f2b..5fd9226 100644
15466 --- a/arch/x86/include/asm/pgtable-3level.h
15467 +++ b/arch/x86/include/asm/pgtable-3level.h
15468 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
15469
15470 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
15471 {
15472 + pax_open_kernel();
15473 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
15474 + pax_close_kernel();
15475 }
15476
15477 static inline void native_set_pud(pud_t *pudp, pud_t pud)
15478 {
15479 + pax_open_kernel();
15480 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
15481 + pax_close_kernel();
15482 }
15483
15484 /*
15485 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
15486 index 1e67223..92a9585 100644
15487 --- a/arch/x86/include/asm/pgtable.h
15488 +++ b/arch/x86/include/asm/pgtable.h
15489 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
15490
15491 #ifndef __PAGETABLE_PUD_FOLDED
15492 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
15493 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
15494 #define pgd_clear(pgd) native_pgd_clear(pgd)
15495 #endif
15496
15497 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
15498
15499 #define arch_end_context_switch(prev) do {} while(0)
15500
15501 +#define pax_open_kernel() native_pax_open_kernel()
15502 +#define pax_close_kernel() native_pax_close_kernel()
15503 #endif /* CONFIG_PARAVIRT */
15504
15505 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
15506 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
15507 +
15508 +#ifdef CONFIG_PAX_KERNEXEC
15509 +static inline unsigned long native_pax_open_kernel(void)
15510 +{
15511 + unsigned long cr0;
15512 +
15513 + preempt_disable();
15514 + barrier();
15515 + cr0 = read_cr0() ^ X86_CR0_WP;
15516 + BUG_ON(cr0 & X86_CR0_WP);
15517 + write_cr0(cr0);
15518 + return cr0 ^ X86_CR0_WP;
15519 +}
15520 +
15521 +static inline unsigned long native_pax_close_kernel(void)
15522 +{
15523 + unsigned long cr0;
15524 +
15525 + cr0 = read_cr0() ^ X86_CR0_WP;
15526 + BUG_ON(!(cr0 & X86_CR0_WP));
15527 + write_cr0(cr0);
15528 + barrier();
15529 + preempt_enable_no_resched();
15530 + return cr0 ^ X86_CR0_WP;
15531 +}
15532 +#else
15533 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
15534 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
15535 +#endif
15536 +
15537 /*
15538 * The following only work if pte_present() is true.
15539 * Undefined behaviour if not..
15540 */
15541 +static inline int pte_user(pte_t pte)
15542 +{
15543 + return pte_val(pte) & _PAGE_USER;
15544 +}
15545 +
15546 static inline int pte_dirty(pte_t pte)
15547 {
15548 return pte_flags(pte) & _PAGE_DIRTY;
15549 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
15550 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
15551 }
15552
15553 +static inline unsigned long pgd_pfn(pgd_t pgd)
15554 +{
15555 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
15556 +}
15557 +
15558 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
15559
15560 static inline int pmd_large(pmd_t pte)
15561 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
15562 return pte_clear_flags(pte, _PAGE_RW);
15563 }
15564
15565 +static inline pte_t pte_mkread(pte_t pte)
15566 +{
15567 + return __pte(pte_val(pte) | _PAGE_USER);
15568 +}
15569 +
15570 static inline pte_t pte_mkexec(pte_t pte)
15571 {
15572 - return pte_clear_flags(pte, _PAGE_NX);
15573 +#ifdef CONFIG_X86_PAE
15574 + if (__supported_pte_mask & _PAGE_NX)
15575 + return pte_clear_flags(pte, _PAGE_NX);
15576 + else
15577 +#endif
15578 + return pte_set_flags(pte, _PAGE_USER);
15579 +}
15580 +
15581 +static inline pte_t pte_exprotect(pte_t pte)
15582 +{
15583 +#ifdef CONFIG_X86_PAE
15584 + if (__supported_pte_mask & _PAGE_NX)
15585 + return pte_set_flags(pte, _PAGE_NX);
15586 + else
15587 +#endif
15588 + return pte_clear_flags(pte, _PAGE_USER);
15589 }
15590
15591 static inline pte_t pte_mkdirty(pte_t pte)
15592 @@ -394,6 +459,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
15593 #endif
15594
15595 #ifndef __ASSEMBLY__
15596 +
15597 +#ifdef CONFIG_PAX_PER_CPU_PGD
15598 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
15599 +enum cpu_pgd_type {kernel = 0, user = 1};
15600 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
15601 +{
15602 + return cpu_pgd[cpu][type];
15603 +}
15604 +#endif
15605 +
15606 #include <linux/mm_types.h>
15607 #include <linux/log2.h>
15608
15609 @@ -529,7 +604,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
15610 * Currently stuck as a macro due to indirect forward reference to
15611 * linux/mmzone.h's __section_mem_map_addr() definition:
15612 */
15613 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
15614 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
15615
15616 /* Find an entry in the second-level page table.. */
15617 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
15618 @@ -569,7 +644,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
15619 * Currently stuck as a macro due to indirect forward reference to
15620 * linux/mmzone.h's __section_mem_map_addr() definition:
15621 */
15622 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
15623 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
15624
15625 /* to find an entry in a page-table-directory. */
15626 static inline unsigned long pud_index(unsigned long address)
15627 @@ -584,7 +659,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
15628
15629 static inline int pgd_bad(pgd_t pgd)
15630 {
15631 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
15632 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
15633 }
15634
15635 static inline int pgd_none(pgd_t pgd)
15636 @@ -607,7 +682,12 @@ static inline int pgd_none(pgd_t pgd)
15637 * pgd_offset() returns a (pgd_t *)
15638 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
15639 */
15640 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
15641 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
15642 +
15643 +#ifdef CONFIG_PAX_PER_CPU_PGD
15644 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
15645 +#endif
15646 +
15647 /*
15648 * a shortcut which implies the use of the kernel's pgd, instead
15649 * of a process's
15650 @@ -618,6 +698,23 @@ static inline int pgd_none(pgd_t pgd)
15651 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
15652 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
15653
15654 +#ifdef CONFIG_X86_32
15655 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
15656 +#else
15657 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
15658 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
15659 +
15660 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15661 +#ifdef __ASSEMBLY__
15662 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
15663 +#else
15664 +extern unsigned long pax_user_shadow_base;
15665 +extern pgdval_t clone_pgd_mask;
15666 +#endif
15667 +#endif
15668 +
15669 +#endif
15670 +
15671 #ifndef __ASSEMBLY__
15672
15673 extern int direct_gbpages;
15674 @@ -784,11 +881,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
15675 * dst and src can be on the same page, but the range must not overlap,
15676 * and must not cross a page boundary.
15677 */
15678 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
15679 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
15680 {
15681 - memcpy(dst, src, count * sizeof(pgd_t));
15682 + pax_open_kernel();
15683 + while (count--)
15684 + *dst++ = *src++;
15685 + pax_close_kernel();
15686 }
15687
15688 +#ifdef CONFIG_PAX_PER_CPU_PGD
15689 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
15690 +#endif
15691 +
15692 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15693 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
15694 +#else
15695 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
15696 +#endif
15697 +
15698 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
15699 static inline int page_level_shift(enum pg_level level)
15700 {
15701 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
15702 index 9ee3221..b979c6b 100644
15703 --- a/arch/x86/include/asm/pgtable_32.h
15704 +++ b/arch/x86/include/asm/pgtable_32.h
15705 @@ -25,9 +25,6 @@
15706 struct mm_struct;
15707 struct vm_area_struct;
15708
15709 -extern pgd_t swapper_pg_dir[1024];
15710 -extern pgd_t initial_page_table[1024];
15711 -
15712 static inline void pgtable_cache_init(void) { }
15713 static inline void check_pgt_cache(void) { }
15714 void paging_init(void);
15715 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
15716 # include <asm/pgtable-2level.h>
15717 #endif
15718
15719 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
15720 +extern pgd_t initial_page_table[PTRS_PER_PGD];
15721 +#ifdef CONFIG_X86_PAE
15722 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
15723 +#endif
15724 +
15725 #if defined(CONFIG_HIGHPTE)
15726 #define pte_offset_map(dir, address) \
15727 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
15728 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
15729 /* Clear a kernel PTE and flush it from the TLB */
15730 #define kpte_clear_flush(ptep, vaddr) \
15731 do { \
15732 + pax_open_kernel(); \
15733 pte_clear(&init_mm, (vaddr), (ptep)); \
15734 + pax_close_kernel(); \
15735 __flush_tlb_one((vaddr)); \
15736 } while (0)
15737
15738 #endif /* !__ASSEMBLY__ */
15739
15740 +#define HAVE_ARCH_UNMAPPED_AREA
15741 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
15742 +
15743 /*
15744 * kern_addr_valid() is (1) for FLATMEM and (0) for
15745 * SPARSEMEM and DISCONTIGMEM
15746 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
15747 index ed5903b..c7fe163 100644
15748 --- a/arch/x86/include/asm/pgtable_32_types.h
15749 +++ b/arch/x86/include/asm/pgtable_32_types.h
15750 @@ -8,7 +8,7 @@
15751 */
15752 #ifdef CONFIG_X86_PAE
15753 # include <asm/pgtable-3level_types.h>
15754 -# define PMD_SIZE (1UL << PMD_SHIFT)
15755 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
15756 # define PMD_MASK (~(PMD_SIZE - 1))
15757 #else
15758 # include <asm/pgtable-2level_types.h>
15759 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
15760 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
15761 #endif
15762
15763 +#ifdef CONFIG_PAX_KERNEXEC
15764 +#ifndef __ASSEMBLY__
15765 +extern unsigned char MODULES_EXEC_VADDR[];
15766 +extern unsigned char MODULES_EXEC_END[];
15767 +#endif
15768 +#include <asm/boot.h>
15769 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
15770 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
15771 +#else
15772 +#define ktla_ktva(addr) (addr)
15773 +#define ktva_ktla(addr) (addr)
15774 +#endif
15775 +
15776 #define MODULES_VADDR VMALLOC_START
15777 #define MODULES_END VMALLOC_END
15778 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
15779 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
15780 index e22c1db..23a625a 100644
15781 --- a/arch/x86/include/asm/pgtable_64.h
15782 +++ b/arch/x86/include/asm/pgtable_64.h
15783 @@ -16,10 +16,14 @@
15784
15785 extern pud_t level3_kernel_pgt[512];
15786 extern pud_t level3_ident_pgt[512];
15787 +extern pud_t level3_vmalloc_start_pgt[512];
15788 +extern pud_t level3_vmalloc_end_pgt[512];
15789 +extern pud_t level3_vmemmap_pgt[512];
15790 +extern pud_t level2_vmemmap_pgt[512];
15791 extern pmd_t level2_kernel_pgt[512];
15792 extern pmd_t level2_fixmap_pgt[512];
15793 -extern pmd_t level2_ident_pgt[512];
15794 -extern pgd_t init_level4_pgt[];
15795 +extern pmd_t level2_ident_pgt[512*2];
15796 +extern pgd_t init_level4_pgt[512];
15797
15798 #define swapper_pg_dir init_level4_pgt
15799
15800 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
15801
15802 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
15803 {
15804 + pax_open_kernel();
15805 *pmdp = pmd;
15806 + pax_close_kernel();
15807 }
15808
15809 static inline void native_pmd_clear(pmd_t *pmd)
15810 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
15811
15812 static inline void native_set_pud(pud_t *pudp, pud_t pud)
15813 {
15814 + pax_open_kernel();
15815 *pudp = pud;
15816 + pax_close_kernel();
15817 }
15818
15819 static inline void native_pud_clear(pud_t *pud)
15820 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
15821
15822 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
15823 {
15824 + pax_open_kernel();
15825 + *pgdp = pgd;
15826 + pax_close_kernel();
15827 +}
15828 +
15829 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
15830 +{
15831 *pgdp = pgd;
15832 }
15833
15834 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
15835 index 2d88344..4679fc3 100644
15836 --- a/arch/x86/include/asm/pgtable_64_types.h
15837 +++ b/arch/x86/include/asm/pgtable_64_types.h
15838 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
15839 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
15840 #define MODULES_END _AC(0xffffffffff000000, UL)
15841 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
15842 +#define MODULES_EXEC_VADDR MODULES_VADDR
15843 +#define MODULES_EXEC_END MODULES_END
15844 +
15845 +#define ktla_ktva(addr) (addr)
15846 +#define ktva_ktla(addr) (addr)
15847
15848 #define EARLY_DYNAMIC_PAGE_TABLES 64
15849
15850 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
15851 index e642300..0ef8f31 100644
15852 --- a/arch/x86/include/asm/pgtable_types.h
15853 +++ b/arch/x86/include/asm/pgtable_types.h
15854 @@ -16,13 +16,12 @@
15855 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
15856 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
15857 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
15858 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
15859 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
15860 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
15861 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
15862 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
15863 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
15864 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
15865 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
15866 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
15867 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
15868 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
15869
15870 /* If _PAGE_BIT_PRESENT is clear, we use these: */
15871 @@ -40,7 +39,6 @@
15872 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
15873 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
15874 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
15875 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
15876 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
15877 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
15878 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
15879 @@ -57,8 +55,10 @@
15880
15881 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
15882 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
15883 -#else
15884 +#elif defined(CONFIG_KMEMCHECK)
15885 #define _PAGE_NX (_AT(pteval_t, 0))
15886 +#else
15887 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
15888 #endif
15889
15890 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
15891 @@ -116,6 +116,9 @@
15892 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
15893 _PAGE_ACCESSED)
15894
15895 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
15896 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
15897 +
15898 #define __PAGE_KERNEL_EXEC \
15899 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
15900 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
15901 @@ -126,7 +129,7 @@
15902 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
15903 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
15904 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
15905 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
15906 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
15907 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
15908 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
15909 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
15910 @@ -188,8 +191,8 @@
15911 * bits are combined, this will alow user to access the high address mapped
15912 * VDSO in the presence of CONFIG_COMPAT_VDSO
15913 */
15914 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
15915 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
15916 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15917 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15918 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
15919 #endif
15920
15921 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
15922 {
15923 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
15924 }
15925 +#endif
15926
15927 +#if PAGETABLE_LEVELS == 3
15928 +#include <asm-generic/pgtable-nopud.h>
15929 +#endif
15930 +
15931 +#if PAGETABLE_LEVELS == 2
15932 +#include <asm-generic/pgtable-nopmd.h>
15933 +#endif
15934 +
15935 +#ifndef __ASSEMBLY__
15936 #if PAGETABLE_LEVELS > 3
15937 typedef struct { pudval_t pud; } pud_t;
15938
15939 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
15940 return pud.pud;
15941 }
15942 #else
15943 -#include <asm-generic/pgtable-nopud.h>
15944 -
15945 static inline pudval_t native_pud_val(pud_t pud)
15946 {
15947 return native_pgd_val(pud.pgd);
15948 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
15949 return pmd.pmd;
15950 }
15951 #else
15952 -#include <asm-generic/pgtable-nopmd.h>
15953 -
15954 static inline pmdval_t native_pmd_val(pmd_t pmd)
15955 {
15956 return native_pgd_val(pmd.pud.pgd);
15957 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
15958
15959 extern pteval_t __supported_pte_mask;
15960 extern void set_nx(void);
15961 -extern int nx_enabled;
15962
15963 #define pgprot_writecombine pgprot_writecombine
15964 extern pgprot_t pgprot_writecombine(pgprot_t prot);
15965 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
15966 index 22224b3..c5d8d7d 100644
15967 --- a/arch/x86/include/asm/processor.h
15968 +++ b/arch/x86/include/asm/processor.h
15969 @@ -198,9 +198,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
15970 : "memory");
15971 }
15972
15973 +/* invpcid (%rdx),%rax */
15974 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
15975 +
15976 +#define INVPCID_SINGLE_ADDRESS 0UL
15977 +#define INVPCID_SINGLE_CONTEXT 1UL
15978 +#define INVPCID_ALL_GLOBAL 2UL
15979 +#define INVPCID_ALL_MONGLOBAL 3UL
15980 +
15981 +#define PCID_KERNEL 0UL
15982 +#define PCID_USER 1UL
15983 +#define PCID_NOFLUSH (1UL << 63)
15984 +
15985 static inline void load_cr3(pgd_t *pgdir)
15986 {
15987 - write_cr3(__pa(pgdir));
15988 + write_cr3(__pa(pgdir) | PCID_KERNEL);
15989 }
15990
15991 #ifdef CONFIG_X86_32
15992 @@ -282,7 +294,7 @@ struct tss_struct {
15993
15994 } ____cacheline_aligned;
15995
15996 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
15997 +extern struct tss_struct init_tss[NR_CPUS];
15998
15999 /*
16000 * Save the original ist values for checking stack pointers during debugging
16001 @@ -452,6 +464,7 @@ struct thread_struct {
16002 unsigned short ds;
16003 unsigned short fsindex;
16004 unsigned short gsindex;
16005 + unsigned short ss;
16006 #endif
16007 #ifdef CONFIG_X86_32
16008 unsigned long ip;
16009 @@ -823,11 +836,18 @@ static inline void spin_lock_prefetch(const void *x)
16010 */
16011 #define TASK_SIZE PAGE_OFFSET
16012 #define TASK_SIZE_MAX TASK_SIZE
16013 +
16014 +#ifdef CONFIG_PAX_SEGMEXEC
16015 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16016 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16017 +#else
16018 #define STACK_TOP TASK_SIZE
16019 -#define STACK_TOP_MAX STACK_TOP
16020 +#endif
16021 +
16022 +#define STACK_TOP_MAX TASK_SIZE
16023
16024 #define INIT_THREAD { \
16025 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16026 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16027 .vm86_info = NULL, \
16028 .sysenter_cs = __KERNEL_CS, \
16029 .io_bitmap_ptr = NULL, \
16030 @@ -841,7 +861,7 @@ static inline void spin_lock_prefetch(const void *x)
16031 */
16032 #define INIT_TSS { \
16033 .x86_tss = { \
16034 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16035 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16036 .ss0 = __KERNEL_DS, \
16037 .ss1 = __KERNEL_CS, \
16038 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16039 @@ -852,11 +872,7 @@ static inline void spin_lock_prefetch(const void *x)
16040 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16041
16042 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16043 -#define KSTK_TOP(info) \
16044 -({ \
16045 - unsigned long *__ptr = (unsigned long *)(info); \
16046 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16047 -})
16048 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16049
16050 /*
16051 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16052 @@ -871,7 +887,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16053 #define task_pt_regs(task) \
16054 ({ \
16055 struct pt_regs *__regs__; \
16056 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16057 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16058 __regs__ - 1; \
16059 })
16060
16061 @@ -881,13 +897,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16062 /*
16063 * User space process size. 47bits minus one guard page.
16064 */
16065 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16066 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16067
16068 /* This decides where the kernel will search for a free chunk of vm
16069 * space during mmap's.
16070 */
16071 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16072 - 0xc0000000 : 0xFFFFe000)
16073 + 0xc0000000 : 0xFFFFf000)
16074
16075 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16076 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16077 @@ -898,11 +914,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16078 #define STACK_TOP_MAX TASK_SIZE_MAX
16079
16080 #define INIT_THREAD { \
16081 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16082 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16083 }
16084
16085 #define INIT_TSS { \
16086 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16087 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16088 }
16089
16090 /*
16091 @@ -930,6 +946,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16092 */
16093 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16094
16095 +#ifdef CONFIG_PAX_SEGMEXEC
16096 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16097 +#endif
16098 +
16099 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16100
16101 /* Get/set a process' ability to use the timestamp counter instruction */
16102 @@ -942,7 +962,8 @@ extern int set_tsc_mode(unsigned int val);
16103 extern u16 amd_get_nb_id(int cpu);
16104
16105 struct aperfmperf {
16106 - u64 aperf, mperf;
16107 + u64 aperf __intentional_overflow(0);
16108 + u64 mperf __intentional_overflow(0);
16109 };
16110
16111 static inline void get_aperfmperf(struct aperfmperf *am)
16112 @@ -970,7 +991,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
16113 return ratio;
16114 }
16115
16116 -extern unsigned long arch_align_stack(unsigned long sp);
16117 +#define arch_align_stack(x) ((x) & ~0xfUL)
16118 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16119
16120 void default_idle(void);
16121 @@ -980,6 +1001,6 @@ bool xen_set_default_idle(void);
16122 #define xen_set_default_idle 0
16123 #endif
16124
16125 -void stop_this_cpu(void *dummy);
16126 +void stop_this_cpu(void *dummy) __noreturn;
16127
16128 #endif /* _ASM_X86_PROCESSOR_H */
16129 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16130 index 942a086..6c26446 100644
16131 --- a/arch/x86/include/asm/ptrace.h
16132 +++ b/arch/x86/include/asm/ptrace.h
16133 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16134 }
16135
16136 /*
16137 - * user_mode_vm(regs) determines whether a register set came from user mode.
16138 + * user_mode(regs) determines whether a register set came from user mode.
16139 * This is true if V8086 mode was enabled OR if the register set was from
16140 * protected mode with RPL-3 CS value. This tricky test checks that with
16141 * one comparison. Many places in the kernel can bypass this full check
16142 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
16143 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
16144 + * be used.
16145 */
16146 -static inline int user_mode(struct pt_regs *regs)
16147 +static inline int user_mode_novm(struct pt_regs *regs)
16148 {
16149 #ifdef CONFIG_X86_32
16150 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
16151 #else
16152 - return !!(regs->cs & 3);
16153 + return !!(regs->cs & SEGMENT_RPL_MASK);
16154 #endif
16155 }
16156
16157 -static inline int user_mode_vm(struct pt_regs *regs)
16158 +static inline int user_mode(struct pt_regs *regs)
16159 {
16160 #ifdef CONFIG_X86_32
16161 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
16162 USER_RPL;
16163 #else
16164 - return user_mode(regs);
16165 + return user_mode_novm(regs);
16166 #endif
16167 }
16168
16169 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
16170 #ifdef CONFIG_X86_64
16171 static inline bool user_64bit_mode(struct pt_regs *regs)
16172 {
16173 + unsigned long cs = regs->cs & 0xffff;
16174 #ifndef CONFIG_PARAVIRT
16175 /*
16176 * On non-paravirt systems, this is the only long mode CPL 3
16177 * selector. We do not allow long mode selectors in the LDT.
16178 */
16179 - return regs->cs == __USER_CS;
16180 + return cs == __USER_CS;
16181 #else
16182 /* Headers are too twisted for this to go in paravirt.h. */
16183 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
16184 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
16185 #endif
16186 }
16187
16188 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
16189 * Traps from the kernel do not save sp and ss.
16190 * Use the helper function to retrieve sp.
16191 */
16192 - if (offset == offsetof(struct pt_regs, sp) &&
16193 - regs->cs == __KERNEL_CS)
16194 - return kernel_stack_pointer(regs);
16195 + if (offset == offsetof(struct pt_regs, sp)) {
16196 + unsigned long cs = regs->cs & 0xffff;
16197 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
16198 + return kernel_stack_pointer(regs);
16199 + }
16200 #endif
16201 return *(unsigned long *)((unsigned long)regs + offset);
16202 }
16203 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
16204 index 9c6b890..5305f53 100644
16205 --- a/arch/x86/include/asm/realmode.h
16206 +++ b/arch/x86/include/asm/realmode.h
16207 @@ -22,16 +22,14 @@ struct real_mode_header {
16208 #endif
16209 /* APM/BIOS reboot */
16210 u32 machine_real_restart_asm;
16211 -#ifdef CONFIG_X86_64
16212 u32 machine_real_restart_seg;
16213 -#endif
16214 };
16215
16216 /* This must match data at trampoline_32/64.S */
16217 struct trampoline_header {
16218 #ifdef CONFIG_X86_32
16219 u32 start;
16220 - u16 gdt_pad;
16221 + u16 boot_cs;
16222 u16 gdt_limit;
16223 u32 gdt_base;
16224 #else
16225 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
16226 index a82c4f1..ac45053 100644
16227 --- a/arch/x86/include/asm/reboot.h
16228 +++ b/arch/x86/include/asm/reboot.h
16229 @@ -6,13 +6,13 @@
16230 struct pt_regs;
16231
16232 struct machine_ops {
16233 - void (*restart)(char *cmd);
16234 - void (*halt)(void);
16235 - void (*power_off)(void);
16236 + void (* __noreturn restart)(char *cmd);
16237 + void (* __noreturn halt)(void);
16238 + void (* __noreturn power_off)(void);
16239 void (*shutdown)(void);
16240 void (*crash_shutdown)(struct pt_regs *);
16241 - void (*emergency_restart)(void);
16242 -};
16243 + void (* __noreturn emergency_restart)(void);
16244 +} __no_const;
16245
16246 extern struct machine_ops machine_ops;
16247
16248 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
16249 index cad82c9..2e5c5c1 100644
16250 --- a/arch/x86/include/asm/rwsem.h
16251 +++ b/arch/x86/include/asm/rwsem.h
16252 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
16253 {
16254 asm volatile("# beginning down_read\n\t"
16255 LOCK_PREFIX _ASM_INC "(%1)\n\t"
16256 +
16257 +#ifdef CONFIG_PAX_REFCOUNT
16258 + "jno 0f\n"
16259 + LOCK_PREFIX _ASM_DEC "(%1)\n"
16260 + "int $4\n0:\n"
16261 + _ASM_EXTABLE(0b, 0b)
16262 +#endif
16263 +
16264 /* adds 0x00000001 */
16265 " jns 1f\n"
16266 " call call_rwsem_down_read_failed\n"
16267 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
16268 "1:\n\t"
16269 " mov %1,%2\n\t"
16270 " add %3,%2\n\t"
16271 +
16272 +#ifdef CONFIG_PAX_REFCOUNT
16273 + "jno 0f\n"
16274 + "sub %3,%2\n"
16275 + "int $4\n0:\n"
16276 + _ASM_EXTABLE(0b, 0b)
16277 +#endif
16278 +
16279 " jle 2f\n\t"
16280 LOCK_PREFIX " cmpxchg %2,%0\n\t"
16281 " jnz 1b\n\t"
16282 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
16283 long tmp;
16284 asm volatile("# beginning down_write\n\t"
16285 LOCK_PREFIX " xadd %1,(%2)\n\t"
16286 +
16287 +#ifdef CONFIG_PAX_REFCOUNT
16288 + "jno 0f\n"
16289 + "mov %1,(%2)\n"
16290 + "int $4\n0:\n"
16291 + _ASM_EXTABLE(0b, 0b)
16292 +#endif
16293 +
16294 /* adds 0xffff0001, returns the old value */
16295 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
16296 /* was the active mask 0 before? */
16297 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
16298 long tmp;
16299 asm volatile("# beginning __up_read\n\t"
16300 LOCK_PREFIX " xadd %1,(%2)\n\t"
16301 +
16302 +#ifdef CONFIG_PAX_REFCOUNT
16303 + "jno 0f\n"
16304 + "mov %1,(%2)\n"
16305 + "int $4\n0:\n"
16306 + _ASM_EXTABLE(0b, 0b)
16307 +#endif
16308 +
16309 /* subtracts 1, returns the old value */
16310 " jns 1f\n\t"
16311 " call call_rwsem_wake\n" /* expects old value in %edx */
16312 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
16313 long tmp;
16314 asm volatile("# beginning __up_write\n\t"
16315 LOCK_PREFIX " xadd %1,(%2)\n\t"
16316 +
16317 +#ifdef CONFIG_PAX_REFCOUNT
16318 + "jno 0f\n"
16319 + "mov %1,(%2)\n"
16320 + "int $4\n0:\n"
16321 + _ASM_EXTABLE(0b, 0b)
16322 +#endif
16323 +
16324 /* subtracts 0xffff0001, returns the old value */
16325 " jns 1f\n\t"
16326 " call call_rwsem_wake\n" /* expects old value in %edx */
16327 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
16328 {
16329 asm volatile("# beginning __downgrade_write\n\t"
16330 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
16331 +
16332 +#ifdef CONFIG_PAX_REFCOUNT
16333 + "jno 0f\n"
16334 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
16335 + "int $4\n0:\n"
16336 + _ASM_EXTABLE(0b, 0b)
16337 +#endif
16338 +
16339 /*
16340 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
16341 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
16342 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
16343 */
16344 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
16345 {
16346 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
16347 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
16348 +
16349 +#ifdef CONFIG_PAX_REFCOUNT
16350 + "jno 0f\n"
16351 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
16352 + "int $4\n0:\n"
16353 + _ASM_EXTABLE(0b, 0b)
16354 +#endif
16355 +
16356 : "+m" (sem->count)
16357 : "er" (delta));
16358 }
16359 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
16360 */
16361 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
16362 {
16363 - return delta + xadd(&sem->count, delta);
16364 + return delta + xadd_check_overflow(&sem->count, delta);
16365 }
16366
16367 #endif /* __KERNEL__ */
16368 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
16369 index c48a950..bc40804 100644
16370 --- a/arch/x86/include/asm/segment.h
16371 +++ b/arch/x86/include/asm/segment.h
16372 @@ -64,10 +64,15 @@
16373 * 26 - ESPFIX small SS
16374 * 27 - per-cpu [ offset to per-cpu data area ]
16375 * 28 - stack_canary-20 [ for stack protector ]
16376 - * 29 - unused
16377 - * 30 - unused
16378 + * 29 - PCI BIOS CS
16379 + * 30 - PCI BIOS DS
16380 * 31 - TSS for double fault handler
16381 */
16382 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
16383 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
16384 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
16385 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
16386 +
16387 #define GDT_ENTRY_TLS_MIN 6
16388 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
16389
16390 @@ -79,6 +84,8 @@
16391
16392 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
16393
16394 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
16395 +
16396 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
16397
16398 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
16399 @@ -104,6 +111,12 @@
16400 #define __KERNEL_STACK_CANARY 0
16401 #endif
16402
16403 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
16404 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
16405 +
16406 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
16407 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
16408 +
16409 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
16410
16411 /*
16412 @@ -141,7 +154,7 @@
16413 */
16414
16415 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
16416 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
16417 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
16418
16419
16420 #else
16421 @@ -165,6 +178,8 @@
16422 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
16423 #define __USER32_DS __USER_DS
16424
16425 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
16426 +
16427 #define GDT_ENTRY_TSS 8 /* needs two entries */
16428 #define GDT_ENTRY_LDT 10 /* needs two entries */
16429 #define GDT_ENTRY_TLS_MIN 12
16430 @@ -173,6 +188,8 @@
16431 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
16432 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
16433
16434 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
16435 +
16436 /* TLS indexes for 64bit - hardcoded in arch_prctl */
16437 #define FS_TLS 0
16438 #define GS_TLS 1
16439 @@ -180,12 +197,14 @@
16440 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
16441 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
16442
16443 -#define GDT_ENTRIES 16
16444 +#define GDT_ENTRIES 17
16445
16446 #endif
16447
16448 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
16449 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
16450 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
16451 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
16452 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
16453 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
16454 #ifndef CONFIG_PARAVIRT
16455 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
16456 {
16457 unsigned long __limit;
16458 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
16459 - return __limit + 1;
16460 + return __limit;
16461 }
16462
16463 #endif /* !__ASSEMBLY__ */
16464 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
16465 index 8d3120f..352b440 100644
16466 --- a/arch/x86/include/asm/smap.h
16467 +++ b/arch/x86/include/asm/smap.h
16468 @@ -25,11 +25,40 @@
16469
16470 #include <asm/alternative-asm.h>
16471
16472 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16473 +#define ASM_PAX_OPEN_USERLAND \
16474 + 661: jmp 663f; \
16475 + .pushsection .altinstr_replacement, "a" ; \
16476 + 662: pushq %rax; nop; \
16477 + .popsection ; \
16478 + .pushsection .altinstructions, "a" ; \
16479 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
16480 + .popsection ; \
16481 + call __pax_open_userland; \
16482 + popq %rax; \
16483 + 663:
16484 +
16485 +#define ASM_PAX_CLOSE_USERLAND \
16486 + 661: jmp 663f; \
16487 + .pushsection .altinstr_replacement, "a" ; \
16488 + 662: pushq %rax; nop; \
16489 + .popsection; \
16490 + .pushsection .altinstructions, "a" ; \
16491 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
16492 + .popsection; \
16493 + call __pax_close_userland; \
16494 + popq %rax; \
16495 + 663:
16496 +#else
16497 +#define ASM_PAX_OPEN_USERLAND
16498 +#define ASM_PAX_CLOSE_USERLAND
16499 +#endif
16500 +
16501 #ifdef CONFIG_X86_SMAP
16502
16503 #define ASM_CLAC \
16504 661: ASM_NOP3 ; \
16505 - .pushsection .altinstr_replacement, "ax" ; \
16506 + .pushsection .altinstr_replacement, "a" ; \
16507 662: __ASM_CLAC ; \
16508 .popsection ; \
16509 .pushsection .altinstructions, "a" ; \
16510 @@ -38,7 +67,7 @@
16511
16512 #define ASM_STAC \
16513 661: ASM_NOP3 ; \
16514 - .pushsection .altinstr_replacement, "ax" ; \
16515 + .pushsection .altinstr_replacement, "a" ; \
16516 662: __ASM_STAC ; \
16517 .popsection ; \
16518 .pushsection .altinstructions, "a" ; \
16519 @@ -56,6 +85,37 @@
16520
16521 #include <asm/alternative.h>
16522
16523 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
16524 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
16525 +
16526 +extern void __pax_open_userland(void);
16527 +static __always_inline unsigned long pax_open_userland(void)
16528 +{
16529 +
16530 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16531 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
16532 + :
16533 + : [open] "i" (__pax_open_userland)
16534 + : "memory", "rax");
16535 +#endif
16536 +
16537 + return 0;
16538 +}
16539 +
16540 +extern void __pax_close_userland(void);
16541 +static __always_inline unsigned long pax_close_userland(void)
16542 +{
16543 +
16544 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16545 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
16546 + :
16547 + : [close] "i" (__pax_close_userland)
16548 + : "memory", "rax");
16549 +#endif
16550 +
16551 + return 0;
16552 +}
16553 +
16554 #ifdef CONFIG_X86_SMAP
16555
16556 static __always_inline void clac(void)
16557 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
16558 index b073aae..39f9bdd 100644
16559 --- a/arch/x86/include/asm/smp.h
16560 +++ b/arch/x86/include/asm/smp.h
16561 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
16562 /* cpus sharing the last level cache: */
16563 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
16564 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
16565 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
16566 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
16567
16568 static inline struct cpumask *cpu_sibling_mask(int cpu)
16569 {
16570 @@ -79,7 +79,7 @@ struct smp_ops {
16571
16572 void (*send_call_func_ipi)(const struct cpumask *mask);
16573 void (*send_call_func_single_ipi)(int cpu);
16574 -};
16575 +} __no_const;
16576
16577 /* Globals due to paravirt */
16578 extern void set_cpu_sibling_map(int cpu);
16579 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
16580 extern int safe_smp_processor_id(void);
16581
16582 #elif defined(CONFIG_X86_64_SMP)
16583 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
16584 -
16585 -#define stack_smp_processor_id() \
16586 -({ \
16587 - struct thread_info *ti; \
16588 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
16589 - ti->cpu; \
16590 -})
16591 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
16592 +#define stack_smp_processor_id() raw_smp_processor_id()
16593 #define safe_smp_processor_id() smp_processor_id()
16594
16595 #endif
16596 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
16597 index 33692ea..350a534 100644
16598 --- a/arch/x86/include/asm/spinlock.h
16599 +++ b/arch/x86/include/asm/spinlock.h
16600 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
16601 static inline void arch_read_lock(arch_rwlock_t *rw)
16602 {
16603 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
16604 +
16605 +#ifdef CONFIG_PAX_REFCOUNT
16606 + "jno 0f\n"
16607 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
16608 + "int $4\n0:\n"
16609 + _ASM_EXTABLE(0b, 0b)
16610 +#endif
16611 +
16612 "jns 1f\n"
16613 "call __read_lock_failed\n\t"
16614 "1:\n"
16615 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
16616 static inline void arch_write_lock(arch_rwlock_t *rw)
16617 {
16618 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
16619 +
16620 +#ifdef CONFIG_PAX_REFCOUNT
16621 + "jno 0f\n"
16622 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
16623 + "int $4\n0:\n"
16624 + _ASM_EXTABLE(0b, 0b)
16625 +#endif
16626 +
16627 "jz 1f\n"
16628 "call __write_lock_failed\n\t"
16629 "1:\n"
16630 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
16631
16632 static inline void arch_read_unlock(arch_rwlock_t *rw)
16633 {
16634 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
16635 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
16636 +
16637 +#ifdef CONFIG_PAX_REFCOUNT
16638 + "jno 0f\n"
16639 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
16640 + "int $4\n0:\n"
16641 + _ASM_EXTABLE(0b, 0b)
16642 +#endif
16643 +
16644 :"+m" (rw->lock) : : "memory");
16645 }
16646
16647 static inline void arch_write_unlock(arch_rwlock_t *rw)
16648 {
16649 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
16650 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
16651 +
16652 +#ifdef CONFIG_PAX_REFCOUNT
16653 + "jno 0f\n"
16654 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
16655 + "int $4\n0:\n"
16656 + _ASM_EXTABLE(0b, 0b)
16657 +#endif
16658 +
16659 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
16660 }
16661
16662 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
16663 index 6a99859..03cb807 100644
16664 --- a/arch/x86/include/asm/stackprotector.h
16665 +++ b/arch/x86/include/asm/stackprotector.h
16666 @@ -47,7 +47,7 @@
16667 * head_32 for boot CPU and setup_per_cpu_areas() for others.
16668 */
16669 #define GDT_STACK_CANARY_INIT \
16670 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
16671 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
16672
16673 /*
16674 * Initialize the stackprotector canary value.
16675 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
16676
16677 static inline void load_stack_canary_segment(void)
16678 {
16679 -#ifdef CONFIG_X86_32
16680 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
16681 asm volatile ("mov %0, %%gs" : : "r" (0));
16682 #endif
16683 }
16684 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
16685 index 70bbe39..4ae2bd4 100644
16686 --- a/arch/x86/include/asm/stacktrace.h
16687 +++ b/arch/x86/include/asm/stacktrace.h
16688 @@ -11,28 +11,20 @@
16689
16690 extern int kstack_depth_to_print;
16691
16692 -struct thread_info;
16693 +struct task_struct;
16694 struct stacktrace_ops;
16695
16696 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
16697 - unsigned long *stack,
16698 - unsigned long bp,
16699 - const struct stacktrace_ops *ops,
16700 - void *data,
16701 - unsigned long *end,
16702 - int *graph);
16703 +typedef unsigned long walk_stack_t(struct task_struct *task,
16704 + void *stack_start,
16705 + unsigned long *stack,
16706 + unsigned long bp,
16707 + const struct stacktrace_ops *ops,
16708 + void *data,
16709 + unsigned long *end,
16710 + int *graph);
16711
16712 -extern unsigned long
16713 -print_context_stack(struct thread_info *tinfo,
16714 - unsigned long *stack, unsigned long bp,
16715 - const struct stacktrace_ops *ops, void *data,
16716 - unsigned long *end, int *graph);
16717 -
16718 -extern unsigned long
16719 -print_context_stack_bp(struct thread_info *tinfo,
16720 - unsigned long *stack, unsigned long bp,
16721 - const struct stacktrace_ops *ops, void *data,
16722 - unsigned long *end, int *graph);
16723 +extern walk_stack_t print_context_stack;
16724 +extern walk_stack_t print_context_stack_bp;
16725
16726 /* Generic stack tracer with callbacks */
16727
16728 @@ -40,7 +32,7 @@ struct stacktrace_ops {
16729 void (*address)(void *data, unsigned long address, int reliable);
16730 /* On negative return stop dumping */
16731 int (*stack)(void *data, char *name);
16732 - walk_stack_t walk_stack;
16733 + walk_stack_t *walk_stack;
16734 };
16735
16736 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
16737 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
16738 index 4ec45b3..a4f0a8a 100644
16739 --- a/arch/x86/include/asm/switch_to.h
16740 +++ b/arch/x86/include/asm/switch_to.h
16741 @@ -108,7 +108,7 @@ do { \
16742 "call __switch_to\n\t" \
16743 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
16744 __switch_canary \
16745 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
16746 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
16747 "movq %%rax,%%rdi\n\t" \
16748 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
16749 "jnz ret_from_fork\n\t" \
16750 @@ -119,7 +119,7 @@ do { \
16751 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
16752 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
16753 [_tif_fork] "i" (_TIF_FORK), \
16754 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
16755 + [thread_info] "m" (current_tinfo), \
16756 [current_task] "m" (current_task) \
16757 __switch_canary_iparam \
16758 : "memory", "cc" __EXTRA_CLOBBER)
16759 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
16760 index a1df6e8..e002940 100644
16761 --- a/arch/x86/include/asm/thread_info.h
16762 +++ b/arch/x86/include/asm/thread_info.h
16763 @@ -10,6 +10,7 @@
16764 #include <linux/compiler.h>
16765 #include <asm/page.h>
16766 #include <asm/types.h>
16767 +#include <asm/percpu.h>
16768
16769 /*
16770 * low level task data that entry.S needs immediate access to
16771 @@ -23,7 +24,6 @@ struct exec_domain;
16772 #include <linux/atomic.h>
16773
16774 struct thread_info {
16775 - struct task_struct *task; /* main task structure */
16776 struct exec_domain *exec_domain; /* execution domain */
16777 __u32 flags; /* low level flags */
16778 __u32 status; /* thread synchronous flags */
16779 @@ -33,19 +33,13 @@ struct thread_info {
16780 mm_segment_t addr_limit;
16781 struct restart_block restart_block;
16782 void __user *sysenter_return;
16783 -#ifdef CONFIG_X86_32
16784 - unsigned long previous_esp; /* ESP of the previous stack in
16785 - case of nested (IRQ) stacks
16786 - */
16787 - __u8 supervisor_stack[0];
16788 -#endif
16789 + unsigned long lowest_stack;
16790 unsigned int sig_on_uaccess_error:1;
16791 unsigned int uaccess_err:1; /* uaccess failed */
16792 };
16793
16794 -#define INIT_THREAD_INFO(tsk) \
16795 +#define INIT_THREAD_INFO \
16796 { \
16797 - .task = &tsk, \
16798 .exec_domain = &default_exec_domain, \
16799 .flags = 0, \
16800 .cpu = 0, \
16801 @@ -56,7 +50,7 @@ struct thread_info {
16802 }, \
16803 }
16804
16805 -#define init_thread_info (init_thread_union.thread_info)
16806 +#define init_thread_info (init_thread_union.stack)
16807 #define init_stack (init_thread_union.stack)
16808
16809 #else /* !__ASSEMBLY__ */
16810 @@ -97,6 +91,7 @@ struct thread_info {
16811 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
16812 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
16813 #define TIF_X32 30 /* 32-bit native x86-64 binary */
16814 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
16815
16816 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
16817 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
16818 @@ -121,17 +116,18 @@ struct thread_info {
16819 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
16820 #define _TIF_ADDR32 (1 << TIF_ADDR32)
16821 #define _TIF_X32 (1 << TIF_X32)
16822 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
16823
16824 /* work to do in syscall_trace_enter() */
16825 #define _TIF_WORK_SYSCALL_ENTRY \
16826 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
16827 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
16828 - _TIF_NOHZ)
16829 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
16830
16831 /* work to do in syscall_trace_leave() */
16832 #define _TIF_WORK_SYSCALL_EXIT \
16833 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
16834 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
16835 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
16836
16837 /* work to do on interrupt/exception return */
16838 #define _TIF_WORK_MASK \
16839 @@ -142,7 +138,7 @@ struct thread_info {
16840 /* work to do on any return to user space */
16841 #define _TIF_ALLWORK_MASK \
16842 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
16843 - _TIF_NOHZ)
16844 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
16845
16846 /* Only used for 64 bit */
16847 #define _TIF_DO_NOTIFY_MASK \
16848 @@ -158,45 +154,40 @@ struct thread_info {
16849
16850 #define PREEMPT_ACTIVE 0x10000000
16851
16852 -#ifdef CONFIG_X86_32
16853 -
16854 -#define STACK_WARN (THREAD_SIZE/8)
16855 -/*
16856 - * macros/functions for gaining access to the thread information structure
16857 - *
16858 - * preempt_count needs to be 1 initially, until the scheduler is functional.
16859 - */
16860 -#ifndef __ASSEMBLY__
16861 -
16862 -
16863 -/* how to get the current stack pointer from C */
16864 -register unsigned long current_stack_pointer asm("esp") __used;
16865 -
16866 -/* how to get the thread information struct from C */
16867 -static inline struct thread_info *current_thread_info(void)
16868 -{
16869 - return (struct thread_info *)
16870 - (current_stack_pointer & ~(THREAD_SIZE - 1));
16871 -}
16872 -
16873 -#else /* !__ASSEMBLY__ */
16874 -
16875 +#ifdef __ASSEMBLY__
16876 /* how to get the thread information struct from ASM */
16877 #define GET_THREAD_INFO(reg) \
16878 - movl $-THREAD_SIZE, reg; \
16879 - andl %esp, reg
16880 + mov PER_CPU_VAR(current_tinfo), reg
16881
16882 /* use this one if reg already contains %esp */
16883 -#define GET_THREAD_INFO_WITH_ESP(reg) \
16884 - andl $-THREAD_SIZE, reg
16885 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
16886 +#else
16887 +/* how to get the thread information struct from C */
16888 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
16889 +
16890 +static __always_inline struct thread_info *current_thread_info(void)
16891 +{
16892 + return this_cpu_read_stable(current_tinfo);
16893 +}
16894 +#endif
16895 +
16896 +#ifdef CONFIG_X86_32
16897 +
16898 +#define STACK_WARN (THREAD_SIZE/8)
16899 +/*
16900 + * macros/functions for gaining access to the thread information structure
16901 + *
16902 + * preempt_count needs to be 1 initially, until the scheduler is functional.
16903 + */
16904 +#ifndef __ASSEMBLY__
16905 +
16906 +/* how to get the current stack pointer from C */
16907 +register unsigned long current_stack_pointer asm("esp") __used;
16908
16909 #endif
16910
16911 #else /* X86_32 */
16912
16913 -#include <asm/percpu.h>
16914 -#define KERNEL_STACK_OFFSET (5*8)
16915 -
16916 /*
16917 * macros/functions for gaining access to the thread information structure
16918 * preempt_count needs to be 1 initially, until the scheduler is functional.
16919 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
16920 #ifndef __ASSEMBLY__
16921 DECLARE_PER_CPU(unsigned long, kernel_stack);
16922
16923 -static inline struct thread_info *current_thread_info(void)
16924 -{
16925 - struct thread_info *ti;
16926 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
16927 - KERNEL_STACK_OFFSET - THREAD_SIZE);
16928 - return ti;
16929 -}
16930 -
16931 -#else /* !__ASSEMBLY__ */
16932 -
16933 -/* how to get the thread information struct from ASM */
16934 -#define GET_THREAD_INFO(reg) \
16935 - movq PER_CPU_VAR(kernel_stack),reg ; \
16936 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
16937 -
16938 -/*
16939 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
16940 - * a certain register (to be used in assembler memory operands).
16941 - */
16942 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
16943 -
16944 +/* how to get the current stack pointer from C */
16945 +register unsigned long current_stack_pointer asm("rsp") __used;
16946 #endif
16947
16948 #endif /* !X86_32 */
16949 @@ -283,5 +255,12 @@ static inline bool is_ia32_task(void)
16950 extern void arch_task_cache_init(void);
16951 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
16952 extern void arch_release_task_struct(struct task_struct *tsk);
16953 +
16954 +#define __HAVE_THREAD_FUNCTIONS
16955 +#define task_thread_info(task) (&(task)->tinfo)
16956 +#define task_stack_page(task) ((task)->stack)
16957 +#define setup_thread_stack(p, org) do {} while (0)
16958 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
16959 +
16960 #endif
16961 #endif /* _ASM_X86_THREAD_INFO_H */
16962 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
16963 index 50a7fc0..88413be 100644
16964 --- a/arch/x86/include/asm/tlbflush.h
16965 +++ b/arch/x86/include/asm/tlbflush.h
16966 @@ -17,18 +17,40 @@
16967
16968 static inline void __native_flush_tlb(void)
16969 {
16970 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16971 + unsigned long descriptor[2];
16972 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
16973 + return;
16974 + }
16975 +
16976 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16977 + if (static_cpu_has(X86_FEATURE_PCID)) {
16978 + unsigned int cpu = raw_get_cpu();
16979 +
16980 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16981 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16982 + raw_put_cpu_no_resched();
16983 + return;
16984 + }
16985 +#endif
16986 +
16987 native_write_cr3(native_read_cr3());
16988 }
16989
16990 static inline void __native_flush_tlb_global_irq_disabled(void)
16991 {
16992 - unsigned long cr4;
16993 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16994 + unsigned long descriptor[2];
16995 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
16996 + } else {
16997 + unsigned long cr4;
16998
16999 - cr4 = native_read_cr4();
17000 - /* clear PGE */
17001 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17002 - /* write old PGE again and flush TLBs */
17003 - native_write_cr4(cr4);
17004 + cr4 = native_read_cr4();
17005 + /* clear PGE */
17006 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17007 + /* write old PGE again and flush TLBs */
17008 + native_write_cr4(cr4);
17009 + }
17010 }
17011
17012 static inline void __native_flush_tlb_global(void)
17013 @@ -49,6 +71,42 @@ static inline void __native_flush_tlb_global(void)
17014
17015 static inline void __native_flush_tlb_single(unsigned long addr)
17016 {
17017 +
17018 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17019 + unsigned long descriptor[2];
17020 +
17021 + descriptor[0] = PCID_KERNEL;
17022 + descriptor[1] = addr;
17023 +
17024 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17025 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF || addr >= TASK_SIZE_MAX)) {
17026 + if (addr < TASK_SIZE_MAX)
17027 + descriptor[1] += pax_user_shadow_base;
17028 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17029 + }
17030 +
17031 + descriptor[0] = PCID_USER;
17032 + descriptor[1] = addr;
17033 +#endif
17034 +
17035 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17036 + return;
17037 + }
17038 +
17039 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17040 + if (static_cpu_has(X86_FEATURE_PCID)) {
17041 + unsigned int cpu = raw_get_cpu();
17042 +
17043 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17044 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17045 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17046 + raw_put_cpu_no_resched();
17047 +
17048 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17049 + addr += pax_user_shadow_base;
17050 + }
17051 +#endif
17052 +
17053 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17054 }
17055
17056 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17057 index 5ee2687..74590b9 100644
17058 --- a/arch/x86/include/asm/uaccess.h
17059 +++ b/arch/x86/include/asm/uaccess.h
17060 @@ -7,6 +7,7 @@
17061 #include <linux/compiler.h>
17062 #include <linux/thread_info.h>
17063 #include <linux/string.h>
17064 +#include <linux/sched.h>
17065 #include <asm/asm.h>
17066 #include <asm/page.h>
17067 #include <asm/smap.h>
17068 @@ -29,7 +30,12 @@
17069
17070 #define get_ds() (KERNEL_DS)
17071 #define get_fs() (current_thread_info()->addr_limit)
17072 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17073 +void __set_fs(mm_segment_t x);
17074 +void set_fs(mm_segment_t x);
17075 +#else
17076 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17077 +#endif
17078
17079 #define segment_eq(a, b) ((a).seg == (b).seg)
17080
17081 @@ -77,8 +83,33 @@
17082 * checks that the pointer is in the user space range - after calling
17083 * this function, memory access functions may still return -EFAULT.
17084 */
17085 -#define access_ok(type, addr, size) \
17086 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17087 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17088 +#define access_ok(type, addr, size) \
17089 +({ \
17090 + long __size = size; \
17091 + unsigned long __addr = (unsigned long)addr; \
17092 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17093 + unsigned long __end_ao = __addr + __size - 1; \
17094 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17095 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17096 + while(__addr_ao <= __end_ao) { \
17097 + char __c_ao; \
17098 + __addr_ao += PAGE_SIZE; \
17099 + if (__size > PAGE_SIZE) \
17100 + cond_resched(); \
17101 + if (__get_user(__c_ao, (char __user *)__addr)) \
17102 + break; \
17103 + if (type != VERIFY_WRITE) { \
17104 + __addr = __addr_ao; \
17105 + continue; \
17106 + } \
17107 + if (__put_user(__c_ao, (char __user *)__addr)) \
17108 + break; \
17109 + __addr = __addr_ao; \
17110 + } \
17111 + } \
17112 + __ret_ao; \
17113 +})
17114
17115 /*
17116 * The exception table consists of pairs of addresses relative to the
17117 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17118 register __inttype(*(ptr)) __val_gu asm("%edx"); \
17119 __chk_user_ptr(ptr); \
17120 might_fault(); \
17121 + pax_open_userland(); \
17122 asm volatile("call __get_user_%P3" \
17123 : "=a" (__ret_gu), "=r" (__val_gu) \
17124 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17125 (x) = (__typeof__(*(ptr))) __val_gu; \
17126 + pax_close_userland(); \
17127 __ret_gu; \
17128 })
17129
17130 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17131 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17132 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17133
17134 -
17135 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17136 +#define __copyuser_seg "gs;"
17137 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17138 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
17139 +#else
17140 +#define __copyuser_seg
17141 +#define __COPYUSER_SET_ES
17142 +#define __COPYUSER_RESTORE_ES
17143 +#endif
17144
17145 #ifdef CONFIG_X86_32
17146 #define __put_user_asm_u64(x, addr, err, errret) \
17147 asm volatile(ASM_STAC "\n" \
17148 - "1: movl %%eax,0(%2)\n" \
17149 - "2: movl %%edx,4(%2)\n" \
17150 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
17151 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
17152 "3: " ASM_CLAC "\n" \
17153 ".section .fixup,\"ax\"\n" \
17154 "4: movl %3,%0\n" \
17155 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17156
17157 #define __put_user_asm_ex_u64(x, addr) \
17158 asm volatile(ASM_STAC "\n" \
17159 - "1: movl %%eax,0(%1)\n" \
17160 - "2: movl %%edx,4(%1)\n" \
17161 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
17162 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
17163 "3: " ASM_CLAC "\n" \
17164 _ASM_EXTABLE_EX(1b, 2b) \
17165 _ASM_EXTABLE_EX(2b, 3b) \
17166 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
17167 __typeof__(*(ptr)) __pu_val; \
17168 __chk_user_ptr(ptr); \
17169 might_fault(); \
17170 - __pu_val = x; \
17171 + __pu_val = (x); \
17172 + pax_open_userland(); \
17173 switch (sizeof(*(ptr))) { \
17174 case 1: \
17175 __put_user_x(1, __pu_val, ptr, __ret_pu); \
17176 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
17177 __put_user_x(X, __pu_val, ptr, __ret_pu); \
17178 break; \
17179 } \
17180 + pax_close_userland(); \
17181 __ret_pu; \
17182 })
17183
17184 @@ -344,8 +387,10 @@ do { \
17185 } while (0)
17186
17187 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
17188 +do { \
17189 + pax_open_userland(); \
17190 asm volatile(ASM_STAC "\n" \
17191 - "1: mov"itype" %2,%"rtype"1\n" \
17192 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
17193 "2: " ASM_CLAC "\n" \
17194 ".section .fixup,\"ax\"\n" \
17195 "3: mov %3,%0\n" \
17196 @@ -353,8 +398,10 @@ do { \
17197 " jmp 2b\n" \
17198 ".previous\n" \
17199 _ASM_EXTABLE(1b, 3b) \
17200 - : "=r" (err), ltype(x) \
17201 - : "m" (__m(addr)), "i" (errret), "0" (err))
17202 + : "=r" (err), ltype (x) \
17203 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
17204 + pax_close_userland(); \
17205 +} while (0)
17206
17207 #define __get_user_size_ex(x, ptr, size) \
17208 do { \
17209 @@ -378,7 +425,7 @@ do { \
17210 } while (0)
17211
17212 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
17213 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
17214 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
17215 "2:\n" \
17216 _ASM_EXTABLE_EX(1b, 2b) \
17217 : ltype(x) : "m" (__m(addr)))
17218 @@ -395,13 +442,24 @@ do { \
17219 int __gu_err; \
17220 unsigned long __gu_val; \
17221 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
17222 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
17223 + (x) = (__typeof__(*(ptr)))__gu_val; \
17224 __gu_err; \
17225 })
17226
17227 /* FIXME: this hack is definitely wrong -AK */
17228 struct __large_struct { unsigned long buf[100]; };
17229 -#define __m(x) (*(struct __large_struct __user *)(x))
17230 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17231 +#define ____m(x) \
17232 +({ \
17233 + unsigned long ____x = (unsigned long)(x); \
17234 + if (____x < pax_user_shadow_base) \
17235 + ____x += pax_user_shadow_base; \
17236 + (typeof(x))____x; \
17237 +})
17238 +#else
17239 +#define ____m(x) (x)
17240 +#endif
17241 +#define __m(x) (*(struct __large_struct __user *)____m(x))
17242
17243 /*
17244 * Tell gcc we read from memory instead of writing: this is because
17245 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
17246 * aliasing issues.
17247 */
17248 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
17249 +do { \
17250 + pax_open_userland(); \
17251 asm volatile(ASM_STAC "\n" \
17252 - "1: mov"itype" %"rtype"1,%2\n" \
17253 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
17254 "2: " ASM_CLAC "\n" \
17255 ".section .fixup,\"ax\"\n" \
17256 "3: mov %3,%0\n" \
17257 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
17258 ".previous\n" \
17259 _ASM_EXTABLE(1b, 3b) \
17260 : "=r"(err) \
17261 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
17262 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
17263 + pax_close_userland(); \
17264 +} while (0)
17265
17266 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
17267 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
17268 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
17269 "2:\n" \
17270 _ASM_EXTABLE_EX(1b, 2b) \
17271 : : ltype(x), "m" (__m(addr)))
17272 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
17273 */
17274 #define uaccess_try do { \
17275 current_thread_info()->uaccess_err = 0; \
17276 + pax_open_userland(); \
17277 stac(); \
17278 barrier();
17279
17280 #define uaccess_catch(err) \
17281 clac(); \
17282 + pax_close_userland(); \
17283 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
17284 } while (0)
17285
17286 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
17287 * On error, the variable @x is set to zero.
17288 */
17289
17290 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17291 +#define __get_user(x, ptr) get_user((x), (ptr))
17292 +#else
17293 #define __get_user(x, ptr) \
17294 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
17295 +#endif
17296
17297 /**
17298 * __put_user: - Write a simple value into user space, with less checking.
17299 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
17300 * Returns zero on success, or -EFAULT on error.
17301 */
17302
17303 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17304 +#define __put_user(x, ptr) put_user((x), (ptr))
17305 +#else
17306 #define __put_user(x, ptr) \
17307 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
17308 +#endif
17309
17310 #define __get_user_unaligned __get_user
17311 #define __put_user_unaligned __put_user
17312 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
17313 #define get_user_ex(x, ptr) do { \
17314 unsigned long __gue_val; \
17315 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
17316 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
17317 + (x) = (__typeof__(*(ptr)))__gue_val; \
17318 } while (0)
17319
17320 #define put_user_try uaccess_try
17321 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
17322 extern __must_check long strlen_user(const char __user *str);
17323 extern __must_check long strnlen_user(const char __user *str, long n);
17324
17325 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
17326 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
17327 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
17328 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
17329
17330 /*
17331 * movsl can be slow when source and dest are not both 8-byte aligned
17332 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
17333 index 7f760a9..04b1c65 100644
17334 --- a/arch/x86/include/asm/uaccess_32.h
17335 +++ b/arch/x86/include/asm/uaccess_32.h
17336 @@ -11,15 +11,15 @@
17337 #include <asm/page.h>
17338
17339 unsigned long __must_check __copy_to_user_ll
17340 - (void __user *to, const void *from, unsigned long n);
17341 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
17342 unsigned long __must_check __copy_from_user_ll
17343 - (void *to, const void __user *from, unsigned long n);
17344 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
17345 unsigned long __must_check __copy_from_user_ll_nozero
17346 - (void *to, const void __user *from, unsigned long n);
17347 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
17348 unsigned long __must_check __copy_from_user_ll_nocache
17349 - (void *to, const void __user *from, unsigned long n);
17350 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
17351 unsigned long __must_check __copy_from_user_ll_nocache_nozero
17352 - (void *to, const void __user *from, unsigned long n);
17353 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
17354
17355 /**
17356 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
17357 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
17358 static __always_inline unsigned long __must_check
17359 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
17360 {
17361 + if ((long)n < 0)
17362 + return n;
17363 +
17364 + check_object_size(from, n, true);
17365 +
17366 if (__builtin_constant_p(n)) {
17367 unsigned long ret;
17368
17369 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
17370 __copy_to_user(void __user *to, const void *from, unsigned long n)
17371 {
17372 might_fault();
17373 +
17374 return __copy_to_user_inatomic(to, from, n);
17375 }
17376
17377 static __always_inline unsigned long
17378 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
17379 {
17380 + if ((long)n < 0)
17381 + return n;
17382 +
17383 /* Avoid zeroing the tail if the copy fails..
17384 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
17385 * but as the zeroing behaviour is only significant when n is not
17386 @@ -137,6 +146,12 @@ static __always_inline unsigned long
17387 __copy_from_user(void *to, const void __user *from, unsigned long n)
17388 {
17389 might_fault();
17390 +
17391 + if ((long)n < 0)
17392 + return n;
17393 +
17394 + check_object_size(to, n, false);
17395 +
17396 if (__builtin_constant_p(n)) {
17397 unsigned long ret;
17398
17399 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
17400 const void __user *from, unsigned long n)
17401 {
17402 might_fault();
17403 +
17404 + if ((long)n < 0)
17405 + return n;
17406 +
17407 if (__builtin_constant_p(n)) {
17408 unsigned long ret;
17409
17410 @@ -181,15 +200,19 @@ static __always_inline unsigned long
17411 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
17412 unsigned long n)
17413 {
17414 - return __copy_from_user_ll_nocache_nozero(to, from, n);
17415 + if ((long)n < 0)
17416 + return n;
17417 +
17418 + return __copy_from_user_ll_nocache_nozero(to, from, n);
17419 }
17420
17421 -unsigned long __must_check copy_to_user(void __user *to,
17422 - const void *from, unsigned long n);
17423 -unsigned long __must_check _copy_from_user(void *to,
17424 - const void __user *from,
17425 - unsigned long n);
17426 -
17427 +extern void copy_to_user_overflow(void)
17428 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
17429 + __compiletime_error("copy_to_user() buffer size is not provably correct")
17430 +#else
17431 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
17432 +#endif
17433 +;
17434
17435 extern void copy_from_user_overflow(void)
17436 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
17437 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
17438 #endif
17439 ;
17440
17441 -static inline unsigned long __must_check copy_from_user(void *to,
17442 - const void __user *from,
17443 - unsigned long n)
17444 +/**
17445 + * copy_to_user: - Copy a block of data into user space.
17446 + * @to: Destination address, in user space.
17447 + * @from: Source address, in kernel space.
17448 + * @n: Number of bytes to copy.
17449 + *
17450 + * Context: User context only. This function may sleep.
17451 + *
17452 + * Copy data from kernel space to user space.
17453 + *
17454 + * Returns number of bytes that could not be copied.
17455 + * On success, this will be zero.
17456 + */
17457 +static inline unsigned long __must_check
17458 +copy_to_user(void __user *to, const void *from, unsigned long n)
17459 {
17460 - int sz = __compiletime_object_size(to);
17461 + size_t sz = __compiletime_object_size(from);
17462
17463 - if (likely(sz == -1 || sz >= n))
17464 - n = _copy_from_user(to, from, n);
17465 - else
17466 + if (unlikely(sz != (size_t)-1 && sz < n))
17467 + copy_to_user_overflow();
17468 + else if (access_ok(VERIFY_WRITE, to, n))
17469 + n = __copy_to_user(to, from, n);
17470 + return n;
17471 +}
17472 +
17473 +/**
17474 + * copy_from_user: - Copy a block of data from user space.
17475 + * @to: Destination address, in kernel space.
17476 + * @from: Source address, in user space.
17477 + * @n: Number of bytes to copy.
17478 + *
17479 + * Context: User context only. This function may sleep.
17480 + *
17481 + * Copy data from user space to kernel space.
17482 + *
17483 + * Returns number of bytes that could not be copied.
17484 + * On success, this will be zero.
17485 + *
17486 + * If some data could not be copied, this function will pad the copied
17487 + * data to the requested size using zero bytes.
17488 + */
17489 +static inline unsigned long __must_check
17490 +copy_from_user(void *to, const void __user *from, unsigned long n)
17491 +{
17492 + size_t sz = __compiletime_object_size(to);
17493 +
17494 + check_object_size(to, n, false);
17495 +
17496 + if (unlikely(sz != (size_t)-1 && sz < n))
17497 copy_from_user_overflow();
17498 -
17499 + else if (access_ok(VERIFY_READ, from, n))
17500 + n = __copy_from_user(to, from, n);
17501 + else if ((long)n > 0)
17502 + memset(to, 0, n);
17503 return n;
17504 }
17505
17506 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
17507 index 142810c..1f2a0a7 100644
17508 --- a/arch/x86/include/asm/uaccess_64.h
17509 +++ b/arch/x86/include/asm/uaccess_64.h
17510 @@ -10,6 +10,9 @@
17511 #include <asm/alternative.h>
17512 #include <asm/cpufeature.h>
17513 #include <asm/page.h>
17514 +#include <asm/pgtable.h>
17515 +
17516 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
17517
17518 /*
17519 * Copy To/From Userspace
17520 @@ -17,13 +20,13 @@
17521
17522 /* Handles exceptions in both to and from, but doesn't do access_ok */
17523 __must_check unsigned long
17524 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
17525 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
17526 __must_check unsigned long
17527 -copy_user_generic_string(void *to, const void *from, unsigned len);
17528 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
17529 __must_check unsigned long
17530 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
17531 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
17532
17533 -static __always_inline __must_check unsigned long
17534 +static __always_inline __must_check __size_overflow(3) unsigned long
17535 copy_user_generic(void *to, const void *from, unsigned len)
17536 {
17537 unsigned ret;
17538 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
17539 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
17540 "=d" (len)),
17541 "1" (to), "2" (from), "3" (len)
17542 - : "memory", "rcx", "r8", "r9", "r10", "r11");
17543 + : "memory", "rcx", "r8", "r9", "r11");
17544 return ret;
17545 }
17546
17547 +static __always_inline __must_check unsigned long
17548 +__copy_to_user(void __user *to, const void *from, unsigned long len);
17549 +static __always_inline __must_check unsigned long
17550 +__copy_from_user(void *to, const void __user *from, unsigned long len);
17551 __must_check unsigned long
17552 -_copy_to_user(void __user *to, const void *from, unsigned len);
17553 -__must_check unsigned long
17554 -_copy_from_user(void *to, const void __user *from, unsigned len);
17555 -__must_check unsigned long
17556 -copy_in_user(void __user *to, const void __user *from, unsigned len);
17557 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
17558 +
17559 +extern void copy_to_user_overflow(void)
17560 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
17561 + __compiletime_error("copy_to_user() buffer size is not provably correct")
17562 +#else
17563 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
17564 +#endif
17565 +;
17566 +
17567 +extern void copy_from_user_overflow(void)
17568 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
17569 + __compiletime_error("copy_from_user() buffer size is not provably correct")
17570 +#else
17571 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
17572 +#endif
17573 +;
17574
17575 static inline unsigned long __must_check copy_from_user(void *to,
17576 const void __user *from,
17577 unsigned long n)
17578 {
17579 - int sz = __compiletime_object_size(to);
17580 -
17581 might_fault();
17582 - if (likely(sz == -1 || sz >= n))
17583 - n = _copy_from_user(to, from, n);
17584 -#ifdef CONFIG_DEBUG_VM
17585 - else
17586 - WARN(1, "Buffer overflow detected!\n");
17587 -#endif
17588 +
17589 + check_object_size(to, n, false);
17590 +
17591 + if (access_ok(VERIFY_READ, from, n))
17592 + n = __copy_from_user(to, from, n);
17593 + else if (n < INT_MAX)
17594 + memset(to, 0, n);
17595 return n;
17596 }
17597
17598 static __always_inline __must_check
17599 -int copy_to_user(void __user *dst, const void *src, unsigned size)
17600 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
17601 {
17602 might_fault();
17603
17604 - return _copy_to_user(dst, src, size);
17605 + if (access_ok(VERIFY_WRITE, dst, size))
17606 + size = __copy_to_user(dst, src, size);
17607 + return size;
17608 }
17609
17610 static __always_inline __must_check
17611 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
17612 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
17613 {
17614 - int ret = 0;
17615 + size_t sz = __compiletime_object_size(dst);
17616 + unsigned ret = 0;
17617
17618 might_fault();
17619 +
17620 + if (size > INT_MAX)
17621 + return size;
17622 +
17623 + check_object_size(dst, size, false);
17624 +
17625 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17626 + if (!__access_ok(VERIFY_READ, src, size))
17627 + return size;
17628 +#endif
17629 +
17630 + if (unlikely(sz != (size_t)-1 && sz < size)) {
17631 + copy_from_user_overflow();
17632 + return size;
17633 + }
17634 +
17635 if (!__builtin_constant_p(size))
17636 - return copy_user_generic(dst, (__force void *)src, size);
17637 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
17638 switch (size) {
17639 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
17640 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
17641 ret, "b", "b", "=q", 1);
17642 return ret;
17643 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
17644 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
17645 ret, "w", "w", "=r", 2);
17646 return ret;
17647 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
17648 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
17649 ret, "l", "k", "=r", 4);
17650 return ret;
17651 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
17652 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
17653 ret, "q", "", "=r", 8);
17654 return ret;
17655 case 10:
17656 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
17657 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
17658 ret, "q", "", "=r", 10);
17659 if (unlikely(ret))
17660 return ret;
17661 __get_user_asm(*(u16 *)(8 + (char *)dst),
17662 - (u16 __user *)(8 + (char __user *)src),
17663 + (const u16 __user *)(8 + (const char __user *)src),
17664 ret, "w", "w", "=r", 2);
17665 return ret;
17666 case 16:
17667 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
17668 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
17669 ret, "q", "", "=r", 16);
17670 if (unlikely(ret))
17671 return ret;
17672 __get_user_asm(*(u64 *)(8 + (char *)dst),
17673 - (u64 __user *)(8 + (char __user *)src),
17674 + (const u64 __user *)(8 + (const char __user *)src),
17675 ret, "q", "", "=r", 8);
17676 return ret;
17677 default:
17678 - return copy_user_generic(dst, (__force void *)src, size);
17679 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
17680 }
17681 }
17682
17683 static __always_inline __must_check
17684 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
17685 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
17686 {
17687 - int ret = 0;
17688 + size_t sz = __compiletime_object_size(src);
17689 + unsigned ret = 0;
17690
17691 might_fault();
17692 +
17693 + if (size > INT_MAX)
17694 + return size;
17695 +
17696 + check_object_size(src, size, true);
17697 +
17698 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17699 + if (!__access_ok(VERIFY_WRITE, dst, size))
17700 + return size;
17701 +#endif
17702 +
17703 + if (unlikely(sz != (size_t)-1 && sz < size)) {
17704 + copy_to_user_overflow();
17705 + return size;
17706 + }
17707 +
17708 if (!__builtin_constant_p(size))
17709 - return copy_user_generic((__force void *)dst, src, size);
17710 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
17711 switch (size) {
17712 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
17713 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
17714 ret, "b", "b", "iq", 1);
17715 return ret;
17716 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
17717 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
17718 ret, "w", "w", "ir", 2);
17719 return ret;
17720 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
17721 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
17722 ret, "l", "k", "ir", 4);
17723 return ret;
17724 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
17725 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
17726 ret, "q", "", "er", 8);
17727 return ret;
17728 case 10:
17729 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
17730 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
17731 ret, "q", "", "er", 10);
17732 if (unlikely(ret))
17733 return ret;
17734 asm("":::"memory");
17735 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
17736 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
17737 ret, "w", "w", "ir", 2);
17738 return ret;
17739 case 16:
17740 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
17741 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
17742 ret, "q", "", "er", 16);
17743 if (unlikely(ret))
17744 return ret;
17745 asm("":::"memory");
17746 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
17747 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
17748 ret, "q", "", "er", 8);
17749 return ret;
17750 default:
17751 - return copy_user_generic((__force void *)dst, src, size);
17752 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
17753 }
17754 }
17755
17756 static __always_inline __must_check
17757 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17758 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
17759 {
17760 - int ret = 0;
17761 + unsigned ret = 0;
17762
17763 might_fault();
17764 +
17765 + if (size > INT_MAX)
17766 + return size;
17767 +
17768 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17769 + if (!__access_ok(VERIFY_READ, src, size))
17770 + return size;
17771 + if (!__access_ok(VERIFY_WRITE, dst, size))
17772 + return size;
17773 +#endif
17774 +
17775 if (!__builtin_constant_p(size))
17776 - return copy_user_generic((__force void *)dst,
17777 - (__force void *)src, size);
17778 + return copy_user_generic((__force_kernel void *)____m(dst),
17779 + (__force_kernel const void *)____m(src), size);
17780 switch (size) {
17781 case 1: {
17782 u8 tmp;
17783 - __get_user_asm(tmp, (u8 __user *)src,
17784 + __get_user_asm(tmp, (const u8 __user *)src,
17785 ret, "b", "b", "=q", 1);
17786 if (likely(!ret))
17787 __put_user_asm(tmp, (u8 __user *)dst,
17788 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17789 }
17790 case 2: {
17791 u16 tmp;
17792 - __get_user_asm(tmp, (u16 __user *)src,
17793 + __get_user_asm(tmp, (const u16 __user *)src,
17794 ret, "w", "w", "=r", 2);
17795 if (likely(!ret))
17796 __put_user_asm(tmp, (u16 __user *)dst,
17797 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17798
17799 case 4: {
17800 u32 tmp;
17801 - __get_user_asm(tmp, (u32 __user *)src,
17802 + __get_user_asm(tmp, (const u32 __user *)src,
17803 ret, "l", "k", "=r", 4);
17804 if (likely(!ret))
17805 __put_user_asm(tmp, (u32 __user *)dst,
17806 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17807 }
17808 case 8: {
17809 u64 tmp;
17810 - __get_user_asm(tmp, (u64 __user *)src,
17811 + __get_user_asm(tmp, (const u64 __user *)src,
17812 ret, "q", "", "=r", 8);
17813 if (likely(!ret))
17814 __put_user_asm(tmp, (u64 __user *)dst,
17815 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17816 return ret;
17817 }
17818 default:
17819 - return copy_user_generic((__force void *)dst,
17820 - (__force void *)src, size);
17821 + return copy_user_generic((__force_kernel void *)____m(dst),
17822 + (__force_kernel const void *)____m(src), size);
17823 }
17824 }
17825
17826 static __must_check __always_inline int
17827 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
17828 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
17829 {
17830 - return copy_user_generic(dst, (__force const void *)src, size);
17831 + if (size > INT_MAX)
17832 + return size;
17833 +
17834 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17835 + if (!__access_ok(VERIFY_READ, src, size))
17836 + return size;
17837 +#endif
17838 +
17839 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
17840 }
17841
17842 -static __must_check __always_inline int
17843 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
17844 +static __must_check __always_inline unsigned long
17845 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
17846 {
17847 - return copy_user_generic((__force void *)dst, src, size);
17848 + if (size > INT_MAX)
17849 + return size;
17850 +
17851 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17852 + if (!__access_ok(VERIFY_WRITE, dst, size))
17853 + return size;
17854 +#endif
17855 +
17856 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
17857 }
17858
17859 -extern long __copy_user_nocache(void *dst, const void __user *src,
17860 - unsigned size, int zerorest);
17861 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
17862 + unsigned long size, int zerorest) __size_overflow(3);
17863
17864 -static inline int
17865 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
17866 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
17867 {
17868 might_sleep();
17869 +
17870 + if (size > INT_MAX)
17871 + return size;
17872 +
17873 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17874 + if (!__access_ok(VERIFY_READ, src, size))
17875 + return size;
17876 +#endif
17877 +
17878 return __copy_user_nocache(dst, src, size, 1);
17879 }
17880
17881 -static inline int
17882 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
17883 - unsigned size)
17884 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
17885 + unsigned long size)
17886 {
17887 + if (size > INT_MAX)
17888 + return size;
17889 +
17890 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17891 + if (!__access_ok(VERIFY_READ, src, size))
17892 + return size;
17893 +#endif
17894 +
17895 return __copy_user_nocache(dst, src, size, 0);
17896 }
17897
17898 -unsigned long
17899 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
17900 +extern unsigned long
17901 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
17902
17903 #endif /* _ASM_X86_UACCESS_64_H */
17904 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
17905 index 5b238981..77fdd78 100644
17906 --- a/arch/x86/include/asm/word-at-a-time.h
17907 +++ b/arch/x86/include/asm/word-at-a-time.h
17908 @@ -11,7 +11,7 @@
17909 * and shift, for example.
17910 */
17911 struct word_at_a_time {
17912 - const unsigned long one_bits, high_bits;
17913 + unsigned long one_bits, high_bits;
17914 };
17915
17916 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
17917 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
17918 index d8d9922..bf6cecb 100644
17919 --- a/arch/x86/include/asm/x86_init.h
17920 +++ b/arch/x86/include/asm/x86_init.h
17921 @@ -129,7 +129,7 @@ struct x86_init_ops {
17922 struct x86_init_timers timers;
17923 struct x86_init_iommu iommu;
17924 struct x86_init_pci pci;
17925 -};
17926 +} __no_const;
17927
17928 /**
17929 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
17930 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
17931 void (*setup_percpu_clockev)(void);
17932 void (*early_percpu_clock_init)(void);
17933 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
17934 -};
17935 +} __no_const;
17936
17937 /**
17938 * struct x86_platform_ops - platform specific runtime functions
17939 @@ -166,7 +166,7 @@ struct x86_platform_ops {
17940 void (*save_sched_clock_state)(void);
17941 void (*restore_sched_clock_state)(void);
17942 void (*apic_post_init)(void);
17943 -};
17944 +} __no_const;
17945
17946 struct pci_dev;
17947 struct msi_msg;
17948 @@ -180,7 +180,7 @@ struct x86_msi_ops {
17949 void (*teardown_msi_irqs)(struct pci_dev *dev);
17950 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
17951 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
17952 -};
17953 +} __no_const;
17954
17955 struct IO_APIC_route_entry;
17956 struct io_apic_irq_attr;
17957 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
17958 unsigned int destination, int vector,
17959 struct io_apic_irq_attr *attr);
17960 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
17961 -};
17962 +} __no_const;
17963
17964 extern struct x86_init_ops x86_init;
17965 extern struct x86_cpuinit_ops x86_cpuinit;
17966 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
17967 index 0415cda..3b22adc 100644
17968 --- a/arch/x86/include/asm/xsave.h
17969 +++ b/arch/x86/include/asm/xsave.h
17970 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
17971 if (unlikely(err))
17972 return -EFAULT;
17973
17974 + pax_open_userland();
17975 __asm__ __volatile__(ASM_STAC "\n"
17976 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
17977 + "1:"
17978 + __copyuser_seg
17979 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
17980 "2: " ASM_CLAC "\n"
17981 ".section .fixup,\"ax\"\n"
17982 "3: movl $-1,%[err]\n"
17983 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
17984 : [err] "=r" (err)
17985 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
17986 : "memory");
17987 + pax_close_userland();
17988 return err;
17989 }
17990
17991 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
17992 {
17993 int err;
17994 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
17995 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
17996 u32 lmask = mask;
17997 u32 hmask = mask >> 32;
17998
17999 + pax_open_userland();
18000 __asm__ __volatile__(ASM_STAC "\n"
18001 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18002 + "1:"
18003 + __copyuser_seg
18004 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18005 "2: " ASM_CLAC "\n"
18006 ".section .fixup,\"ax\"\n"
18007 "3: movl $-1,%[err]\n"
18008 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18009 : [err] "=r" (err)
18010 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18011 : "memory"); /* memory required? */
18012 + pax_close_userland();
18013 return err;
18014 }
18015
18016 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18017 index bbae024..e1528f9 100644
18018 --- a/arch/x86/include/uapi/asm/e820.h
18019 +++ b/arch/x86/include/uapi/asm/e820.h
18020 @@ -63,7 +63,7 @@ struct e820map {
18021 #define ISA_START_ADDRESS 0xa0000
18022 #define ISA_END_ADDRESS 0x100000
18023
18024 -#define BIOS_BEGIN 0x000a0000
18025 +#define BIOS_BEGIN 0x000c0000
18026 #define BIOS_END 0x00100000
18027
18028 #define BIOS_ROM_BASE 0xffe00000
18029 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18030 index 7bd3bd3..5dac791 100644
18031 --- a/arch/x86/kernel/Makefile
18032 +++ b/arch/x86/kernel/Makefile
18033 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18034 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18035 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18036 obj-y += probe_roms.o
18037 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18038 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18039 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18040 obj-y += syscall_$(BITS).o
18041 obj-$(CONFIG_X86_64) += vsyscall_64.o
18042 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18043 index 230c8ea..f915130 100644
18044 --- a/arch/x86/kernel/acpi/boot.c
18045 +++ b/arch/x86/kernel/acpi/boot.c
18046 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18047 * If your system is blacklisted here, but you find that acpi=force
18048 * works for you, please contact linux-acpi@vger.kernel.org
18049 */
18050 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18051 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18052 /*
18053 * Boxes that need ACPI disabled
18054 */
18055 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18056 };
18057
18058 /* second table for DMI checks that should run after early-quirks */
18059 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18060 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18061 /*
18062 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18063 * which includes some code which overrides all temperature
18064 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18065 index ec94e11..7fbbec0 100644
18066 --- a/arch/x86/kernel/acpi/sleep.c
18067 +++ b/arch/x86/kernel/acpi/sleep.c
18068 @@ -88,8 +88,12 @@ int acpi_suspend_lowlevel(void)
18069 #else /* CONFIG_64BIT */
18070 #ifdef CONFIG_SMP
18071 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18072 +
18073 + pax_open_kernel();
18074 early_gdt_descr.address =
18075 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18076 + pax_close_kernel();
18077 +
18078 initial_gs = per_cpu_offset(smp_processor_id());
18079 #endif
18080 initial_code = (unsigned long)wakeup_long64;
18081 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18082 index d1daa66..59fecba 100644
18083 --- a/arch/x86/kernel/acpi/wakeup_32.S
18084 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18085 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18086 # and restore the stack ... but you need gdt for this to work
18087 movl saved_context_esp, %esp
18088
18089 - movl %cs:saved_magic, %eax
18090 - cmpl $0x12345678, %eax
18091 + cmpl $0x12345678, saved_magic
18092 jne bogus_magic
18093
18094 # jump to place where we left off
18095 - movl saved_eip, %eax
18096 - jmp *%eax
18097 + jmp *(saved_eip)
18098
18099 bogus_magic:
18100 jmp bogus_magic
18101 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18102 index c15cf9a..0e63558 100644
18103 --- a/arch/x86/kernel/alternative.c
18104 +++ b/arch/x86/kernel/alternative.c
18105 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18106 */
18107 for (a = start; a < end; a++) {
18108 instr = (u8 *)&a->instr_offset + a->instr_offset;
18109 +
18110 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18111 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18112 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18113 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18114 +#endif
18115 +
18116 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18117 BUG_ON(a->replacementlen > a->instrlen);
18118 BUG_ON(a->instrlen > sizeof(insnbuf));
18119 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18120 for (poff = start; poff < end; poff++) {
18121 u8 *ptr = (u8 *)poff + *poff;
18122
18123 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18124 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18125 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18126 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18127 +#endif
18128 +
18129 if (!*poff || ptr < text || ptr >= text_end)
18130 continue;
18131 /* turn DS segment override prefix into lock prefix */
18132 - if (*ptr == 0x3e)
18133 + if (*ktla_ktva(ptr) == 0x3e)
18134 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18135 }
18136 mutex_unlock(&text_mutex);
18137 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18138 for (poff = start; poff < end; poff++) {
18139 u8 *ptr = (u8 *)poff + *poff;
18140
18141 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18142 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18143 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18144 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18145 +#endif
18146 +
18147 if (!*poff || ptr < text || ptr >= text_end)
18148 continue;
18149 /* turn lock prefix into DS segment override prefix */
18150 - if (*ptr == 0xf0)
18151 + if (*ktla_ktva(ptr) == 0xf0)
18152 text_poke(ptr, ((unsigned char []){0x3E}), 1);
18153 }
18154 mutex_unlock(&text_mutex);
18155 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
18156
18157 BUG_ON(p->len > MAX_PATCH_LEN);
18158 /* prep the buffer with the original instructions */
18159 - memcpy(insnbuf, p->instr, p->len);
18160 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
18161 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
18162 (unsigned long)p->instr, p->len);
18163
18164 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
18165 if (!uniproc_patched || num_possible_cpus() == 1)
18166 free_init_pages("SMP alternatives",
18167 (unsigned long)__smp_locks,
18168 - (unsigned long)__smp_locks_end);
18169 + PAGE_ALIGN((unsigned long)__smp_locks_end));
18170 #endif
18171
18172 apply_paravirt(__parainstructions, __parainstructions_end);
18173 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
18174 * instructions. And on the local CPU you need to be protected again NMI or MCE
18175 * handlers seeing an inconsistent instruction while you patch.
18176 */
18177 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
18178 +void *__kprobes text_poke_early(void *addr, const void *opcode,
18179 size_t len)
18180 {
18181 unsigned long flags;
18182 local_irq_save(flags);
18183 - memcpy(addr, opcode, len);
18184 +
18185 + pax_open_kernel();
18186 + memcpy(ktla_ktva(addr), opcode, len);
18187 sync_core();
18188 + pax_close_kernel();
18189 +
18190 local_irq_restore(flags);
18191 /* Could also do a CLFLUSH here to speed up CPU recovery; but
18192 that causes hangs on some VIA CPUs. */
18193 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
18194 */
18195 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
18196 {
18197 - unsigned long flags;
18198 - char *vaddr;
18199 + unsigned char *vaddr = ktla_ktva(addr);
18200 struct page *pages[2];
18201 - int i;
18202 + size_t i;
18203
18204 if (!core_kernel_text((unsigned long)addr)) {
18205 - pages[0] = vmalloc_to_page(addr);
18206 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
18207 + pages[0] = vmalloc_to_page(vaddr);
18208 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
18209 } else {
18210 - pages[0] = virt_to_page(addr);
18211 + pages[0] = virt_to_page(vaddr);
18212 WARN_ON(!PageReserved(pages[0]));
18213 - pages[1] = virt_to_page(addr + PAGE_SIZE);
18214 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
18215 }
18216 BUG_ON(!pages[0]);
18217 - local_irq_save(flags);
18218 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
18219 - if (pages[1])
18220 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
18221 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
18222 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
18223 - clear_fixmap(FIX_TEXT_POKE0);
18224 - if (pages[1])
18225 - clear_fixmap(FIX_TEXT_POKE1);
18226 - local_flush_tlb();
18227 - sync_core();
18228 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
18229 - that causes hangs on some VIA CPUs. */
18230 + text_poke_early(addr, opcode, len);
18231 for (i = 0; i < len; i++)
18232 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
18233 - local_irq_restore(flags);
18234 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
18235 return addr;
18236 }
18237
18238 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
18239 index 904611b..004dde6 100644
18240 --- a/arch/x86/kernel/apic/apic.c
18241 +++ b/arch/x86/kernel/apic/apic.c
18242 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
18243 /*
18244 * Debug level, exported for io_apic.c
18245 */
18246 -unsigned int apic_verbosity;
18247 +int apic_verbosity;
18248
18249 int pic_mode;
18250
18251 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
18252 apic_write(APIC_ESR, 0);
18253 v1 = apic_read(APIC_ESR);
18254 ack_APIC_irq();
18255 - atomic_inc(&irq_err_count);
18256 + atomic_inc_unchecked(&irq_err_count);
18257
18258 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
18259 smp_processor_id(), v0 , v1);
18260 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
18261 index 00c77cf..2dc6a2d 100644
18262 --- a/arch/x86/kernel/apic/apic_flat_64.c
18263 +++ b/arch/x86/kernel/apic/apic_flat_64.c
18264 @@ -157,7 +157,7 @@ static int flat_probe(void)
18265 return 1;
18266 }
18267
18268 -static struct apic apic_flat = {
18269 +static struct apic apic_flat __read_only = {
18270 .name = "flat",
18271 .probe = flat_probe,
18272 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
18273 @@ -271,7 +271,7 @@ static int physflat_probe(void)
18274 return 0;
18275 }
18276
18277 -static struct apic apic_physflat = {
18278 +static struct apic apic_physflat __read_only = {
18279
18280 .name = "physical flat",
18281 .probe = physflat_probe,
18282 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
18283 index e145f28..2752888 100644
18284 --- a/arch/x86/kernel/apic/apic_noop.c
18285 +++ b/arch/x86/kernel/apic/apic_noop.c
18286 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
18287 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
18288 }
18289
18290 -struct apic apic_noop = {
18291 +struct apic apic_noop __read_only = {
18292 .name = "noop",
18293 .probe = noop_probe,
18294 .acpi_madt_oem_check = NULL,
18295 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
18296 index d50e364..543bee3 100644
18297 --- a/arch/x86/kernel/apic/bigsmp_32.c
18298 +++ b/arch/x86/kernel/apic/bigsmp_32.c
18299 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
18300 return dmi_bigsmp;
18301 }
18302
18303 -static struct apic apic_bigsmp = {
18304 +static struct apic apic_bigsmp __read_only = {
18305
18306 .name = "bigsmp",
18307 .probe = probe_bigsmp,
18308 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
18309 index 0874799..a7a7892 100644
18310 --- a/arch/x86/kernel/apic/es7000_32.c
18311 +++ b/arch/x86/kernel/apic/es7000_32.c
18312 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
18313 return ret && es7000_apic_is_cluster();
18314 }
18315
18316 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
18317 -static struct apic __refdata apic_es7000_cluster = {
18318 +static struct apic apic_es7000_cluster __read_only = {
18319
18320 .name = "es7000",
18321 .probe = probe_es7000,
18322 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
18323 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
18324 };
18325
18326 -static struct apic __refdata apic_es7000 = {
18327 +static struct apic apic_es7000 __read_only = {
18328
18329 .name = "es7000",
18330 .probe = probe_es7000,
18331 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
18332 index 9ed796c..e930fe4 100644
18333 --- a/arch/x86/kernel/apic/io_apic.c
18334 +++ b/arch/x86/kernel/apic/io_apic.c
18335 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
18336 }
18337 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
18338
18339 -void lock_vector_lock(void)
18340 +void lock_vector_lock(void) __acquires(vector_lock)
18341 {
18342 /* Used to the online set of cpus does not change
18343 * during assign_irq_vector.
18344 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
18345 raw_spin_lock(&vector_lock);
18346 }
18347
18348 -void unlock_vector_lock(void)
18349 +void unlock_vector_lock(void) __releases(vector_lock)
18350 {
18351 raw_spin_unlock(&vector_lock);
18352 }
18353 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
18354 ack_APIC_irq();
18355 }
18356
18357 -atomic_t irq_mis_count;
18358 +atomic_unchecked_t irq_mis_count;
18359
18360 #ifdef CONFIG_GENERIC_PENDING_IRQ
18361 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
18362 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
18363 * at the cpu.
18364 */
18365 if (!(v & (1 << (i & 0x1f)))) {
18366 - atomic_inc(&irq_mis_count);
18367 + atomic_inc_unchecked(&irq_mis_count);
18368
18369 eoi_ioapic_irq(irq, cfg);
18370 }
18371 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
18372 index d661ee9..791fd33 100644
18373 --- a/arch/x86/kernel/apic/numaq_32.c
18374 +++ b/arch/x86/kernel/apic/numaq_32.c
18375 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
18376 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
18377 }
18378
18379 -/* Use __refdata to keep false positive warning calm. */
18380 -static struct apic __refdata apic_numaq = {
18381 +static struct apic apic_numaq __read_only = {
18382
18383 .name = "NUMAQ",
18384 .probe = probe_numaq,
18385 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
18386 index eb35ef9..f184a21 100644
18387 --- a/arch/x86/kernel/apic/probe_32.c
18388 +++ b/arch/x86/kernel/apic/probe_32.c
18389 @@ -72,7 +72,7 @@ static int probe_default(void)
18390 return 1;
18391 }
18392
18393 -static struct apic apic_default = {
18394 +static struct apic apic_default __read_only = {
18395
18396 .name = "default",
18397 .probe = probe_default,
18398 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
18399 index 77c95c0..434f8a4 100644
18400 --- a/arch/x86/kernel/apic/summit_32.c
18401 +++ b/arch/x86/kernel/apic/summit_32.c
18402 @@ -486,7 +486,7 @@ void setup_summit(void)
18403 }
18404 #endif
18405
18406 -static struct apic apic_summit = {
18407 +static struct apic apic_summit __read_only = {
18408
18409 .name = "summit",
18410 .probe = probe_summit,
18411 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
18412 index c88baa4..757aee1 100644
18413 --- a/arch/x86/kernel/apic/x2apic_cluster.c
18414 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
18415 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
18416 return notifier_from_errno(err);
18417 }
18418
18419 -static struct notifier_block __refdata x2apic_cpu_notifier = {
18420 +static struct notifier_block x2apic_cpu_notifier = {
18421 .notifier_call = update_clusterinfo,
18422 };
18423
18424 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
18425 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
18426 }
18427
18428 -static struct apic apic_x2apic_cluster = {
18429 +static struct apic apic_x2apic_cluster __read_only = {
18430
18431 .name = "cluster x2apic",
18432 .probe = x2apic_cluster_probe,
18433 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
18434 index 562a76d..a003c0f 100644
18435 --- a/arch/x86/kernel/apic/x2apic_phys.c
18436 +++ b/arch/x86/kernel/apic/x2apic_phys.c
18437 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
18438 return apic == &apic_x2apic_phys;
18439 }
18440
18441 -static struct apic apic_x2apic_phys = {
18442 +static struct apic apic_x2apic_phys __read_only = {
18443
18444 .name = "physical x2apic",
18445 .probe = x2apic_phys_probe,
18446 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
18447 index 794f6eb..67e1db2 100644
18448 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
18449 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
18450 @@ -342,7 +342,7 @@ static int uv_probe(void)
18451 return apic == &apic_x2apic_uv_x;
18452 }
18453
18454 -static struct apic __refdata apic_x2apic_uv_x = {
18455 +static struct apic apic_x2apic_uv_x __read_only = {
18456
18457 .name = "UV large system",
18458 .probe = uv_probe,
18459 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
18460 index 53a4e27..038760a 100644
18461 --- a/arch/x86/kernel/apm_32.c
18462 +++ b/arch/x86/kernel/apm_32.c
18463 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
18464 * This is for buggy BIOS's that refer to (real mode) segment 0x40
18465 * even though they are called in protected mode.
18466 */
18467 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
18468 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
18469 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
18470
18471 static const char driver_version[] = "1.16ac"; /* no spaces */
18472 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
18473 BUG_ON(cpu != 0);
18474 gdt = get_cpu_gdt_table(cpu);
18475 save_desc_40 = gdt[0x40 / 8];
18476 +
18477 + pax_open_kernel();
18478 gdt[0x40 / 8] = bad_bios_desc;
18479 + pax_close_kernel();
18480
18481 apm_irq_save(flags);
18482 APM_DO_SAVE_SEGS;
18483 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
18484 &call->esi);
18485 APM_DO_RESTORE_SEGS;
18486 apm_irq_restore(flags);
18487 +
18488 + pax_open_kernel();
18489 gdt[0x40 / 8] = save_desc_40;
18490 + pax_close_kernel();
18491 +
18492 put_cpu();
18493
18494 return call->eax & 0xff;
18495 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
18496 BUG_ON(cpu != 0);
18497 gdt = get_cpu_gdt_table(cpu);
18498 save_desc_40 = gdt[0x40 / 8];
18499 +
18500 + pax_open_kernel();
18501 gdt[0x40 / 8] = bad_bios_desc;
18502 + pax_close_kernel();
18503
18504 apm_irq_save(flags);
18505 APM_DO_SAVE_SEGS;
18506 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
18507 &call->eax);
18508 APM_DO_RESTORE_SEGS;
18509 apm_irq_restore(flags);
18510 +
18511 + pax_open_kernel();
18512 gdt[0x40 / 8] = save_desc_40;
18513 + pax_close_kernel();
18514 +
18515 put_cpu();
18516 return error;
18517 }
18518 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
18519 * code to that CPU.
18520 */
18521 gdt = get_cpu_gdt_table(0);
18522 +
18523 + pax_open_kernel();
18524 set_desc_base(&gdt[APM_CS >> 3],
18525 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
18526 set_desc_base(&gdt[APM_CS_16 >> 3],
18527 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
18528 set_desc_base(&gdt[APM_DS >> 3],
18529 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
18530 + pax_close_kernel();
18531
18532 proc_create("apm", 0, NULL, &apm_file_ops);
18533
18534 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
18535 index 2861082..6d4718e 100644
18536 --- a/arch/x86/kernel/asm-offsets.c
18537 +++ b/arch/x86/kernel/asm-offsets.c
18538 @@ -33,6 +33,8 @@ void common(void) {
18539 OFFSET(TI_status, thread_info, status);
18540 OFFSET(TI_addr_limit, thread_info, addr_limit);
18541 OFFSET(TI_preempt_count, thread_info, preempt_count);
18542 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
18543 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
18544
18545 BLANK();
18546 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
18547 @@ -53,8 +55,26 @@ void common(void) {
18548 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
18549 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
18550 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
18551 +
18552 +#ifdef CONFIG_PAX_KERNEXEC
18553 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
18554 #endif
18555
18556 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18557 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
18558 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
18559 +#ifdef CONFIG_X86_64
18560 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
18561 +#endif
18562 +#endif
18563 +
18564 +#endif
18565 +
18566 + BLANK();
18567 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
18568 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
18569 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
18570 +
18571 #ifdef CONFIG_XEN
18572 BLANK();
18573 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
18574 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
18575 index e7c798b..2b2019b 100644
18576 --- a/arch/x86/kernel/asm-offsets_64.c
18577 +++ b/arch/x86/kernel/asm-offsets_64.c
18578 @@ -77,6 +77,7 @@ int main(void)
18579 BLANK();
18580 #undef ENTRY
18581
18582 + DEFINE(TSS_size, sizeof(struct tss_struct));
18583 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
18584 BLANK();
18585
18586 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
18587 index b0684e4..22ccfd7 100644
18588 --- a/arch/x86/kernel/cpu/Makefile
18589 +++ b/arch/x86/kernel/cpu/Makefile
18590 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
18591 CFLAGS_REMOVE_perf_event.o = -pg
18592 endif
18593
18594 -# Make sure load_percpu_segment has no stackprotector
18595 -nostackp := $(call cc-option, -fno-stack-protector)
18596 -CFLAGS_common.o := $(nostackp)
18597 -
18598 obj-y := intel_cacheinfo.o scattered.o topology.o
18599 obj-y += proc.o capflags.o powerflags.o common.o
18600 obj-y += rdrand.o
18601 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
18602 index 5013a48..0782c53 100644
18603 --- a/arch/x86/kernel/cpu/amd.c
18604 +++ b/arch/x86/kernel/cpu/amd.c
18605 @@ -744,7 +744,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
18606 unsigned int size)
18607 {
18608 /* AMD errata T13 (order #21922) */
18609 - if ((c->x86 == 6)) {
18610 + if (c->x86 == 6) {
18611 /* Duron Rev A0 */
18612 if (c->x86_model == 3 && c->x86_mask == 0)
18613 size = 64;
18614 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
18615 index 22018f7..13f5099 100644
18616 --- a/arch/x86/kernel/cpu/common.c
18617 +++ b/arch/x86/kernel/cpu/common.c
18618 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
18619
18620 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
18621
18622 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
18623 -#ifdef CONFIG_X86_64
18624 - /*
18625 - * We need valid kernel segments for data and code in long mode too
18626 - * IRET will check the segment types kkeil 2000/10/28
18627 - * Also sysret mandates a special GDT layout
18628 - *
18629 - * TLS descriptors are currently at a different place compared to i386.
18630 - * Hopefully nobody expects them at a fixed place (Wine?)
18631 - */
18632 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
18633 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
18634 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
18635 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
18636 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
18637 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
18638 -#else
18639 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
18640 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
18641 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
18642 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
18643 - /*
18644 - * Segments used for calling PnP BIOS have byte granularity.
18645 - * They code segments and data segments have fixed 64k limits,
18646 - * the transfer segment sizes are set at run time.
18647 - */
18648 - /* 32-bit code */
18649 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
18650 - /* 16-bit code */
18651 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
18652 - /* 16-bit data */
18653 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
18654 - /* 16-bit data */
18655 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
18656 - /* 16-bit data */
18657 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
18658 - /*
18659 - * The APM segments have byte granularity and their bases
18660 - * are set at run time. All have 64k limits.
18661 - */
18662 - /* 32-bit code */
18663 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
18664 - /* 16-bit code */
18665 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
18666 - /* data */
18667 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
18668 -
18669 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
18670 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
18671 - GDT_STACK_CANARY_INIT
18672 -#endif
18673 -} };
18674 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
18675 -
18676 static int __init x86_xsave_setup(char *s)
18677 {
18678 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
18679 @@ -288,6 +234,52 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
18680 set_in_cr4(X86_CR4_SMAP);
18681 }
18682
18683 +#ifdef CONFIG_X86_64
18684 +static __init int setup_disable_pcid(char *arg)
18685 +{
18686 + setup_clear_cpu_cap(X86_FEATURE_PCID);
18687 +
18688 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18689 + if (clone_pgd_mask != ~(pgdval_t)0UL)
18690 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
18691 +#endif
18692 +
18693 + return 1;
18694 +}
18695 +__setup("nopcid", setup_disable_pcid);
18696 +
18697 +static void setup_pcid(struct cpuinfo_x86 *c)
18698 +{
18699 + if (!cpu_has(c, X86_FEATURE_PCID)) {
18700 +
18701 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18702 + if (pax_user_shadow_base)
18703 + printk("PAX: slow and weak UDEREF enabled\n");
18704 + else
18705 + printk("PAX: UDEREF disabled\n");
18706 +#endif
18707 +
18708 + return;
18709 + }
18710 +
18711 + printk("PAX: PCID detected\n");
18712 + set_in_cr4(X86_CR4_PCIDE);
18713 +
18714 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18715 + clone_pgd_mask = ~(pgdval_t)0UL;
18716 + if (pax_user_shadow_base)
18717 + printk("PAX: weak UDEREF enabled\n");
18718 + else {
18719 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
18720 + printk("PAX: strong UDEREF enabled\n");
18721 + }
18722 +#endif
18723 +
18724 + if (cpu_has(c, X86_FEATURE_INVPCID))
18725 + printk("PAX: INVPCID detected\n");
18726 +}
18727 +#endif
18728 +
18729 /*
18730 * Some CPU features depend on higher CPUID levels, which may not always
18731 * be available due to CPUID level capping or broken virtualization
18732 @@ -386,7 +378,7 @@ void switch_to_new_gdt(int cpu)
18733 {
18734 struct desc_ptr gdt_descr;
18735
18736 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
18737 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
18738 gdt_descr.size = GDT_SIZE - 1;
18739 load_gdt(&gdt_descr);
18740 /* Reload the per-cpu base */
18741 @@ -874,6 +866,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
18742 setup_smep(c);
18743 setup_smap(c);
18744
18745 +#ifdef CONFIG_X86_64
18746 + setup_pcid(c);
18747 +#endif
18748 +
18749 /*
18750 * The vendor-specific functions might have changed features.
18751 * Now we do "generic changes."
18752 @@ -882,6 +878,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
18753 /* Filter out anything that depends on CPUID levels we don't have */
18754 filter_cpuid_features(c, true);
18755
18756 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
18757 + setup_clear_cpu_cap(X86_FEATURE_SEP);
18758 +#endif
18759 +
18760 /* If the model name is still unset, do table lookup. */
18761 if (!c->x86_model_id[0]) {
18762 const char *p;
18763 @@ -1069,10 +1069,12 @@ static __init int setup_disablecpuid(char *arg)
18764 }
18765 __setup("clearcpuid=", setup_disablecpuid);
18766
18767 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
18768 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
18769 +
18770 #ifdef CONFIG_X86_64
18771 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
18772 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
18773 - (unsigned long) nmi_idt_table };
18774 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
18775
18776 DEFINE_PER_CPU_FIRST(union irq_stack_union,
18777 irq_stack_union) __aligned(PAGE_SIZE);
18778 @@ -1086,7 +1088,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
18779 EXPORT_PER_CPU_SYMBOL(current_task);
18780
18781 DEFINE_PER_CPU(unsigned long, kernel_stack) =
18782 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
18783 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
18784 EXPORT_PER_CPU_SYMBOL(kernel_stack);
18785
18786 DEFINE_PER_CPU(char *, irq_stack_ptr) =
18787 @@ -1231,7 +1233,7 @@ void __cpuinit cpu_init(void)
18788 load_ucode_ap();
18789
18790 cpu = stack_smp_processor_id();
18791 - t = &per_cpu(init_tss, cpu);
18792 + t = init_tss + cpu;
18793 oist = &per_cpu(orig_ist, cpu);
18794
18795 #ifdef CONFIG_NUMA
18796 @@ -1257,7 +1259,7 @@ void __cpuinit cpu_init(void)
18797 switch_to_new_gdt(cpu);
18798 loadsegment(fs, 0);
18799
18800 - load_idt((const struct desc_ptr *)&idt_descr);
18801 + load_idt(&idt_descr);
18802
18803 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
18804 syscall_init();
18805 @@ -1266,7 +1268,6 @@ void __cpuinit cpu_init(void)
18806 wrmsrl(MSR_KERNEL_GS_BASE, 0);
18807 barrier();
18808
18809 - x86_configure_nx();
18810 enable_x2apic();
18811
18812 /*
18813 @@ -1318,7 +1319,7 @@ void __cpuinit cpu_init(void)
18814 {
18815 int cpu = smp_processor_id();
18816 struct task_struct *curr = current;
18817 - struct tss_struct *t = &per_cpu(init_tss, cpu);
18818 + struct tss_struct *t = init_tss + cpu;
18819 struct thread_struct *thread = &curr->thread;
18820
18821 show_ucode_info_early();
18822 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
18823 index 7c6f7d5..8cac382 100644
18824 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
18825 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
18826 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
18827 };
18828
18829 #ifdef CONFIG_AMD_NB
18830 +static struct attribute *default_attrs_amd_nb[] = {
18831 + &type.attr,
18832 + &level.attr,
18833 + &coherency_line_size.attr,
18834 + &physical_line_partition.attr,
18835 + &ways_of_associativity.attr,
18836 + &number_of_sets.attr,
18837 + &size.attr,
18838 + &shared_cpu_map.attr,
18839 + &shared_cpu_list.attr,
18840 + NULL,
18841 + NULL,
18842 + NULL,
18843 + NULL
18844 +};
18845 +
18846 static struct attribute ** __cpuinit amd_l3_attrs(void)
18847 {
18848 static struct attribute **attrs;
18849 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
18850
18851 n = ARRAY_SIZE(default_attrs);
18852
18853 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
18854 - n += 2;
18855 -
18856 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
18857 - n += 1;
18858 -
18859 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
18860 - if (attrs == NULL)
18861 - return attrs = default_attrs;
18862 -
18863 - for (n = 0; default_attrs[n]; n++)
18864 - attrs[n] = default_attrs[n];
18865 + attrs = default_attrs_amd_nb;
18866
18867 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
18868 attrs[n++] = &cache_disable_0.attr;
18869 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
18870 .default_attrs = default_attrs,
18871 };
18872
18873 +#ifdef CONFIG_AMD_NB
18874 +static struct kobj_type ktype_cache_amd_nb = {
18875 + .sysfs_ops = &sysfs_ops,
18876 + .default_attrs = default_attrs_amd_nb,
18877 +};
18878 +#endif
18879 +
18880 static struct kobj_type ktype_percpu_entry = {
18881 .sysfs_ops = &sysfs_ops,
18882 };
18883 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
18884 return retval;
18885 }
18886
18887 +#ifdef CONFIG_AMD_NB
18888 + amd_l3_attrs();
18889 +#endif
18890 +
18891 for (i = 0; i < num_cache_leaves; i++) {
18892 + struct kobj_type *ktype;
18893 +
18894 this_object = INDEX_KOBJECT_PTR(cpu, i);
18895 this_object->cpu = cpu;
18896 this_object->index = i;
18897
18898 this_leaf = CPUID4_INFO_IDX(cpu, i);
18899
18900 - ktype_cache.default_attrs = default_attrs;
18901 + ktype = &ktype_cache;
18902 #ifdef CONFIG_AMD_NB
18903 if (this_leaf->base.nb)
18904 - ktype_cache.default_attrs = amd_l3_attrs();
18905 + ktype = &ktype_cache_amd_nb;
18906 #endif
18907 retval = kobject_init_and_add(&(this_object->kobj),
18908 - &ktype_cache,
18909 + ktype,
18910 per_cpu(ici_cache_kobject, cpu),
18911 "index%1lu", i);
18912 if (unlikely(retval)) {
18913 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
18914 return NOTIFY_OK;
18915 }
18916
18917 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
18918 +static struct notifier_block cacheinfo_cpu_notifier = {
18919 .notifier_call = cacheinfo_cpu_callback,
18920 };
18921
18922 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
18923 index 9239504..b2471ce 100644
18924 --- a/arch/x86/kernel/cpu/mcheck/mce.c
18925 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
18926 @@ -45,6 +45,7 @@
18927 #include <asm/processor.h>
18928 #include <asm/mce.h>
18929 #include <asm/msr.h>
18930 +#include <asm/local.h>
18931
18932 #include "mce-internal.h"
18933
18934 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
18935 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
18936 m->cs, m->ip);
18937
18938 - if (m->cs == __KERNEL_CS)
18939 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
18940 print_symbol("{%s}", m->ip);
18941 pr_cont("\n");
18942 }
18943 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
18944
18945 #define PANIC_TIMEOUT 5 /* 5 seconds */
18946
18947 -static atomic_t mce_paniced;
18948 +static atomic_unchecked_t mce_paniced;
18949
18950 static int fake_panic;
18951 -static atomic_t mce_fake_paniced;
18952 +static atomic_unchecked_t mce_fake_paniced;
18953
18954 /* Panic in progress. Enable interrupts and wait for final IPI */
18955 static void wait_for_panic(void)
18956 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
18957 /*
18958 * Make sure only one CPU runs in machine check panic
18959 */
18960 - if (atomic_inc_return(&mce_paniced) > 1)
18961 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
18962 wait_for_panic();
18963 barrier();
18964
18965 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
18966 console_verbose();
18967 } else {
18968 /* Don't log too much for fake panic */
18969 - if (atomic_inc_return(&mce_fake_paniced) > 1)
18970 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
18971 return;
18972 }
18973 /* First print corrected ones that are still unlogged */
18974 @@ -353,7 +354,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
18975 if (!fake_panic) {
18976 if (panic_timeout == 0)
18977 panic_timeout = mca_cfg.panic_timeout;
18978 - panic(msg);
18979 + panic("%s", msg);
18980 } else
18981 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
18982 }
18983 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
18984 * might have been modified by someone else.
18985 */
18986 rmb();
18987 - if (atomic_read(&mce_paniced))
18988 + if (atomic_read_unchecked(&mce_paniced))
18989 wait_for_panic();
18990 if (!mca_cfg.monarch_timeout)
18991 goto out;
18992 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
18993 }
18994
18995 /* Call the installed machine check handler for this CPU setup. */
18996 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
18997 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
18998 unexpected_machine_check;
18999
19000 /*
19001 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
19002 return;
19003 }
19004
19005 + pax_open_kernel();
19006 machine_check_vector = do_machine_check;
19007 + pax_close_kernel();
19008
19009 __mcheck_cpu_init_generic();
19010 __mcheck_cpu_init_vendor(c);
19011 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
19012 */
19013
19014 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19015 -static int mce_chrdev_open_count; /* #times opened */
19016 +static local_t mce_chrdev_open_count; /* #times opened */
19017 static int mce_chrdev_open_exclu; /* already open exclusive? */
19018
19019 static int mce_chrdev_open(struct inode *inode, struct file *file)
19020 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19021 spin_lock(&mce_chrdev_state_lock);
19022
19023 if (mce_chrdev_open_exclu ||
19024 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19025 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19026 spin_unlock(&mce_chrdev_state_lock);
19027
19028 return -EBUSY;
19029 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19030
19031 if (file->f_flags & O_EXCL)
19032 mce_chrdev_open_exclu = 1;
19033 - mce_chrdev_open_count++;
19034 + local_inc(&mce_chrdev_open_count);
19035
19036 spin_unlock(&mce_chrdev_state_lock);
19037
19038 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19039 {
19040 spin_lock(&mce_chrdev_state_lock);
19041
19042 - mce_chrdev_open_count--;
19043 + local_dec(&mce_chrdev_open_count);
19044 mce_chrdev_open_exclu = 0;
19045
19046 spin_unlock(&mce_chrdev_state_lock);
19047 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
19048 return NOTIFY_OK;
19049 }
19050
19051 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
19052 +static struct notifier_block mce_cpu_notifier = {
19053 .notifier_call = mce_cpu_callback,
19054 };
19055
19056 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
19057
19058 for (i = 0; i < mca_cfg.banks; i++) {
19059 struct mce_bank *b = &mce_banks[i];
19060 - struct device_attribute *a = &b->attr;
19061 + device_attribute_no_const *a = &b->attr;
19062
19063 sysfs_attr_init(&a->attr);
19064 a->attr.name = b->attrname;
19065 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
19066 static void mce_reset(void)
19067 {
19068 cpu_missing = 0;
19069 - atomic_set(&mce_fake_paniced, 0);
19070 + atomic_set_unchecked(&mce_fake_paniced, 0);
19071 atomic_set(&mce_executing, 0);
19072 atomic_set(&mce_callin, 0);
19073 atomic_set(&global_nwo, 0);
19074 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19075 index 1c044b1..37a2a43 100644
19076 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19077 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19078 @@ -11,6 +11,7 @@
19079 #include <asm/processor.h>
19080 #include <asm/mce.h>
19081 #include <asm/msr.h>
19082 +#include <asm/pgtable.h>
19083
19084 /* By default disabled */
19085 int mce_p5_enabled __read_mostly;
19086 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19087 if (!cpu_has(c, X86_FEATURE_MCE))
19088 return;
19089
19090 + pax_open_kernel();
19091 machine_check_vector = pentium_machine_check;
19092 + pax_close_kernel();
19093 /* Make sure the vector pointer is visible before we enable MCEs: */
19094 wmb();
19095
19096 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
19097 index 47a1870..8c019a7 100644
19098 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
19099 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
19100 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
19101 return notifier_from_errno(err);
19102 }
19103
19104 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
19105 +static struct notifier_block thermal_throttle_cpu_notifier =
19106 {
19107 .notifier_call = thermal_throttle_cpu_callback,
19108 };
19109 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19110 index e9a701a..35317d6 100644
19111 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19112 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19113 @@ -10,6 +10,7 @@
19114 #include <asm/processor.h>
19115 #include <asm/mce.h>
19116 #include <asm/msr.h>
19117 +#include <asm/pgtable.h>
19118
19119 /* Machine check handler for WinChip C6: */
19120 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19121 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19122 {
19123 u32 lo, hi;
19124
19125 + pax_open_kernel();
19126 machine_check_vector = winchip_machine_check;
19127 + pax_close_kernel();
19128 /* Make sure the vector pointer is visible before we enable MCEs: */
19129 wmb();
19130
19131 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19132 index ca22b73..9987afe 100644
19133 --- a/arch/x86/kernel/cpu/mtrr/main.c
19134 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19135 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19136 u64 size_or_mask, size_and_mask;
19137 static bool mtrr_aps_delayed_init;
19138
19139 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19140 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19141
19142 const struct mtrr_ops *mtrr_if;
19143
19144 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19145 index df5e41f..816c719 100644
19146 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19147 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19148 @@ -25,7 +25,7 @@ struct mtrr_ops {
19149 int (*validate_add_page)(unsigned long base, unsigned long size,
19150 unsigned int type);
19151 int (*have_wrcomb)(void);
19152 -};
19153 +} __do_const;
19154
19155 extern int generic_get_free_region(unsigned long base, unsigned long size,
19156 int replace_reg);
19157 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19158 index 1025f3c..824f677 100644
19159 --- a/arch/x86/kernel/cpu/perf_event.c
19160 +++ b/arch/x86/kernel/cpu/perf_event.c
19161 @@ -1311,7 +1311,7 @@ static void __init pmu_check_apic(void)
19162 pr_info("no hardware sampling interrupt available.\n");
19163 }
19164
19165 -static struct attribute_group x86_pmu_format_group = {
19166 +static attribute_group_no_const x86_pmu_format_group = {
19167 .name = "format",
19168 .attrs = NULL,
19169 };
19170 @@ -1410,7 +1410,7 @@ static struct attribute *events_attr[] = {
19171 NULL,
19172 };
19173
19174 -static struct attribute_group x86_pmu_events_group = {
19175 +static attribute_group_no_const x86_pmu_events_group = {
19176 .name = "events",
19177 .attrs = events_attr,
19178 };
19179 @@ -1920,7 +1920,7 @@ static unsigned long get_segment_base(unsigned int segment)
19180 if (idx > GDT_ENTRIES)
19181 return 0;
19182
19183 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
19184 + desc = get_cpu_gdt_table(smp_processor_id());
19185 }
19186
19187 return get_desc_base(desc + idx);
19188 @@ -2010,7 +2010,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
19189 break;
19190
19191 perf_callchain_store(entry, frame.return_address);
19192 - fp = frame.next_frame;
19193 + fp = (const void __force_user *)frame.next_frame;
19194 }
19195 }
19196
19197 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
19198 index a9e2207..d70c83a 100644
19199 --- a/arch/x86/kernel/cpu/perf_event_intel.c
19200 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
19201 @@ -2022,10 +2022,10 @@ __init int intel_pmu_init(void)
19202 * v2 and above have a perf capabilities MSR
19203 */
19204 if (version > 1) {
19205 - u64 capabilities;
19206 + u64 capabilities = x86_pmu.intel_cap.capabilities;
19207
19208 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
19209 - x86_pmu.intel_cap.capabilities = capabilities;
19210 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
19211 + x86_pmu.intel_cap.capabilities = capabilities;
19212 }
19213
19214 intel_ds_init();
19215 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
19216 index 52441a2..f94fae8 100644
19217 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
19218 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
19219 @@ -3093,7 +3093,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
19220 static int __init uncore_type_init(struct intel_uncore_type *type)
19221 {
19222 struct intel_uncore_pmu *pmus;
19223 - struct attribute_group *attr_group;
19224 + attribute_group_no_const *attr_group;
19225 struct attribute **attrs;
19226 int i, j;
19227
19228 @@ -3518,7 +3518,7 @@ static int
19229 return NOTIFY_OK;
19230 }
19231
19232 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
19233 +static struct notifier_block uncore_cpu_nb = {
19234 .notifier_call = uncore_cpu_notifier,
19235 /*
19236 * to migrate uncore events, our notifier should be executed
19237 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
19238 index f952891..4722ad4 100644
19239 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
19240 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
19241 @@ -488,7 +488,7 @@ struct intel_uncore_box {
19242 struct uncore_event_desc {
19243 struct kobj_attribute attr;
19244 const char *config;
19245 -};
19246 +} __do_const;
19247
19248 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
19249 { \
19250 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
19251 index 1e4dbcf..b9a34c2 100644
19252 --- a/arch/x86/kernel/cpuid.c
19253 +++ b/arch/x86/kernel/cpuid.c
19254 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
19255 return notifier_from_errno(err);
19256 }
19257
19258 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
19259 +static struct notifier_block cpuid_class_cpu_notifier =
19260 {
19261 .notifier_call = cpuid_class_cpu_callback,
19262 };
19263 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
19264 index 74467fe..18793d5 100644
19265 --- a/arch/x86/kernel/crash.c
19266 +++ b/arch/x86/kernel/crash.c
19267 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
19268 {
19269 #ifdef CONFIG_X86_32
19270 struct pt_regs fixed_regs;
19271 -#endif
19272
19273 -#ifdef CONFIG_X86_32
19274 - if (!user_mode_vm(regs)) {
19275 + if (!user_mode(regs)) {
19276 crash_fixup_ss_esp(&fixed_regs, regs);
19277 regs = &fixed_regs;
19278 }
19279 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
19280 index afa64ad..dce67dd 100644
19281 --- a/arch/x86/kernel/crash_dump_64.c
19282 +++ b/arch/x86/kernel/crash_dump_64.c
19283 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
19284 return -ENOMEM;
19285
19286 if (userbuf) {
19287 - if (copy_to_user(buf, vaddr + offset, csize)) {
19288 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
19289 iounmap(vaddr);
19290 return -EFAULT;
19291 }
19292 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
19293 index 155a13f..1672b9b 100644
19294 --- a/arch/x86/kernel/doublefault_32.c
19295 +++ b/arch/x86/kernel/doublefault_32.c
19296 @@ -11,7 +11,7 @@
19297
19298 #define DOUBLEFAULT_STACKSIZE (1024)
19299 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
19300 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
19301 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
19302
19303 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
19304
19305 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
19306 unsigned long gdt, tss;
19307
19308 native_store_gdt(&gdt_desc);
19309 - gdt = gdt_desc.address;
19310 + gdt = (unsigned long)gdt_desc.address;
19311
19312 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
19313
19314 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
19315 /* 0x2 bit is always set */
19316 .flags = X86_EFLAGS_SF | 0x2,
19317 .sp = STACK_START,
19318 - .es = __USER_DS,
19319 + .es = __KERNEL_DS,
19320 .cs = __KERNEL_CS,
19321 .ss = __KERNEL_DS,
19322 - .ds = __USER_DS,
19323 + .ds = __KERNEL_DS,
19324 .fs = __KERNEL_PERCPU,
19325
19326 .__cr3 = __pa_nodebug(swapper_pg_dir),
19327 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
19328 index deb6421..76bbc12 100644
19329 --- a/arch/x86/kernel/dumpstack.c
19330 +++ b/arch/x86/kernel/dumpstack.c
19331 @@ -2,6 +2,9 @@
19332 * Copyright (C) 1991, 1992 Linus Torvalds
19333 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
19334 */
19335 +#ifdef CONFIG_GRKERNSEC_HIDESYM
19336 +#define __INCLUDED_BY_HIDESYM 1
19337 +#endif
19338 #include <linux/kallsyms.h>
19339 #include <linux/kprobes.h>
19340 #include <linux/uaccess.h>
19341 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
19342 static void
19343 print_ftrace_graph_addr(unsigned long addr, void *data,
19344 const struct stacktrace_ops *ops,
19345 - struct thread_info *tinfo, int *graph)
19346 + struct task_struct *task, int *graph)
19347 {
19348 - struct task_struct *task;
19349 unsigned long ret_addr;
19350 int index;
19351
19352 if (addr != (unsigned long)return_to_handler)
19353 return;
19354
19355 - task = tinfo->task;
19356 index = task->curr_ret_stack;
19357
19358 if (!task->ret_stack || index < *graph)
19359 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
19360 static inline void
19361 print_ftrace_graph_addr(unsigned long addr, void *data,
19362 const struct stacktrace_ops *ops,
19363 - struct thread_info *tinfo, int *graph)
19364 + struct task_struct *task, int *graph)
19365 { }
19366 #endif
19367
19368 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
19369 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
19370 */
19371
19372 -static inline int valid_stack_ptr(struct thread_info *tinfo,
19373 - void *p, unsigned int size, void *end)
19374 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
19375 {
19376 - void *t = tinfo;
19377 if (end) {
19378 if (p < end && p >= (end-THREAD_SIZE))
19379 return 1;
19380 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
19381 }
19382
19383 unsigned long
19384 -print_context_stack(struct thread_info *tinfo,
19385 +print_context_stack(struct task_struct *task, void *stack_start,
19386 unsigned long *stack, unsigned long bp,
19387 const struct stacktrace_ops *ops, void *data,
19388 unsigned long *end, int *graph)
19389 {
19390 struct stack_frame *frame = (struct stack_frame *)bp;
19391
19392 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
19393 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
19394 unsigned long addr;
19395
19396 addr = *stack;
19397 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
19398 } else {
19399 ops->address(data, addr, 0);
19400 }
19401 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
19402 + print_ftrace_graph_addr(addr, data, ops, task, graph);
19403 }
19404 stack++;
19405 }
19406 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
19407 EXPORT_SYMBOL_GPL(print_context_stack);
19408
19409 unsigned long
19410 -print_context_stack_bp(struct thread_info *tinfo,
19411 +print_context_stack_bp(struct task_struct *task, void *stack_start,
19412 unsigned long *stack, unsigned long bp,
19413 const struct stacktrace_ops *ops, void *data,
19414 unsigned long *end, int *graph)
19415 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
19416 struct stack_frame *frame = (struct stack_frame *)bp;
19417 unsigned long *ret_addr = &frame->return_address;
19418
19419 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
19420 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
19421 unsigned long addr = *ret_addr;
19422
19423 if (!__kernel_text_address(addr))
19424 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
19425 ops->address(data, addr, 1);
19426 frame = frame->next_frame;
19427 ret_addr = &frame->return_address;
19428 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
19429 + print_ftrace_graph_addr(addr, data, ops, task, graph);
19430 }
19431
19432 return (unsigned long)frame;
19433 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
19434 static void print_trace_address(void *data, unsigned long addr, int reliable)
19435 {
19436 touch_nmi_watchdog();
19437 - printk(data);
19438 + printk("%s", (char *)data);
19439 printk_address(addr, reliable);
19440 }
19441
19442 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
19443 }
19444 EXPORT_SYMBOL_GPL(oops_begin);
19445
19446 +extern void gr_handle_kernel_exploit(void);
19447 +
19448 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
19449 {
19450 if (regs && kexec_should_crash(current))
19451 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
19452 panic("Fatal exception in interrupt");
19453 if (panic_on_oops)
19454 panic("Fatal exception");
19455 - do_exit(signr);
19456 +
19457 + gr_handle_kernel_exploit();
19458 +
19459 + do_group_exit(signr);
19460 }
19461
19462 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
19463 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
19464 print_modules();
19465 show_regs(regs);
19466 #ifdef CONFIG_X86_32
19467 - if (user_mode_vm(regs)) {
19468 + if (user_mode(regs)) {
19469 sp = regs->sp;
19470 ss = regs->ss & 0xffff;
19471 } else {
19472 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
19473 unsigned long flags = oops_begin();
19474 int sig = SIGSEGV;
19475
19476 - if (!user_mode_vm(regs))
19477 + if (!user_mode(regs))
19478 report_bug(regs->ip, regs);
19479
19480 if (__die(str, regs, err))
19481 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
19482 index f2a1770..540657f 100644
19483 --- a/arch/x86/kernel/dumpstack_32.c
19484 +++ b/arch/x86/kernel/dumpstack_32.c
19485 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19486 bp = stack_frame(task, regs);
19487
19488 for (;;) {
19489 - struct thread_info *context;
19490 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
19491
19492 - context = (struct thread_info *)
19493 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
19494 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
19495 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
19496
19497 - stack = (unsigned long *)context->previous_esp;
19498 - if (!stack)
19499 + if (stack_start == task_stack_page(task))
19500 break;
19501 + stack = *(unsigned long **)stack_start;
19502 if (ops->stack(data, "IRQ") < 0)
19503 break;
19504 touch_nmi_watchdog();
19505 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
19506 int i;
19507
19508 show_regs_print_info(KERN_EMERG);
19509 - __show_regs(regs, !user_mode_vm(regs));
19510 + __show_regs(regs, !user_mode(regs));
19511
19512 /*
19513 * When in-kernel, we also print out the stack and code at the
19514 * time of the fault..
19515 */
19516 - if (!user_mode_vm(regs)) {
19517 + if (!user_mode(regs)) {
19518 unsigned int code_prologue = code_bytes * 43 / 64;
19519 unsigned int code_len = code_bytes;
19520 unsigned char c;
19521 u8 *ip;
19522 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
19523
19524 pr_emerg("Stack:\n");
19525 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
19526
19527 pr_emerg("Code:");
19528
19529 - ip = (u8 *)regs->ip - code_prologue;
19530 + ip = (u8 *)regs->ip - code_prologue + cs_base;
19531 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
19532 /* try starting at IP */
19533 - ip = (u8 *)regs->ip;
19534 + ip = (u8 *)regs->ip + cs_base;
19535 code_len = code_len - code_prologue + 1;
19536 }
19537 for (i = 0; i < code_len; i++, ip++) {
19538 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
19539 pr_cont(" Bad EIP value.");
19540 break;
19541 }
19542 - if (ip == (u8 *)regs->ip)
19543 + if (ip == (u8 *)regs->ip + cs_base)
19544 pr_cont(" <%02x>", c);
19545 else
19546 pr_cont(" %02x", c);
19547 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
19548 {
19549 unsigned short ud2;
19550
19551 + ip = ktla_ktva(ip);
19552 if (ip < PAGE_OFFSET)
19553 return 0;
19554 if (probe_kernel_address((unsigned short *)ip, ud2))
19555 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
19556
19557 return ud2 == 0x0b0f;
19558 }
19559 +
19560 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19561 +void pax_check_alloca(unsigned long size)
19562 +{
19563 + unsigned long sp = (unsigned long)&sp, stack_left;
19564 +
19565 + /* all kernel stacks are of the same size */
19566 + stack_left = sp & (THREAD_SIZE - 1);
19567 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
19568 +}
19569 +EXPORT_SYMBOL(pax_check_alloca);
19570 +#endif
19571 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
19572 index addb207..99635fa 100644
19573 --- a/arch/x86/kernel/dumpstack_64.c
19574 +++ b/arch/x86/kernel/dumpstack_64.c
19575 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19576 unsigned long *irq_stack_end =
19577 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
19578 unsigned used = 0;
19579 - struct thread_info *tinfo;
19580 int graph = 0;
19581 unsigned long dummy;
19582 + void *stack_start;
19583
19584 if (!task)
19585 task = current;
19586 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19587 * current stack address. If the stacks consist of nested
19588 * exceptions
19589 */
19590 - tinfo = task_thread_info(task);
19591 for (;;) {
19592 char *id;
19593 unsigned long *estack_end;
19594 +
19595 estack_end = in_exception_stack(cpu, (unsigned long)stack,
19596 &used, &id);
19597
19598 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19599 if (ops->stack(data, id) < 0)
19600 break;
19601
19602 - bp = ops->walk_stack(tinfo, stack, bp, ops,
19603 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
19604 data, estack_end, &graph);
19605 ops->stack(data, "<EOE>");
19606 /*
19607 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19608 * second-to-last pointer (index -2 to end) in the
19609 * exception stack:
19610 */
19611 + if ((u16)estack_end[-1] != __KERNEL_DS)
19612 + goto out;
19613 stack = (unsigned long *) estack_end[-2];
19614 continue;
19615 }
19616 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19617 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
19618 if (ops->stack(data, "IRQ") < 0)
19619 break;
19620 - bp = ops->walk_stack(tinfo, stack, bp,
19621 + bp = ops->walk_stack(task, irq_stack, stack, bp,
19622 ops, data, irq_stack_end, &graph);
19623 /*
19624 * We link to the next stack (which would be
19625 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19626 /*
19627 * This handles the process stack:
19628 */
19629 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
19630 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
19631 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
19632 +out:
19633 put_cpu();
19634 }
19635 EXPORT_SYMBOL(dump_trace);
19636 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
19637
19638 return ud2 == 0x0b0f;
19639 }
19640 +
19641 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19642 +void pax_check_alloca(unsigned long size)
19643 +{
19644 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
19645 + unsigned cpu, used;
19646 + char *id;
19647 +
19648 + /* check the process stack first */
19649 + stack_start = (unsigned long)task_stack_page(current);
19650 + stack_end = stack_start + THREAD_SIZE;
19651 + if (likely(stack_start <= sp && sp < stack_end)) {
19652 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
19653 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
19654 + return;
19655 + }
19656 +
19657 + cpu = get_cpu();
19658 +
19659 + /* check the irq stacks */
19660 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
19661 + stack_start = stack_end - IRQ_STACK_SIZE;
19662 + if (stack_start <= sp && sp < stack_end) {
19663 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
19664 + put_cpu();
19665 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
19666 + return;
19667 + }
19668 +
19669 + /* check the exception stacks */
19670 + used = 0;
19671 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
19672 + stack_start = stack_end - EXCEPTION_STKSZ;
19673 + if (stack_end && stack_start <= sp && sp < stack_end) {
19674 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
19675 + put_cpu();
19676 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
19677 + return;
19678 + }
19679 +
19680 + put_cpu();
19681 +
19682 + /* unknown stack */
19683 + BUG();
19684 +}
19685 +EXPORT_SYMBOL(pax_check_alloca);
19686 +#endif
19687 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
19688 index d32abea..74daf4f 100644
19689 --- a/arch/x86/kernel/e820.c
19690 +++ b/arch/x86/kernel/e820.c
19691 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
19692
19693 static void early_panic(char *msg)
19694 {
19695 - early_printk(msg);
19696 - panic(msg);
19697 + early_printk("%s", msg);
19698 + panic("%s", msg);
19699 }
19700
19701 static int userdef __initdata;
19702 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
19703 index d15f575..d692043 100644
19704 --- a/arch/x86/kernel/early_printk.c
19705 +++ b/arch/x86/kernel/early_printk.c
19706 @@ -7,6 +7,7 @@
19707 #include <linux/pci_regs.h>
19708 #include <linux/pci_ids.h>
19709 #include <linux/errno.h>
19710 +#include <linux/sched.h>
19711 #include <asm/io.h>
19712 #include <asm/processor.h>
19713 #include <asm/fcntl.h>
19714 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
19715 index 8f3e2de..6b71e39 100644
19716 --- a/arch/x86/kernel/entry_32.S
19717 +++ b/arch/x86/kernel/entry_32.S
19718 @@ -177,13 +177,153 @@
19719 /*CFI_REL_OFFSET gs, PT_GS*/
19720 .endm
19721 .macro SET_KERNEL_GS reg
19722 +
19723 +#ifdef CONFIG_CC_STACKPROTECTOR
19724 movl $(__KERNEL_STACK_CANARY), \reg
19725 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
19726 + movl $(__USER_DS), \reg
19727 +#else
19728 + xorl \reg, \reg
19729 +#endif
19730 +
19731 movl \reg, %gs
19732 .endm
19733
19734 #endif /* CONFIG_X86_32_LAZY_GS */
19735
19736 -.macro SAVE_ALL
19737 +.macro pax_enter_kernel
19738 +#ifdef CONFIG_PAX_KERNEXEC
19739 + call pax_enter_kernel
19740 +#endif
19741 +.endm
19742 +
19743 +.macro pax_exit_kernel
19744 +#ifdef CONFIG_PAX_KERNEXEC
19745 + call pax_exit_kernel
19746 +#endif
19747 +.endm
19748 +
19749 +#ifdef CONFIG_PAX_KERNEXEC
19750 +ENTRY(pax_enter_kernel)
19751 +#ifdef CONFIG_PARAVIRT
19752 + pushl %eax
19753 + pushl %ecx
19754 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
19755 + mov %eax, %esi
19756 +#else
19757 + mov %cr0, %esi
19758 +#endif
19759 + bts $16, %esi
19760 + jnc 1f
19761 + mov %cs, %esi
19762 + cmp $__KERNEL_CS, %esi
19763 + jz 3f
19764 + ljmp $__KERNEL_CS, $3f
19765 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
19766 +2:
19767 +#ifdef CONFIG_PARAVIRT
19768 + mov %esi, %eax
19769 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
19770 +#else
19771 + mov %esi, %cr0
19772 +#endif
19773 +3:
19774 +#ifdef CONFIG_PARAVIRT
19775 + popl %ecx
19776 + popl %eax
19777 +#endif
19778 + ret
19779 +ENDPROC(pax_enter_kernel)
19780 +
19781 +ENTRY(pax_exit_kernel)
19782 +#ifdef CONFIG_PARAVIRT
19783 + pushl %eax
19784 + pushl %ecx
19785 +#endif
19786 + mov %cs, %esi
19787 + cmp $__KERNEXEC_KERNEL_CS, %esi
19788 + jnz 2f
19789 +#ifdef CONFIG_PARAVIRT
19790 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
19791 + mov %eax, %esi
19792 +#else
19793 + mov %cr0, %esi
19794 +#endif
19795 + btr $16, %esi
19796 + ljmp $__KERNEL_CS, $1f
19797 +1:
19798 +#ifdef CONFIG_PARAVIRT
19799 + mov %esi, %eax
19800 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
19801 +#else
19802 + mov %esi, %cr0
19803 +#endif
19804 +2:
19805 +#ifdef CONFIG_PARAVIRT
19806 + popl %ecx
19807 + popl %eax
19808 +#endif
19809 + ret
19810 +ENDPROC(pax_exit_kernel)
19811 +#endif
19812 +
19813 + .macro pax_erase_kstack
19814 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19815 + call pax_erase_kstack
19816 +#endif
19817 + .endm
19818 +
19819 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19820 +/*
19821 + * ebp: thread_info
19822 + */
19823 +ENTRY(pax_erase_kstack)
19824 + pushl %edi
19825 + pushl %ecx
19826 + pushl %eax
19827 +
19828 + mov TI_lowest_stack(%ebp), %edi
19829 + mov $-0xBEEF, %eax
19830 + std
19831 +
19832 +1: mov %edi, %ecx
19833 + and $THREAD_SIZE_asm - 1, %ecx
19834 + shr $2, %ecx
19835 + repne scasl
19836 + jecxz 2f
19837 +
19838 + cmp $2*16, %ecx
19839 + jc 2f
19840 +
19841 + mov $2*16, %ecx
19842 + repe scasl
19843 + jecxz 2f
19844 + jne 1b
19845 +
19846 +2: cld
19847 + mov %esp, %ecx
19848 + sub %edi, %ecx
19849 +
19850 + cmp $THREAD_SIZE_asm, %ecx
19851 + jb 3f
19852 + ud2
19853 +3:
19854 +
19855 + shr $2, %ecx
19856 + rep stosl
19857 +
19858 + mov TI_task_thread_sp0(%ebp), %edi
19859 + sub $128, %edi
19860 + mov %edi, TI_lowest_stack(%ebp)
19861 +
19862 + popl %eax
19863 + popl %ecx
19864 + popl %edi
19865 + ret
19866 +ENDPROC(pax_erase_kstack)
19867 +#endif
19868 +
19869 +.macro __SAVE_ALL _DS
19870 cld
19871 PUSH_GS
19872 pushl_cfi %fs
19873 @@ -206,7 +346,7 @@
19874 CFI_REL_OFFSET ecx, 0
19875 pushl_cfi %ebx
19876 CFI_REL_OFFSET ebx, 0
19877 - movl $(__USER_DS), %edx
19878 + movl $\_DS, %edx
19879 movl %edx, %ds
19880 movl %edx, %es
19881 movl $(__KERNEL_PERCPU), %edx
19882 @@ -214,6 +354,15 @@
19883 SET_KERNEL_GS %edx
19884 .endm
19885
19886 +.macro SAVE_ALL
19887 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
19888 + __SAVE_ALL __KERNEL_DS
19889 + pax_enter_kernel
19890 +#else
19891 + __SAVE_ALL __USER_DS
19892 +#endif
19893 +.endm
19894 +
19895 .macro RESTORE_INT_REGS
19896 popl_cfi %ebx
19897 CFI_RESTORE ebx
19898 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
19899 popfl_cfi
19900 jmp syscall_exit
19901 CFI_ENDPROC
19902 -END(ret_from_fork)
19903 +ENDPROC(ret_from_fork)
19904
19905 ENTRY(ret_from_kernel_thread)
19906 CFI_STARTPROC
19907 @@ -344,7 +493,15 @@ ret_from_intr:
19908 andl $SEGMENT_RPL_MASK, %eax
19909 #endif
19910 cmpl $USER_RPL, %eax
19911 +
19912 +#ifdef CONFIG_PAX_KERNEXEC
19913 + jae resume_userspace
19914 +
19915 + pax_exit_kernel
19916 + jmp resume_kernel
19917 +#else
19918 jb resume_kernel # not returning to v8086 or userspace
19919 +#endif
19920
19921 ENTRY(resume_userspace)
19922 LOCKDEP_SYS_EXIT
19923 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
19924 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
19925 # int/exception return?
19926 jne work_pending
19927 - jmp restore_all
19928 -END(ret_from_exception)
19929 + jmp restore_all_pax
19930 +ENDPROC(ret_from_exception)
19931
19932 #ifdef CONFIG_PREEMPT
19933 ENTRY(resume_kernel)
19934 @@ -372,7 +529,7 @@ need_resched:
19935 jz restore_all
19936 call preempt_schedule_irq
19937 jmp need_resched
19938 -END(resume_kernel)
19939 +ENDPROC(resume_kernel)
19940 #endif
19941 CFI_ENDPROC
19942 /*
19943 @@ -406,30 +563,45 @@ sysenter_past_esp:
19944 /*CFI_REL_OFFSET cs, 0*/
19945 /*
19946 * Push current_thread_info()->sysenter_return to the stack.
19947 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
19948 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
19949 */
19950 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
19951 + pushl_cfi $0
19952 CFI_REL_OFFSET eip, 0
19953
19954 pushl_cfi %eax
19955 SAVE_ALL
19956 + GET_THREAD_INFO(%ebp)
19957 + movl TI_sysenter_return(%ebp),%ebp
19958 + movl %ebp,PT_EIP(%esp)
19959 ENABLE_INTERRUPTS(CLBR_NONE)
19960
19961 /*
19962 * Load the potential sixth argument from user stack.
19963 * Careful about security.
19964 */
19965 + movl PT_OLDESP(%esp),%ebp
19966 +
19967 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19968 + mov PT_OLDSS(%esp),%ds
19969 +1: movl %ds:(%ebp),%ebp
19970 + push %ss
19971 + pop %ds
19972 +#else
19973 cmpl $__PAGE_OFFSET-3,%ebp
19974 jae syscall_fault
19975 ASM_STAC
19976 1: movl (%ebp),%ebp
19977 ASM_CLAC
19978 +#endif
19979 +
19980 movl %ebp,PT_EBP(%esp)
19981 _ASM_EXTABLE(1b,syscall_fault)
19982
19983 GET_THREAD_INFO(%ebp)
19984
19985 +#ifdef CONFIG_PAX_RANDKSTACK
19986 + pax_erase_kstack
19987 +#endif
19988 +
19989 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
19990 jnz sysenter_audit
19991 sysenter_do_call:
19992 @@ -444,12 +616,24 @@ sysenter_do_call:
19993 testl $_TIF_ALLWORK_MASK, %ecx
19994 jne sysexit_audit
19995 sysenter_exit:
19996 +
19997 +#ifdef CONFIG_PAX_RANDKSTACK
19998 + pushl_cfi %eax
19999 + movl %esp, %eax
20000 + call pax_randomize_kstack
20001 + popl_cfi %eax
20002 +#endif
20003 +
20004 + pax_erase_kstack
20005 +
20006 /* if something modifies registers it must also disable sysexit */
20007 movl PT_EIP(%esp), %edx
20008 movl PT_OLDESP(%esp), %ecx
20009 xorl %ebp,%ebp
20010 TRACE_IRQS_ON
20011 1: mov PT_FS(%esp), %fs
20012 +2: mov PT_DS(%esp), %ds
20013 +3: mov PT_ES(%esp), %es
20014 PTGS_TO_GS
20015 ENABLE_INTERRUPTS_SYSEXIT
20016
20017 @@ -466,6 +650,9 @@ sysenter_audit:
20018 movl %eax,%edx /* 2nd arg: syscall number */
20019 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20020 call __audit_syscall_entry
20021 +
20022 + pax_erase_kstack
20023 +
20024 pushl_cfi %ebx
20025 movl PT_EAX(%esp),%eax /* reload syscall number */
20026 jmp sysenter_do_call
20027 @@ -491,10 +678,16 @@ sysexit_audit:
20028
20029 CFI_ENDPROC
20030 .pushsection .fixup,"ax"
20031 -2: movl $0,PT_FS(%esp)
20032 +4: movl $0,PT_FS(%esp)
20033 + jmp 1b
20034 +5: movl $0,PT_DS(%esp)
20035 + jmp 1b
20036 +6: movl $0,PT_ES(%esp)
20037 jmp 1b
20038 .popsection
20039 - _ASM_EXTABLE(1b,2b)
20040 + _ASM_EXTABLE(1b,4b)
20041 + _ASM_EXTABLE(2b,5b)
20042 + _ASM_EXTABLE(3b,6b)
20043 PTGS_TO_GS_EX
20044 ENDPROC(ia32_sysenter_target)
20045
20046 @@ -509,6 +702,11 @@ ENTRY(system_call)
20047 pushl_cfi %eax # save orig_eax
20048 SAVE_ALL
20049 GET_THREAD_INFO(%ebp)
20050 +
20051 +#ifdef CONFIG_PAX_RANDKSTACK
20052 + pax_erase_kstack
20053 +#endif
20054 +
20055 # system call tracing in operation / emulation
20056 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20057 jnz syscall_trace_entry
20058 @@ -527,6 +725,15 @@ syscall_exit:
20059 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20060 jne syscall_exit_work
20061
20062 +restore_all_pax:
20063 +
20064 +#ifdef CONFIG_PAX_RANDKSTACK
20065 + movl %esp, %eax
20066 + call pax_randomize_kstack
20067 +#endif
20068 +
20069 + pax_erase_kstack
20070 +
20071 restore_all:
20072 TRACE_IRQS_IRET
20073 restore_all_notrace:
20074 @@ -583,14 +790,34 @@ ldt_ss:
20075 * compensating for the offset by changing to the ESPFIX segment with
20076 * a base address that matches for the difference.
20077 */
20078 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20079 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20080 mov %esp, %edx /* load kernel esp */
20081 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20082 mov %dx, %ax /* eax: new kernel esp */
20083 sub %eax, %edx /* offset (low word is 0) */
20084 +#ifdef CONFIG_SMP
20085 + movl PER_CPU_VAR(cpu_number), %ebx
20086 + shll $PAGE_SHIFT_asm, %ebx
20087 + addl $cpu_gdt_table, %ebx
20088 +#else
20089 + movl $cpu_gdt_table, %ebx
20090 +#endif
20091 shr $16, %edx
20092 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20093 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20094 +
20095 +#ifdef CONFIG_PAX_KERNEXEC
20096 + mov %cr0, %esi
20097 + btr $16, %esi
20098 + mov %esi, %cr0
20099 +#endif
20100 +
20101 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20102 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20103 +
20104 +#ifdef CONFIG_PAX_KERNEXEC
20105 + bts $16, %esi
20106 + mov %esi, %cr0
20107 +#endif
20108 +
20109 pushl_cfi $__ESPFIX_SS
20110 pushl_cfi %eax /* new kernel esp */
20111 /* Disable interrupts, but do not irqtrace this section: we
20112 @@ -619,20 +846,18 @@ work_resched:
20113 movl TI_flags(%ebp), %ecx
20114 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20115 # than syscall tracing?
20116 - jz restore_all
20117 + jz restore_all_pax
20118 testb $_TIF_NEED_RESCHED, %cl
20119 jnz work_resched
20120
20121 work_notifysig: # deal with pending signals and
20122 # notify-resume requests
20123 + movl %esp, %eax
20124 #ifdef CONFIG_VM86
20125 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20126 - movl %esp, %eax
20127 jne work_notifysig_v86 # returning to kernel-space or
20128 # vm86-space
20129 1:
20130 -#else
20131 - movl %esp, %eax
20132 #endif
20133 TRACE_IRQS_ON
20134 ENABLE_INTERRUPTS(CLBR_NONE)
20135 @@ -653,7 +878,7 @@ work_notifysig_v86:
20136 movl %eax, %esp
20137 jmp 1b
20138 #endif
20139 -END(work_pending)
20140 +ENDPROC(work_pending)
20141
20142 # perform syscall exit tracing
20143 ALIGN
20144 @@ -661,11 +886,14 @@ syscall_trace_entry:
20145 movl $-ENOSYS,PT_EAX(%esp)
20146 movl %esp, %eax
20147 call syscall_trace_enter
20148 +
20149 + pax_erase_kstack
20150 +
20151 /* What it returned is what we'll actually use. */
20152 cmpl $(NR_syscalls), %eax
20153 jnae syscall_call
20154 jmp syscall_exit
20155 -END(syscall_trace_entry)
20156 +ENDPROC(syscall_trace_entry)
20157
20158 # perform syscall exit tracing
20159 ALIGN
20160 @@ -678,21 +906,25 @@ syscall_exit_work:
20161 movl %esp, %eax
20162 call syscall_trace_leave
20163 jmp resume_userspace
20164 -END(syscall_exit_work)
20165 +ENDPROC(syscall_exit_work)
20166 CFI_ENDPROC
20167
20168 RING0_INT_FRAME # can't unwind into user space anyway
20169 syscall_fault:
20170 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20171 + push %ss
20172 + pop %ds
20173 +#endif
20174 ASM_CLAC
20175 GET_THREAD_INFO(%ebp)
20176 movl $-EFAULT,PT_EAX(%esp)
20177 jmp resume_userspace
20178 -END(syscall_fault)
20179 +ENDPROC(syscall_fault)
20180
20181 syscall_badsys:
20182 movl $-ENOSYS,PT_EAX(%esp)
20183 jmp resume_userspace
20184 -END(syscall_badsys)
20185 +ENDPROC(syscall_badsys)
20186 CFI_ENDPROC
20187 /*
20188 * End of kprobes section
20189 @@ -708,8 +940,15 @@ END(syscall_badsys)
20190 * normal stack and adjusts ESP with the matching offset.
20191 */
20192 /* fixup the stack */
20193 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
20194 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
20195 +#ifdef CONFIG_SMP
20196 + movl PER_CPU_VAR(cpu_number), %ebx
20197 + shll $PAGE_SHIFT_asm, %ebx
20198 + addl $cpu_gdt_table, %ebx
20199 +#else
20200 + movl $cpu_gdt_table, %ebx
20201 +#endif
20202 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
20203 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
20204 shl $16, %eax
20205 addl %esp, %eax /* the adjusted stack pointer */
20206 pushl_cfi $__KERNEL_DS
20207 @@ -762,7 +1001,7 @@ vector=vector+1
20208 .endr
20209 2: jmp common_interrupt
20210 .endr
20211 -END(irq_entries_start)
20212 +ENDPROC(irq_entries_start)
20213
20214 .previous
20215 END(interrupt)
20216 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
20217 pushl_cfi $do_coprocessor_error
20218 jmp error_code
20219 CFI_ENDPROC
20220 -END(coprocessor_error)
20221 +ENDPROC(coprocessor_error)
20222
20223 ENTRY(simd_coprocessor_error)
20224 RING0_INT_FRAME
20225 @@ -826,7 +1065,7 @@ ENTRY(simd_coprocessor_error)
20226 .section .altinstructions,"a"
20227 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
20228 .previous
20229 -.section .altinstr_replacement,"ax"
20230 +.section .altinstr_replacement,"a"
20231 663: pushl $do_simd_coprocessor_error
20232 664:
20233 .previous
20234 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
20235 #endif
20236 jmp error_code
20237 CFI_ENDPROC
20238 -END(simd_coprocessor_error)
20239 +ENDPROC(simd_coprocessor_error)
20240
20241 ENTRY(device_not_available)
20242 RING0_INT_FRAME
20243 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
20244 pushl_cfi $do_device_not_available
20245 jmp error_code
20246 CFI_ENDPROC
20247 -END(device_not_available)
20248 +ENDPROC(device_not_available)
20249
20250 #ifdef CONFIG_PARAVIRT
20251 ENTRY(native_iret)
20252 iret
20253 _ASM_EXTABLE(native_iret, iret_exc)
20254 -END(native_iret)
20255 +ENDPROC(native_iret)
20256
20257 ENTRY(native_irq_enable_sysexit)
20258 sti
20259 sysexit
20260 -END(native_irq_enable_sysexit)
20261 +ENDPROC(native_irq_enable_sysexit)
20262 #endif
20263
20264 ENTRY(overflow)
20265 @@ -865,7 +1104,7 @@ ENTRY(overflow)
20266 pushl_cfi $do_overflow
20267 jmp error_code
20268 CFI_ENDPROC
20269 -END(overflow)
20270 +ENDPROC(overflow)
20271
20272 ENTRY(bounds)
20273 RING0_INT_FRAME
20274 @@ -874,7 +1113,7 @@ ENTRY(bounds)
20275 pushl_cfi $do_bounds
20276 jmp error_code
20277 CFI_ENDPROC
20278 -END(bounds)
20279 +ENDPROC(bounds)
20280
20281 ENTRY(invalid_op)
20282 RING0_INT_FRAME
20283 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
20284 pushl_cfi $do_invalid_op
20285 jmp error_code
20286 CFI_ENDPROC
20287 -END(invalid_op)
20288 +ENDPROC(invalid_op)
20289
20290 ENTRY(coprocessor_segment_overrun)
20291 RING0_INT_FRAME
20292 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
20293 pushl_cfi $do_coprocessor_segment_overrun
20294 jmp error_code
20295 CFI_ENDPROC
20296 -END(coprocessor_segment_overrun)
20297 +ENDPROC(coprocessor_segment_overrun)
20298
20299 ENTRY(invalid_TSS)
20300 RING0_EC_FRAME
20301 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
20302 pushl_cfi $do_invalid_TSS
20303 jmp error_code
20304 CFI_ENDPROC
20305 -END(invalid_TSS)
20306 +ENDPROC(invalid_TSS)
20307
20308 ENTRY(segment_not_present)
20309 RING0_EC_FRAME
20310 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
20311 pushl_cfi $do_segment_not_present
20312 jmp error_code
20313 CFI_ENDPROC
20314 -END(segment_not_present)
20315 +ENDPROC(segment_not_present)
20316
20317 ENTRY(stack_segment)
20318 RING0_EC_FRAME
20319 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
20320 pushl_cfi $do_stack_segment
20321 jmp error_code
20322 CFI_ENDPROC
20323 -END(stack_segment)
20324 +ENDPROC(stack_segment)
20325
20326 ENTRY(alignment_check)
20327 RING0_EC_FRAME
20328 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
20329 pushl_cfi $do_alignment_check
20330 jmp error_code
20331 CFI_ENDPROC
20332 -END(alignment_check)
20333 +ENDPROC(alignment_check)
20334
20335 ENTRY(divide_error)
20336 RING0_INT_FRAME
20337 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
20338 pushl_cfi $do_divide_error
20339 jmp error_code
20340 CFI_ENDPROC
20341 -END(divide_error)
20342 +ENDPROC(divide_error)
20343
20344 #ifdef CONFIG_X86_MCE
20345 ENTRY(machine_check)
20346 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
20347 pushl_cfi machine_check_vector
20348 jmp error_code
20349 CFI_ENDPROC
20350 -END(machine_check)
20351 +ENDPROC(machine_check)
20352 #endif
20353
20354 ENTRY(spurious_interrupt_bug)
20355 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
20356 pushl_cfi $do_spurious_interrupt_bug
20357 jmp error_code
20358 CFI_ENDPROC
20359 -END(spurious_interrupt_bug)
20360 +ENDPROC(spurious_interrupt_bug)
20361 /*
20362 * End of kprobes section
20363 */
20364 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
20365
20366 ENTRY(mcount)
20367 ret
20368 -END(mcount)
20369 +ENDPROC(mcount)
20370
20371 ENTRY(ftrace_caller)
20372 cmpl $0, function_trace_stop
20373 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
20374 .globl ftrace_stub
20375 ftrace_stub:
20376 ret
20377 -END(ftrace_caller)
20378 +ENDPROC(ftrace_caller)
20379
20380 ENTRY(ftrace_regs_caller)
20381 pushf /* push flags before compare (in cs location) */
20382 @@ -1197,7 +1436,7 @@ trace:
20383 popl %ecx
20384 popl %eax
20385 jmp ftrace_stub
20386 -END(mcount)
20387 +ENDPROC(mcount)
20388 #endif /* CONFIG_DYNAMIC_FTRACE */
20389 #endif /* CONFIG_FUNCTION_TRACER */
20390
20391 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
20392 popl %ecx
20393 popl %eax
20394 ret
20395 -END(ftrace_graph_caller)
20396 +ENDPROC(ftrace_graph_caller)
20397
20398 .globl return_to_handler
20399 return_to_handler:
20400 @@ -1271,15 +1510,18 @@ error_code:
20401 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
20402 REG_TO_PTGS %ecx
20403 SET_KERNEL_GS %ecx
20404 - movl $(__USER_DS), %ecx
20405 + movl $(__KERNEL_DS), %ecx
20406 movl %ecx, %ds
20407 movl %ecx, %es
20408 +
20409 + pax_enter_kernel
20410 +
20411 TRACE_IRQS_OFF
20412 movl %esp,%eax # pt_regs pointer
20413 call *%edi
20414 jmp ret_from_exception
20415 CFI_ENDPROC
20416 -END(page_fault)
20417 +ENDPROC(page_fault)
20418
20419 /*
20420 * Debug traps and NMI can happen at the one SYSENTER instruction
20421 @@ -1322,7 +1564,7 @@ debug_stack_correct:
20422 call do_debug
20423 jmp ret_from_exception
20424 CFI_ENDPROC
20425 -END(debug)
20426 +ENDPROC(debug)
20427
20428 /*
20429 * NMI is doubly nasty. It can happen _while_ we're handling
20430 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
20431 xorl %edx,%edx # zero error code
20432 movl %esp,%eax # pt_regs pointer
20433 call do_nmi
20434 +
20435 + pax_exit_kernel
20436 +
20437 jmp restore_all_notrace
20438 CFI_ENDPROC
20439
20440 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
20441 FIXUP_ESPFIX_STACK # %eax == %esp
20442 xorl %edx,%edx # zero error code
20443 call do_nmi
20444 +
20445 + pax_exit_kernel
20446 +
20447 RESTORE_REGS
20448 lss 12+4(%esp), %esp # back to espfix stack
20449 CFI_ADJUST_CFA_OFFSET -24
20450 jmp irq_return
20451 CFI_ENDPROC
20452 -END(nmi)
20453 +ENDPROC(nmi)
20454
20455 ENTRY(int3)
20456 RING0_INT_FRAME
20457 @@ -1414,14 +1662,14 @@ ENTRY(int3)
20458 call do_int3
20459 jmp ret_from_exception
20460 CFI_ENDPROC
20461 -END(int3)
20462 +ENDPROC(int3)
20463
20464 ENTRY(general_protection)
20465 RING0_EC_FRAME
20466 pushl_cfi $do_general_protection
20467 jmp error_code
20468 CFI_ENDPROC
20469 -END(general_protection)
20470 +ENDPROC(general_protection)
20471
20472 #ifdef CONFIG_KVM_GUEST
20473 ENTRY(async_page_fault)
20474 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
20475 pushl_cfi $do_async_page_fault
20476 jmp error_code
20477 CFI_ENDPROC
20478 -END(async_page_fault)
20479 +ENDPROC(async_page_fault)
20480 #endif
20481
20482 /*
20483 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
20484 index 7272089..833fdf8 100644
20485 --- a/arch/x86/kernel/entry_64.S
20486 +++ b/arch/x86/kernel/entry_64.S
20487 @@ -59,6 +59,8 @@
20488 #include <asm/context_tracking.h>
20489 #include <asm/smap.h>
20490 #include <linux/err.h>
20491 +#include <asm/pgtable.h>
20492 +#include <asm/alternative-asm.h>
20493
20494 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
20495 #include <linux/elf-em.h>
20496 @@ -80,8 +82,9 @@
20497 #ifdef CONFIG_DYNAMIC_FTRACE
20498
20499 ENTRY(function_hook)
20500 + pax_force_retaddr
20501 retq
20502 -END(function_hook)
20503 +ENDPROC(function_hook)
20504
20505 /* skip is set if stack has been adjusted */
20506 .macro ftrace_caller_setup skip=0
20507 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
20508 #endif
20509
20510 GLOBAL(ftrace_stub)
20511 + pax_force_retaddr
20512 retq
20513 -END(ftrace_caller)
20514 +ENDPROC(ftrace_caller)
20515
20516 ENTRY(ftrace_regs_caller)
20517 /* Save the current flags before compare (in SS location)*/
20518 @@ -191,7 +195,7 @@ ftrace_restore_flags:
20519 popfq
20520 jmp ftrace_stub
20521
20522 -END(ftrace_regs_caller)
20523 +ENDPROC(ftrace_regs_caller)
20524
20525
20526 #else /* ! CONFIG_DYNAMIC_FTRACE */
20527 @@ -212,6 +216,7 @@ ENTRY(function_hook)
20528 #endif
20529
20530 GLOBAL(ftrace_stub)
20531 + pax_force_retaddr
20532 retq
20533
20534 trace:
20535 @@ -225,12 +230,13 @@ trace:
20536 #endif
20537 subq $MCOUNT_INSN_SIZE, %rdi
20538
20539 + pax_force_fptr ftrace_trace_function
20540 call *ftrace_trace_function
20541
20542 MCOUNT_RESTORE_FRAME
20543
20544 jmp ftrace_stub
20545 -END(function_hook)
20546 +ENDPROC(function_hook)
20547 #endif /* CONFIG_DYNAMIC_FTRACE */
20548 #endif /* CONFIG_FUNCTION_TRACER */
20549
20550 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
20551
20552 MCOUNT_RESTORE_FRAME
20553
20554 + pax_force_retaddr
20555 retq
20556 -END(ftrace_graph_caller)
20557 +ENDPROC(ftrace_graph_caller)
20558
20559 GLOBAL(return_to_handler)
20560 subq $24, %rsp
20561 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
20562 movq 8(%rsp), %rdx
20563 movq (%rsp), %rax
20564 addq $24, %rsp
20565 + pax_force_fptr %rdi
20566 jmp *%rdi
20567 +ENDPROC(return_to_handler)
20568 #endif
20569
20570
20571 @@ -284,6 +293,427 @@ ENTRY(native_usergs_sysret64)
20572 ENDPROC(native_usergs_sysret64)
20573 #endif /* CONFIG_PARAVIRT */
20574
20575 + .macro ljmpq sel, off
20576 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
20577 + .byte 0x48; ljmp *1234f(%rip)
20578 + .pushsection .rodata
20579 + .align 16
20580 + 1234: .quad \off; .word \sel
20581 + .popsection
20582 +#else
20583 + pushq $\sel
20584 + pushq $\off
20585 + lretq
20586 +#endif
20587 + .endm
20588 +
20589 + .macro pax_enter_kernel
20590 + pax_set_fptr_mask
20591 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20592 + call pax_enter_kernel
20593 +#endif
20594 + .endm
20595 +
20596 + .macro pax_exit_kernel
20597 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20598 + call pax_exit_kernel
20599 +#endif
20600 +
20601 + .endm
20602 +
20603 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20604 +ENTRY(pax_enter_kernel)
20605 + pushq %rdi
20606 +
20607 +#ifdef CONFIG_PARAVIRT
20608 + PV_SAVE_REGS(CLBR_RDI)
20609 +#endif
20610 +
20611 +#ifdef CONFIG_PAX_KERNEXEC
20612 + GET_CR0_INTO_RDI
20613 + bts $16,%rdi
20614 + jnc 3f
20615 + mov %cs,%edi
20616 + cmp $__KERNEL_CS,%edi
20617 + jnz 2f
20618 +1:
20619 +#endif
20620 +
20621 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20622 + 661: jmp 111f
20623 + .pushsection .altinstr_replacement, "a"
20624 + 662: ASM_NOP2
20625 + .popsection
20626 + .pushsection .altinstructions, "a"
20627 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
20628 + .popsection
20629 + GET_CR3_INTO_RDI
20630 + cmp $0,%dil
20631 + jnz 112f
20632 + mov $__KERNEL_DS,%edi
20633 + mov %edi,%ss
20634 + jmp 111f
20635 +112: cmp $1,%dil
20636 + jz 113f
20637 + ud2
20638 +113: sub $4097,%rdi
20639 + bts $63,%rdi
20640 + SET_RDI_INTO_CR3
20641 + mov $__UDEREF_KERNEL_DS,%edi
20642 + mov %edi,%ss
20643 +111:
20644 +#endif
20645 +
20646 +#ifdef CONFIG_PARAVIRT
20647 + PV_RESTORE_REGS(CLBR_RDI)
20648 +#endif
20649 +
20650 + popq %rdi
20651 + pax_force_retaddr
20652 + retq
20653 +
20654 +#ifdef CONFIG_PAX_KERNEXEC
20655 +2: ljmpq __KERNEL_CS,1b
20656 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
20657 +4: SET_RDI_INTO_CR0
20658 + jmp 1b
20659 +#endif
20660 +ENDPROC(pax_enter_kernel)
20661 +
20662 +ENTRY(pax_exit_kernel)
20663 + pushq %rdi
20664 +
20665 +#ifdef CONFIG_PARAVIRT
20666 + PV_SAVE_REGS(CLBR_RDI)
20667 +#endif
20668 +
20669 +#ifdef CONFIG_PAX_KERNEXEC
20670 + mov %cs,%rdi
20671 + cmp $__KERNEXEC_KERNEL_CS,%edi
20672 + jz 2f
20673 + GET_CR0_INTO_RDI
20674 + bts $16,%rdi
20675 + jnc 4f
20676 +1:
20677 +#endif
20678 +
20679 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20680 + 661: jmp 111f
20681 + .pushsection .altinstr_replacement, "a"
20682 + 662: ASM_NOP2
20683 + .popsection
20684 + .pushsection .altinstructions, "a"
20685 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
20686 + .popsection
20687 + mov %ss,%edi
20688 + cmp $__UDEREF_KERNEL_DS,%edi
20689 + jnz 111f
20690 + GET_CR3_INTO_RDI
20691 + cmp $0,%dil
20692 + jz 112f
20693 + ud2
20694 +112: add $4097,%rdi
20695 + bts $63,%rdi
20696 + SET_RDI_INTO_CR3
20697 + mov $__KERNEL_DS,%edi
20698 + mov %edi,%ss
20699 +111:
20700 +#endif
20701 +
20702 +#ifdef CONFIG_PARAVIRT
20703 + PV_RESTORE_REGS(CLBR_RDI);
20704 +#endif
20705 +
20706 + popq %rdi
20707 + pax_force_retaddr
20708 + retq
20709 +
20710 +#ifdef CONFIG_PAX_KERNEXEC
20711 +2: GET_CR0_INTO_RDI
20712 + btr $16,%rdi
20713 + jnc 4f
20714 + ljmpq __KERNEL_CS,3f
20715 +3: SET_RDI_INTO_CR0
20716 + jmp 1b
20717 +4: ud2
20718 + jmp 4b
20719 +#endif
20720 +ENDPROC(pax_exit_kernel)
20721 +#endif
20722 +
20723 + .macro pax_enter_kernel_user
20724 + pax_set_fptr_mask
20725 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20726 + call pax_enter_kernel_user
20727 +#endif
20728 + .endm
20729 +
20730 + .macro pax_exit_kernel_user
20731 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20732 + call pax_exit_kernel_user
20733 +#endif
20734 +#ifdef CONFIG_PAX_RANDKSTACK
20735 + pushq %rax
20736 + pushq %r11
20737 + call pax_randomize_kstack
20738 + popq %r11
20739 + popq %rax
20740 +#endif
20741 + .endm
20742 +
20743 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20744 +ENTRY(pax_enter_kernel_user)
20745 + pushq %rdi
20746 + pushq %rbx
20747 +
20748 +#ifdef CONFIG_PARAVIRT
20749 + PV_SAVE_REGS(CLBR_RDI)
20750 +#endif
20751 +
20752 + 661: jmp 111f
20753 + .pushsection .altinstr_replacement, "a"
20754 + 662: ASM_NOP2
20755 + .popsection
20756 + .pushsection .altinstructions, "a"
20757 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
20758 + .popsection
20759 + GET_CR3_INTO_RDI
20760 + cmp $1,%dil
20761 + jnz 3f
20762 + sub $4097,%rdi
20763 + bts $63,%rdi
20764 + jmp 2f
20765 +111:
20766 +
20767 + GET_CR3_INTO_RDI
20768 + mov %rdi,%rbx
20769 + add $__START_KERNEL_map,%rbx
20770 + sub phys_base(%rip),%rbx
20771 +
20772 +#ifdef CONFIG_PARAVIRT
20773 + cmpl $0, pv_info+PARAVIRT_enabled
20774 + jz 1f
20775 + pushq %rdi
20776 + i = 0
20777 + .rept USER_PGD_PTRS
20778 + mov i*8(%rbx),%rsi
20779 + mov $0,%sil
20780 + lea i*8(%rbx),%rdi
20781 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
20782 + i = i + 1
20783 + .endr
20784 + popq %rdi
20785 + jmp 2f
20786 +1:
20787 +#endif
20788 +
20789 + i = 0
20790 + .rept USER_PGD_PTRS
20791 + movb $0,i*8(%rbx)
20792 + i = i + 1
20793 + .endr
20794 +
20795 +#ifdef CONFIG_PAX_KERNEXEC
20796 + GET_CR0_INTO_RDI
20797 + bts $16,%rdi
20798 + SET_RDI_INTO_CR0
20799 +#endif
20800 +
20801 +2: SET_RDI_INTO_CR3
20802 +
20803 +#ifdef CONFIG_PARAVIRT
20804 + PV_RESTORE_REGS(CLBR_RDI)
20805 +#endif
20806 +
20807 + popq %rbx
20808 + popq %rdi
20809 + pax_force_retaddr
20810 + retq
20811 +3: ud2
20812 +ENDPROC(pax_enter_kernel_user)
20813 +
20814 +ENTRY(pax_exit_kernel_user)
20815 + pushq %rdi
20816 + pushq %rbx
20817 +
20818 +#ifdef CONFIG_PARAVIRT
20819 + PV_SAVE_REGS(CLBR_RDI)
20820 +#endif
20821 +
20822 + GET_CR3_INTO_RDI
20823 + 661: jmp 1f
20824 + .pushsection .altinstr_replacement, "a"
20825 + 662: ASM_NOP2
20826 + .popsection
20827 + .pushsection .altinstructions, "a"
20828 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
20829 + .popsection
20830 + cmp $0,%dil
20831 + jnz 3f
20832 + add $4097,%rdi
20833 + bts $63,%rdi
20834 + SET_RDI_INTO_CR3
20835 + jmp 2f
20836 +1:
20837 + mov %rdi,%rbx
20838 + add $__START_KERNEL_map,%rbx
20839 + sub phys_base(%rip),%rbx
20840 +
20841 +#ifdef CONFIG_PARAVIRT
20842 + cmpl $0, pv_info+PARAVIRT_enabled
20843 + jz 1f
20844 + pushq %rdi
20845 + i = 0
20846 + .rept USER_PGD_PTRS
20847 + mov i*8(%rbx),%rsi
20848 + mov $0x67,%sil
20849 + lea i*8(%rbx),%rdi
20850 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
20851 + i = i + 1
20852 + .endr
20853 + popq %rdi
20854 + jmp 2f
20855 +1:
20856 +#endif
20857 +
20858 +#ifdef CONFIG_PAX_KERNEXEC
20859 + GET_CR0_INTO_RDI
20860 + btr $16,%rdi
20861 + jnc 3f
20862 + SET_RDI_INTO_CR0
20863 +#endif
20864 +
20865 + i = 0
20866 + .rept USER_PGD_PTRS
20867 + movb $0x67,i*8(%rbx)
20868 + i = i + 1
20869 + .endr
20870 +2:
20871 +
20872 +#ifdef CONFIG_PARAVIRT
20873 + PV_RESTORE_REGS(CLBR_RDI)
20874 +#endif
20875 +
20876 + popq %rbx
20877 + popq %rdi
20878 + pax_force_retaddr
20879 + retq
20880 +3: ud2
20881 +ENDPROC(pax_exit_kernel_user)
20882 +#endif
20883 +
20884 + .macro pax_enter_kernel_nmi
20885 + pax_set_fptr_mask
20886 +
20887 +#ifdef CONFIG_PAX_KERNEXEC
20888 + GET_CR0_INTO_RDI
20889 + bts $16,%rdi
20890 + jc 110f
20891 + SET_RDI_INTO_CR0
20892 + or $2,%ebx
20893 +110:
20894 +#endif
20895 +
20896 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20897 + 661: jmp 111f
20898 + .pushsection .altinstr_replacement, "a"
20899 + 662: ASM_NOP2
20900 + .popsection
20901 + .pushsection .altinstructions, "a"
20902 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
20903 + .popsection
20904 + GET_CR3_INTO_RDI
20905 + cmp $0,%dil
20906 + jz 111f
20907 + sub $4097,%rdi
20908 + or $4,%ebx
20909 + bts $63,%rdi
20910 + SET_RDI_INTO_CR3
20911 + mov $__UDEREF_KERNEL_DS,%edi
20912 + mov %edi,%ss
20913 +111:
20914 +#endif
20915 + .endm
20916 +
20917 + .macro pax_exit_kernel_nmi
20918 +#ifdef CONFIG_PAX_KERNEXEC
20919 + btr $1,%ebx
20920 + jnc 110f
20921 + GET_CR0_INTO_RDI
20922 + btr $16,%rdi
20923 + SET_RDI_INTO_CR0
20924 +110:
20925 +#endif
20926 +
20927 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20928 + btr $2,%ebx
20929 + jnc 111f
20930 + GET_CR3_INTO_RDI
20931 + add $4097,%rdi
20932 + bts $63,%rdi
20933 + SET_RDI_INTO_CR3
20934 + mov $__KERNEL_DS,%edi
20935 + mov %edi,%ss
20936 +111:
20937 +#endif
20938 + .endm
20939 +
20940 + .macro pax_erase_kstack
20941 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20942 + call pax_erase_kstack
20943 +#endif
20944 + .endm
20945 +
20946 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20947 +ENTRY(pax_erase_kstack)
20948 + pushq %rdi
20949 + pushq %rcx
20950 + pushq %rax
20951 + pushq %r11
20952 +
20953 + GET_THREAD_INFO(%r11)
20954 + mov TI_lowest_stack(%r11), %rdi
20955 + mov $-0xBEEF, %rax
20956 + std
20957 +
20958 +1: mov %edi, %ecx
20959 + and $THREAD_SIZE_asm - 1, %ecx
20960 + shr $3, %ecx
20961 + repne scasq
20962 + jecxz 2f
20963 +
20964 + cmp $2*8, %ecx
20965 + jc 2f
20966 +
20967 + mov $2*8, %ecx
20968 + repe scasq
20969 + jecxz 2f
20970 + jne 1b
20971 +
20972 +2: cld
20973 + mov %esp, %ecx
20974 + sub %edi, %ecx
20975 +
20976 + cmp $THREAD_SIZE_asm, %rcx
20977 + jb 3f
20978 + ud2
20979 +3:
20980 +
20981 + shr $3, %ecx
20982 + rep stosq
20983 +
20984 + mov TI_task_thread_sp0(%r11), %rdi
20985 + sub $256, %rdi
20986 + mov %rdi, TI_lowest_stack(%r11)
20987 +
20988 + popq %r11
20989 + popq %rax
20990 + popq %rcx
20991 + popq %rdi
20992 + pax_force_retaddr
20993 + ret
20994 +ENDPROC(pax_erase_kstack)
20995 +#endif
20996
20997 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
20998 #ifdef CONFIG_TRACE_IRQFLAGS
20999 @@ -375,8 +805,8 @@ ENDPROC(native_usergs_sysret64)
21000 .endm
21001
21002 .macro UNFAKE_STACK_FRAME
21003 - addq $8*6, %rsp
21004 - CFI_ADJUST_CFA_OFFSET -(6*8)
21005 + addq $8*6 + ARG_SKIP, %rsp
21006 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21007 .endm
21008
21009 /*
21010 @@ -463,7 +893,7 @@ ENDPROC(native_usergs_sysret64)
21011 movq %rsp, %rsi
21012
21013 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21014 - testl $3, CS-RBP(%rsi)
21015 + testb $3, CS-RBP(%rsi)
21016 je 1f
21017 SWAPGS
21018 /*
21019 @@ -498,9 +928,10 @@ ENTRY(save_rest)
21020 movq_cfi r15, R15+16
21021 movq %r11, 8(%rsp) /* return address */
21022 FIXUP_TOP_OF_STACK %r11, 16
21023 + pax_force_retaddr
21024 ret
21025 CFI_ENDPROC
21026 -END(save_rest)
21027 +ENDPROC(save_rest)
21028
21029 /* save complete stack frame */
21030 .pushsection .kprobes.text, "ax"
21031 @@ -529,9 +960,10 @@ ENTRY(save_paranoid)
21032 js 1f /* negative -> in kernel */
21033 SWAPGS
21034 xorl %ebx,%ebx
21035 -1: ret
21036 +1: pax_force_retaddr_bts
21037 + ret
21038 CFI_ENDPROC
21039 -END(save_paranoid)
21040 +ENDPROC(save_paranoid)
21041 .popsection
21042
21043 /*
21044 @@ -553,7 +985,7 @@ ENTRY(ret_from_fork)
21045
21046 RESTORE_REST
21047
21048 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21049 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21050 jz 1f
21051
21052 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21053 @@ -571,7 +1003,7 @@ ENTRY(ret_from_fork)
21054 RESTORE_REST
21055 jmp int_ret_from_sys_call
21056 CFI_ENDPROC
21057 -END(ret_from_fork)
21058 +ENDPROC(ret_from_fork)
21059
21060 /*
21061 * System call entry. Up to 6 arguments in registers are supported.
21062 @@ -608,7 +1040,7 @@ END(ret_from_fork)
21063 ENTRY(system_call)
21064 CFI_STARTPROC simple
21065 CFI_SIGNAL_FRAME
21066 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21067 + CFI_DEF_CFA rsp,0
21068 CFI_REGISTER rip,rcx
21069 /*CFI_REGISTER rflags,r11*/
21070 SWAPGS_UNSAFE_STACK
21071 @@ -621,16 +1053,23 @@ GLOBAL(system_call_after_swapgs)
21072
21073 movq %rsp,PER_CPU_VAR(old_rsp)
21074 movq PER_CPU_VAR(kernel_stack),%rsp
21075 + SAVE_ARGS 8*6,0
21076 + pax_enter_kernel_user
21077 +
21078 +#ifdef CONFIG_PAX_RANDKSTACK
21079 + pax_erase_kstack
21080 +#endif
21081 +
21082 /*
21083 * No need to follow this irqs off/on section - it's straight
21084 * and short:
21085 */
21086 ENABLE_INTERRUPTS(CLBR_NONE)
21087 - SAVE_ARGS 8,0
21088 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21089 movq %rcx,RIP-ARGOFFSET(%rsp)
21090 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21091 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21092 + GET_THREAD_INFO(%rcx)
21093 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21094 jnz tracesys
21095 system_call_fastpath:
21096 #if __SYSCALL_MASK == ~0
21097 @@ -640,7 +1079,7 @@ system_call_fastpath:
21098 cmpl $__NR_syscall_max,%eax
21099 #endif
21100 ja badsys
21101 - movq %r10,%rcx
21102 + movq R10-ARGOFFSET(%rsp),%rcx
21103 call *sys_call_table(,%rax,8) # XXX: rip relative
21104 movq %rax,RAX-ARGOFFSET(%rsp)
21105 /*
21106 @@ -654,10 +1093,13 @@ sysret_check:
21107 LOCKDEP_SYS_EXIT
21108 DISABLE_INTERRUPTS(CLBR_NONE)
21109 TRACE_IRQS_OFF
21110 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21111 + GET_THREAD_INFO(%rcx)
21112 + movl TI_flags(%rcx),%edx
21113 andl %edi,%edx
21114 jnz sysret_careful
21115 CFI_REMEMBER_STATE
21116 + pax_exit_kernel_user
21117 + pax_erase_kstack
21118 /*
21119 * sysretq will re-enable interrupts:
21120 */
21121 @@ -709,14 +1151,18 @@ badsys:
21122 * jump back to the normal fast path.
21123 */
21124 auditsys:
21125 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21126 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21127 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21128 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21129 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21130 movq %rax,%rsi /* 2nd arg: syscall number */
21131 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21132 call __audit_syscall_entry
21133 +
21134 + pax_erase_kstack
21135 +
21136 LOAD_ARGS 0 /* reload call-clobbered registers */
21137 + pax_set_fptr_mask
21138 jmp system_call_fastpath
21139
21140 /*
21141 @@ -737,7 +1183,7 @@ sysret_audit:
21142 /* Do syscall tracing */
21143 tracesys:
21144 #ifdef CONFIG_AUDITSYSCALL
21145 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21146 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21147 jz auditsys
21148 #endif
21149 SAVE_REST
21150 @@ -745,12 +1191,16 @@ tracesys:
21151 FIXUP_TOP_OF_STACK %rdi
21152 movq %rsp,%rdi
21153 call syscall_trace_enter
21154 +
21155 + pax_erase_kstack
21156 +
21157 /*
21158 * Reload arg registers from stack in case ptrace changed them.
21159 * We don't reload %rax because syscall_trace_enter() returned
21160 * the value it wants us to use in the table lookup.
21161 */
21162 LOAD_ARGS ARGOFFSET, 1
21163 + pax_set_fptr_mask
21164 RESTORE_REST
21165 #if __SYSCALL_MASK == ~0
21166 cmpq $__NR_syscall_max,%rax
21167 @@ -759,7 +1209,7 @@ tracesys:
21168 cmpl $__NR_syscall_max,%eax
21169 #endif
21170 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21171 - movq %r10,%rcx /* fixup for C */
21172 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21173 call *sys_call_table(,%rax,8)
21174 movq %rax,RAX-ARGOFFSET(%rsp)
21175 /* Use IRET because user could have changed frame */
21176 @@ -780,7 +1230,9 @@ GLOBAL(int_with_check)
21177 andl %edi,%edx
21178 jnz int_careful
21179 andl $~TS_COMPAT,TI_status(%rcx)
21180 - jmp retint_swapgs
21181 + pax_exit_kernel_user
21182 + pax_erase_kstack
21183 + jmp retint_swapgs_pax
21184
21185 /* Either reschedule or signal or syscall exit tracking needed. */
21186 /* First do a reschedule test. */
21187 @@ -826,7 +1278,7 @@ int_restore_rest:
21188 TRACE_IRQS_OFF
21189 jmp int_with_check
21190 CFI_ENDPROC
21191 -END(system_call)
21192 +ENDPROC(system_call)
21193
21194 .macro FORK_LIKE func
21195 ENTRY(stub_\func)
21196 @@ -839,9 +1291,10 @@ ENTRY(stub_\func)
21197 DEFAULT_FRAME 0 8 /* offset 8: return address */
21198 call sys_\func
21199 RESTORE_TOP_OF_STACK %r11, 8
21200 + pax_force_retaddr
21201 ret $REST_SKIP /* pop extended registers */
21202 CFI_ENDPROC
21203 -END(stub_\func)
21204 +ENDPROC(stub_\func)
21205 .endm
21206
21207 .macro FIXED_FRAME label,func
21208 @@ -851,9 +1304,10 @@ ENTRY(\label)
21209 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
21210 call \func
21211 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
21212 + pax_force_retaddr
21213 ret
21214 CFI_ENDPROC
21215 -END(\label)
21216 +ENDPROC(\label)
21217 .endm
21218
21219 FORK_LIKE clone
21220 @@ -870,9 +1324,10 @@ ENTRY(ptregscall_common)
21221 movq_cfi_restore R12+8, r12
21222 movq_cfi_restore RBP+8, rbp
21223 movq_cfi_restore RBX+8, rbx
21224 + pax_force_retaddr
21225 ret $REST_SKIP /* pop extended registers */
21226 CFI_ENDPROC
21227 -END(ptregscall_common)
21228 +ENDPROC(ptregscall_common)
21229
21230 ENTRY(stub_execve)
21231 CFI_STARTPROC
21232 @@ -885,7 +1340,7 @@ ENTRY(stub_execve)
21233 RESTORE_REST
21234 jmp int_ret_from_sys_call
21235 CFI_ENDPROC
21236 -END(stub_execve)
21237 +ENDPROC(stub_execve)
21238
21239 /*
21240 * sigreturn is special because it needs to restore all registers on return.
21241 @@ -902,7 +1357,7 @@ ENTRY(stub_rt_sigreturn)
21242 RESTORE_REST
21243 jmp int_ret_from_sys_call
21244 CFI_ENDPROC
21245 -END(stub_rt_sigreturn)
21246 +ENDPROC(stub_rt_sigreturn)
21247
21248 #ifdef CONFIG_X86_X32_ABI
21249 ENTRY(stub_x32_rt_sigreturn)
21250 @@ -916,7 +1371,7 @@ ENTRY(stub_x32_rt_sigreturn)
21251 RESTORE_REST
21252 jmp int_ret_from_sys_call
21253 CFI_ENDPROC
21254 -END(stub_x32_rt_sigreturn)
21255 +ENDPROC(stub_x32_rt_sigreturn)
21256
21257 ENTRY(stub_x32_execve)
21258 CFI_STARTPROC
21259 @@ -930,7 +1385,7 @@ ENTRY(stub_x32_execve)
21260 RESTORE_REST
21261 jmp int_ret_from_sys_call
21262 CFI_ENDPROC
21263 -END(stub_x32_execve)
21264 +ENDPROC(stub_x32_execve)
21265
21266 #endif
21267
21268 @@ -967,7 +1422,7 @@ vector=vector+1
21269 2: jmp common_interrupt
21270 .endr
21271 CFI_ENDPROC
21272 -END(irq_entries_start)
21273 +ENDPROC(irq_entries_start)
21274
21275 .previous
21276 END(interrupt)
21277 @@ -987,6 +1442,16 @@ END(interrupt)
21278 subq $ORIG_RAX-RBP, %rsp
21279 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
21280 SAVE_ARGS_IRQ
21281 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21282 + testb $3, CS(%rdi)
21283 + jnz 1f
21284 + pax_enter_kernel
21285 + jmp 2f
21286 +1: pax_enter_kernel_user
21287 +2:
21288 +#else
21289 + pax_enter_kernel
21290 +#endif
21291 call \func
21292 .endm
21293
21294 @@ -1019,7 +1484,7 @@ ret_from_intr:
21295
21296 exit_intr:
21297 GET_THREAD_INFO(%rcx)
21298 - testl $3,CS-ARGOFFSET(%rsp)
21299 + testb $3,CS-ARGOFFSET(%rsp)
21300 je retint_kernel
21301
21302 /* Interrupt came from user space */
21303 @@ -1041,12 +1506,16 @@ retint_swapgs: /* return to user-space */
21304 * The iretq could re-enable interrupts:
21305 */
21306 DISABLE_INTERRUPTS(CLBR_ANY)
21307 + pax_exit_kernel_user
21308 +retint_swapgs_pax:
21309 TRACE_IRQS_IRETQ
21310 SWAPGS
21311 jmp restore_args
21312
21313 retint_restore_args: /* return to kernel space */
21314 DISABLE_INTERRUPTS(CLBR_ANY)
21315 + pax_exit_kernel
21316 + pax_force_retaddr (RIP-ARGOFFSET)
21317 /*
21318 * The iretq could re-enable interrupts:
21319 */
21320 @@ -1129,7 +1598,7 @@ ENTRY(retint_kernel)
21321 #endif
21322
21323 CFI_ENDPROC
21324 -END(common_interrupt)
21325 +ENDPROC(common_interrupt)
21326 /*
21327 * End of kprobes section
21328 */
21329 @@ -1147,7 +1616,7 @@ ENTRY(\sym)
21330 interrupt \do_sym
21331 jmp ret_from_intr
21332 CFI_ENDPROC
21333 -END(\sym)
21334 +ENDPROC(\sym)
21335 .endm
21336
21337 #ifdef CONFIG_SMP
21338 @@ -1208,12 +1677,22 @@ ENTRY(\sym)
21339 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
21340 call error_entry
21341 DEFAULT_FRAME 0
21342 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21343 + testb $3, CS(%rsp)
21344 + jnz 1f
21345 + pax_enter_kernel
21346 + jmp 2f
21347 +1: pax_enter_kernel_user
21348 +2:
21349 +#else
21350 + pax_enter_kernel
21351 +#endif
21352 movq %rsp,%rdi /* pt_regs pointer */
21353 xorl %esi,%esi /* no error code */
21354 call \do_sym
21355 jmp error_exit /* %ebx: no swapgs flag */
21356 CFI_ENDPROC
21357 -END(\sym)
21358 +ENDPROC(\sym)
21359 .endm
21360
21361 .macro paranoidzeroentry sym do_sym
21362 @@ -1226,15 +1705,25 @@ ENTRY(\sym)
21363 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
21364 call save_paranoid
21365 TRACE_IRQS_OFF
21366 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21367 + testb $3, CS(%rsp)
21368 + jnz 1f
21369 + pax_enter_kernel
21370 + jmp 2f
21371 +1: pax_enter_kernel_user
21372 +2:
21373 +#else
21374 + pax_enter_kernel
21375 +#endif
21376 movq %rsp,%rdi /* pt_regs pointer */
21377 xorl %esi,%esi /* no error code */
21378 call \do_sym
21379 jmp paranoid_exit /* %ebx: no swapgs flag */
21380 CFI_ENDPROC
21381 -END(\sym)
21382 +ENDPROC(\sym)
21383 .endm
21384
21385 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
21386 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
21387 .macro paranoidzeroentry_ist sym do_sym ist
21388 ENTRY(\sym)
21389 INTR_FRAME
21390 @@ -1245,14 +1734,30 @@ ENTRY(\sym)
21391 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
21392 call save_paranoid
21393 TRACE_IRQS_OFF_DEBUG
21394 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21395 + testb $3, CS(%rsp)
21396 + jnz 1f
21397 + pax_enter_kernel
21398 + jmp 2f
21399 +1: pax_enter_kernel_user
21400 +2:
21401 +#else
21402 + pax_enter_kernel
21403 +#endif
21404 movq %rsp,%rdi /* pt_regs pointer */
21405 xorl %esi,%esi /* no error code */
21406 +#ifdef CONFIG_SMP
21407 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
21408 + lea init_tss(%r12), %r12
21409 +#else
21410 + lea init_tss(%rip), %r12
21411 +#endif
21412 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
21413 call \do_sym
21414 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
21415 jmp paranoid_exit /* %ebx: no swapgs flag */
21416 CFI_ENDPROC
21417 -END(\sym)
21418 +ENDPROC(\sym)
21419 .endm
21420
21421 .macro errorentry sym do_sym
21422 @@ -1264,13 +1769,23 @@ ENTRY(\sym)
21423 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
21424 call error_entry
21425 DEFAULT_FRAME 0
21426 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21427 + testb $3, CS(%rsp)
21428 + jnz 1f
21429 + pax_enter_kernel
21430 + jmp 2f
21431 +1: pax_enter_kernel_user
21432 +2:
21433 +#else
21434 + pax_enter_kernel
21435 +#endif
21436 movq %rsp,%rdi /* pt_regs pointer */
21437 movq ORIG_RAX(%rsp),%rsi /* get error code */
21438 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
21439 call \do_sym
21440 jmp error_exit /* %ebx: no swapgs flag */
21441 CFI_ENDPROC
21442 -END(\sym)
21443 +ENDPROC(\sym)
21444 .endm
21445
21446 /* error code is on the stack already */
21447 @@ -1284,13 +1799,23 @@ ENTRY(\sym)
21448 call save_paranoid
21449 DEFAULT_FRAME 0
21450 TRACE_IRQS_OFF
21451 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21452 + testb $3, CS(%rsp)
21453 + jnz 1f
21454 + pax_enter_kernel
21455 + jmp 2f
21456 +1: pax_enter_kernel_user
21457 +2:
21458 +#else
21459 + pax_enter_kernel
21460 +#endif
21461 movq %rsp,%rdi /* pt_regs pointer */
21462 movq ORIG_RAX(%rsp),%rsi /* get error code */
21463 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
21464 call \do_sym
21465 jmp paranoid_exit /* %ebx: no swapgs flag */
21466 CFI_ENDPROC
21467 -END(\sym)
21468 +ENDPROC(\sym)
21469 .endm
21470
21471 zeroentry divide_error do_divide_error
21472 @@ -1320,9 +1845,10 @@ gs_change:
21473 2: mfence /* workaround */
21474 SWAPGS
21475 popfq_cfi
21476 + pax_force_retaddr
21477 ret
21478 CFI_ENDPROC
21479 -END(native_load_gs_index)
21480 +ENDPROC(native_load_gs_index)
21481
21482 _ASM_EXTABLE(gs_change,bad_gs)
21483 .section .fixup,"ax"
21484 @@ -1350,9 +1876,10 @@ ENTRY(call_softirq)
21485 CFI_DEF_CFA_REGISTER rsp
21486 CFI_ADJUST_CFA_OFFSET -8
21487 decl PER_CPU_VAR(irq_count)
21488 + pax_force_retaddr
21489 ret
21490 CFI_ENDPROC
21491 -END(call_softirq)
21492 +ENDPROC(call_softirq)
21493
21494 #ifdef CONFIG_XEN
21495 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
21496 @@ -1390,7 +1917,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
21497 decl PER_CPU_VAR(irq_count)
21498 jmp error_exit
21499 CFI_ENDPROC
21500 -END(xen_do_hypervisor_callback)
21501 +ENDPROC(xen_do_hypervisor_callback)
21502
21503 /*
21504 * Hypervisor uses this for application faults while it executes.
21505 @@ -1449,7 +1976,7 @@ ENTRY(xen_failsafe_callback)
21506 SAVE_ALL
21507 jmp error_exit
21508 CFI_ENDPROC
21509 -END(xen_failsafe_callback)
21510 +ENDPROC(xen_failsafe_callback)
21511
21512 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
21513 xen_hvm_callback_vector xen_evtchn_do_upcall
21514 @@ -1501,18 +2028,33 @@ ENTRY(paranoid_exit)
21515 DEFAULT_FRAME
21516 DISABLE_INTERRUPTS(CLBR_NONE)
21517 TRACE_IRQS_OFF_DEBUG
21518 - testl %ebx,%ebx /* swapgs needed? */
21519 + testl $1,%ebx /* swapgs needed? */
21520 jnz paranoid_restore
21521 - testl $3,CS(%rsp)
21522 + testb $3,CS(%rsp)
21523 jnz paranoid_userspace
21524 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21525 + pax_exit_kernel
21526 + TRACE_IRQS_IRETQ 0
21527 + SWAPGS_UNSAFE_STACK
21528 + RESTORE_ALL 8
21529 + pax_force_retaddr_bts
21530 + jmp irq_return
21531 +#endif
21532 paranoid_swapgs:
21533 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21534 + pax_exit_kernel_user
21535 +#else
21536 + pax_exit_kernel
21537 +#endif
21538 TRACE_IRQS_IRETQ 0
21539 SWAPGS_UNSAFE_STACK
21540 RESTORE_ALL 8
21541 jmp irq_return
21542 paranoid_restore:
21543 + pax_exit_kernel
21544 TRACE_IRQS_IRETQ_DEBUG 0
21545 RESTORE_ALL 8
21546 + pax_force_retaddr_bts
21547 jmp irq_return
21548 paranoid_userspace:
21549 GET_THREAD_INFO(%rcx)
21550 @@ -1541,7 +2083,7 @@ paranoid_schedule:
21551 TRACE_IRQS_OFF
21552 jmp paranoid_userspace
21553 CFI_ENDPROC
21554 -END(paranoid_exit)
21555 +ENDPROC(paranoid_exit)
21556
21557 /*
21558 * Exception entry point. This expects an error code/orig_rax on the stack.
21559 @@ -1568,12 +2110,13 @@ ENTRY(error_entry)
21560 movq_cfi r14, R14+8
21561 movq_cfi r15, R15+8
21562 xorl %ebx,%ebx
21563 - testl $3,CS+8(%rsp)
21564 + testb $3,CS+8(%rsp)
21565 je error_kernelspace
21566 error_swapgs:
21567 SWAPGS
21568 error_sti:
21569 TRACE_IRQS_OFF
21570 + pax_force_retaddr_bts
21571 ret
21572
21573 /*
21574 @@ -1600,7 +2143,7 @@ bstep_iret:
21575 movq %rcx,RIP+8(%rsp)
21576 jmp error_swapgs
21577 CFI_ENDPROC
21578 -END(error_entry)
21579 +ENDPROC(error_entry)
21580
21581
21582 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
21583 @@ -1611,7 +2154,7 @@ ENTRY(error_exit)
21584 DISABLE_INTERRUPTS(CLBR_NONE)
21585 TRACE_IRQS_OFF
21586 GET_THREAD_INFO(%rcx)
21587 - testl %eax,%eax
21588 + testl $1,%eax
21589 jne retint_kernel
21590 LOCKDEP_SYS_EXIT_IRQ
21591 movl TI_flags(%rcx),%edx
21592 @@ -1620,7 +2163,7 @@ ENTRY(error_exit)
21593 jnz retint_careful
21594 jmp retint_swapgs
21595 CFI_ENDPROC
21596 -END(error_exit)
21597 +ENDPROC(error_exit)
21598
21599 /*
21600 * Test if a given stack is an NMI stack or not.
21601 @@ -1678,9 +2221,11 @@ ENTRY(nmi)
21602 * If %cs was not the kernel segment, then the NMI triggered in user
21603 * space, which means it is definitely not nested.
21604 */
21605 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
21606 + je 1f
21607 cmpl $__KERNEL_CS, 16(%rsp)
21608 jne first_nmi
21609 -
21610 +1:
21611 /*
21612 * Check the special variable on the stack to see if NMIs are
21613 * executing.
21614 @@ -1714,8 +2259,7 @@ nested_nmi:
21615
21616 1:
21617 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
21618 - leaq -1*8(%rsp), %rdx
21619 - movq %rdx, %rsp
21620 + subq $8, %rsp
21621 CFI_ADJUST_CFA_OFFSET 1*8
21622 leaq -10*8(%rsp), %rdx
21623 pushq_cfi $__KERNEL_DS
21624 @@ -1733,6 +2277,7 @@ nested_nmi_out:
21625 CFI_RESTORE rdx
21626
21627 /* No need to check faults here */
21628 +# pax_force_retaddr_bts
21629 INTERRUPT_RETURN
21630
21631 CFI_RESTORE_STATE
21632 @@ -1849,6 +2394,8 @@ end_repeat_nmi:
21633 */
21634 movq %cr2, %r12
21635
21636 + pax_enter_kernel_nmi
21637 +
21638 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
21639 movq %rsp,%rdi
21640 movq $-1,%rsi
21641 @@ -1861,26 +2408,31 @@ end_repeat_nmi:
21642 movq %r12, %cr2
21643 1:
21644
21645 - testl %ebx,%ebx /* swapgs needed? */
21646 + testl $1,%ebx /* swapgs needed? */
21647 jnz nmi_restore
21648 nmi_swapgs:
21649 SWAPGS_UNSAFE_STACK
21650 nmi_restore:
21651 + pax_exit_kernel_nmi
21652 /* Pop the extra iret frame at once */
21653 RESTORE_ALL 6*8
21654 + testb $3, 8(%rsp)
21655 + jnz 1f
21656 + pax_force_retaddr_bts
21657 +1:
21658
21659 /* Clear the NMI executing stack variable */
21660 movq $0, 5*8(%rsp)
21661 jmp irq_return
21662 CFI_ENDPROC
21663 -END(nmi)
21664 +ENDPROC(nmi)
21665
21666 ENTRY(ignore_sysret)
21667 CFI_STARTPROC
21668 mov $-ENOSYS,%eax
21669 sysret
21670 CFI_ENDPROC
21671 -END(ignore_sysret)
21672 +ENDPROC(ignore_sysret)
21673
21674 /*
21675 * End of kprobes section
21676 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
21677 index 42a392a..fbbd930 100644
21678 --- a/arch/x86/kernel/ftrace.c
21679 +++ b/arch/x86/kernel/ftrace.c
21680 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
21681 {
21682 unsigned char replaced[MCOUNT_INSN_SIZE];
21683
21684 + ip = ktla_ktva(ip);
21685 +
21686 /*
21687 * Note: Due to modules and __init, code can
21688 * disappear and change, we need to protect against faulting
21689 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
21690 unsigned char old[MCOUNT_INSN_SIZE], *new;
21691 int ret;
21692
21693 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
21694 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
21695 new = ftrace_call_replace(ip, (unsigned long)func);
21696
21697 /* See comment above by declaration of modifying_ftrace_code */
21698 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
21699 /* Also update the regs callback function */
21700 if (!ret) {
21701 ip = (unsigned long)(&ftrace_regs_call);
21702 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
21703 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
21704 new = ftrace_call_replace(ip, (unsigned long)func);
21705 ret = ftrace_modify_code(ip, old, new);
21706 }
21707 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
21708 * kernel identity mapping to modify code.
21709 */
21710 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
21711 - ip = (unsigned long)__va(__pa_symbol(ip));
21712 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
21713
21714 return probe_kernel_write((void *)ip, val, size);
21715 }
21716 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
21717 unsigned char replaced[MCOUNT_INSN_SIZE];
21718 unsigned char brk = BREAKPOINT_INSTRUCTION;
21719
21720 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
21721 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
21722 return -EFAULT;
21723
21724 /* Make sure it is what we expect it to be */
21725 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
21726 return ret;
21727
21728 fail_update:
21729 - probe_kernel_write((void *)ip, &old_code[0], 1);
21730 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
21731 goto out;
21732 }
21733
21734 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
21735 {
21736 unsigned char code[MCOUNT_INSN_SIZE];
21737
21738 + ip = ktla_ktva(ip);
21739 +
21740 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
21741 return -EFAULT;
21742
21743 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
21744 index 55b6761..a6456fc 100644
21745 --- a/arch/x86/kernel/head64.c
21746 +++ b/arch/x86/kernel/head64.c
21747 @@ -67,12 +67,12 @@ again:
21748 pgd = *pgd_p;
21749
21750 /*
21751 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
21752 - * critical -- __PAGE_OFFSET would point us back into the dynamic
21753 + * The use of __early_va rather than __va here is critical:
21754 + * __va would point us back into the dynamic
21755 * range and we might end up looping forever...
21756 */
21757 if (pgd)
21758 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
21759 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
21760 else {
21761 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
21762 reset_early_page_tables();
21763 @@ -82,13 +82,13 @@ again:
21764 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
21765 for (i = 0; i < PTRS_PER_PUD; i++)
21766 pud_p[i] = 0;
21767 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
21768 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
21769 }
21770 pud_p += pud_index(address);
21771 pud = *pud_p;
21772
21773 if (pud)
21774 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
21775 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
21776 else {
21777 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
21778 reset_early_page_tables();
21779 @@ -98,7 +98,7 @@ again:
21780 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
21781 for (i = 0; i < PTRS_PER_PMD; i++)
21782 pmd_p[i] = 0;
21783 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
21784 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
21785 }
21786 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
21787 pmd_p[pmd_index(address)] = pmd;
21788 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
21789 if (console_loglevel == 10)
21790 early_printk("Kernel alive\n");
21791
21792 - clear_page(init_level4_pgt);
21793 /* set init_level4_pgt kernel high mapping*/
21794 init_level4_pgt[511] = early_level4_pgt[511];
21795
21796 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
21797 index 73afd11..0ef46f2 100644
21798 --- a/arch/x86/kernel/head_32.S
21799 +++ b/arch/x86/kernel/head_32.S
21800 @@ -26,6 +26,12 @@
21801 /* Physical address */
21802 #define pa(X) ((X) - __PAGE_OFFSET)
21803
21804 +#ifdef CONFIG_PAX_KERNEXEC
21805 +#define ta(X) (X)
21806 +#else
21807 +#define ta(X) ((X) - __PAGE_OFFSET)
21808 +#endif
21809 +
21810 /*
21811 * References to members of the new_cpu_data structure.
21812 */
21813 @@ -55,11 +61,7 @@
21814 * and small than max_low_pfn, otherwise will waste some page table entries
21815 */
21816
21817 -#if PTRS_PER_PMD > 1
21818 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
21819 -#else
21820 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
21821 -#endif
21822 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
21823
21824 /* Number of possible pages in the lowmem region */
21825 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
21826 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
21827 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
21828
21829 /*
21830 + * Real beginning of normal "text" segment
21831 + */
21832 +ENTRY(stext)
21833 +ENTRY(_stext)
21834 +
21835 +/*
21836 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
21837 * %esi points to the real-mode code as a 32-bit pointer.
21838 * CS and DS must be 4 GB flat segments, but we don't depend on
21839 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
21840 * can.
21841 */
21842 __HEAD
21843 +
21844 +#ifdef CONFIG_PAX_KERNEXEC
21845 + jmp startup_32
21846 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
21847 +.fill PAGE_SIZE-5,1,0xcc
21848 +#endif
21849 +
21850 ENTRY(startup_32)
21851 movl pa(stack_start),%ecx
21852
21853 @@ -106,6 +121,59 @@ ENTRY(startup_32)
21854 2:
21855 leal -__PAGE_OFFSET(%ecx),%esp
21856
21857 +#ifdef CONFIG_SMP
21858 + movl $pa(cpu_gdt_table),%edi
21859 + movl $__per_cpu_load,%eax
21860 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
21861 + rorl $16,%eax
21862 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
21863 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
21864 + movl $__per_cpu_end - 1,%eax
21865 + subl $__per_cpu_start,%eax
21866 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
21867 +#endif
21868 +
21869 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21870 + movl $NR_CPUS,%ecx
21871 + movl $pa(cpu_gdt_table),%edi
21872 +1:
21873 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
21874 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
21875 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
21876 + addl $PAGE_SIZE_asm,%edi
21877 + loop 1b
21878 +#endif
21879 +
21880 +#ifdef CONFIG_PAX_KERNEXEC
21881 + movl $pa(boot_gdt),%edi
21882 + movl $__LOAD_PHYSICAL_ADDR,%eax
21883 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
21884 + rorl $16,%eax
21885 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
21886 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
21887 + rorl $16,%eax
21888 +
21889 + ljmp $(__BOOT_CS),$1f
21890 +1:
21891 +
21892 + movl $NR_CPUS,%ecx
21893 + movl $pa(cpu_gdt_table),%edi
21894 + addl $__PAGE_OFFSET,%eax
21895 +1:
21896 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
21897 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
21898 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
21899 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
21900 + rorl $16,%eax
21901 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
21902 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
21903 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
21904 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
21905 + rorl $16,%eax
21906 + addl $PAGE_SIZE_asm,%edi
21907 + loop 1b
21908 +#endif
21909 +
21910 /*
21911 * Clear BSS first so that there are no surprises...
21912 */
21913 @@ -201,8 +269,11 @@ ENTRY(startup_32)
21914 movl %eax, pa(max_pfn_mapped)
21915
21916 /* Do early initialization of the fixmap area */
21917 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
21918 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
21919 +#ifdef CONFIG_COMPAT_VDSO
21920 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
21921 +#else
21922 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
21923 +#endif
21924 #else /* Not PAE */
21925
21926 page_pde_offset = (__PAGE_OFFSET >> 20);
21927 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
21928 movl %eax, pa(max_pfn_mapped)
21929
21930 /* Do early initialization of the fixmap area */
21931 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
21932 - movl %eax,pa(initial_page_table+0xffc)
21933 +#ifdef CONFIG_COMPAT_VDSO
21934 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
21935 +#else
21936 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
21937 +#endif
21938 #endif
21939
21940 #ifdef CONFIG_PARAVIRT
21941 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
21942 cmpl $num_subarch_entries, %eax
21943 jae bad_subarch
21944
21945 - movl pa(subarch_entries)(,%eax,4), %eax
21946 - subl $__PAGE_OFFSET, %eax
21947 - jmp *%eax
21948 + jmp *pa(subarch_entries)(,%eax,4)
21949
21950 bad_subarch:
21951 WEAK(lguest_entry)
21952 @@ -261,10 +333,10 @@ WEAK(xen_entry)
21953 __INITDATA
21954
21955 subarch_entries:
21956 - .long default_entry /* normal x86/PC */
21957 - .long lguest_entry /* lguest hypervisor */
21958 - .long xen_entry /* Xen hypervisor */
21959 - .long default_entry /* Moorestown MID */
21960 + .long ta(default_entry) /* normal x86/PC */
21961 + .long ta(lguest_entry) /* lguest hypervisor */
21962 + .long ta(xen_entry) /* Xen hypervisor */
21963 + .long ta(default_entry) /* Moorestown MID */
21964 num_subarch_entries = (. - subarch_entries) / 4
21965 .previous
21966 #else
21967 @@ -355,6 +427,7 @@ default_entry:
21968 movl pa(mmu_cr4_features),%eax
21969 movl %eax,%cr4
21970
21971 +#ifdef CONFIG_X86_PAE
21972 testb $X86_CR4_PAE, %al # check if PAE is enabled
21973 jz enable_paging
21974
21975 @@ -383,6 +456,9 @@ default_entry:
21976 /* Make changes effective */
21977 wrmsr
21978
21979 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
21980 +#endif
21981 +
21982 enable_paging:
21983
21984 /*
21985 @@ -451,14 +527,20 @@ is486:
21986 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
21987 movl %eax,%ss # after changing gdt.
21988
21989 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
21990 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
21991 movl %eax,%ds
21992 movl %eax,%es
21993
21994 movl $(__KERNEL_PERCPU), %eax
21995 movl %eax,%fs # set this cpu's percpu
21996
21997 +#ifdef CONFIG_CC_STACKPROTECTOR
21998 movl $(__KERNEL_STACK_CANARY),%eax
21999 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22000 + movl $(__USER_DS),%eax
22001 +#else
22002 + xorl %eax,%eax
22003 +#endif
22004 movl %eax,%gs
22005
22006 xorl %eax,%eax # Clear LDT
22007 @@ -534,8 +616,11 @@ setup_once:
22008 * relocation. Manually set base address in stack canary
22009 * segment descriptor.
22010 */
22011 - movl $gdt_page,%eax
22012 + movl $cpu_gdt_table,%eax
22013 movl $stack_canary,%ecx
22014 +#ifdef CONFIG_SMP
22015 + addl $__per_cpu_load,%ecx
22016 +#endif
22017 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22018 shrl $16, %ecx
22019 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22020 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
22021 /* This is global to keep gas from relaxing the jumps */
22022 ENTRY(early_idt_handler)
22023 cld
22024 - cmpl $2,%ss:early_recursion_flag
22025 + cmpl $1,%ss:early_recursion_flag
22026 je hlt_loop
22027 incl %ss:early_recursion_flag
22028
22029 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
22030 pushl (20+6*4)(%esp) /* trapno */
22031 pushl $fault_msg
22032 call printk
22033 -#endif
22034 call dump_stack
22035 +#endif
22036 hlt_loop:
22037 hlt
22038 jmp hlt_loop
22039 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
22040 /* This is the default interrupt "handler" :-) */
22041 ALIGN
22042 ignore_int:
22043 - cld
22044 #ifdef CONFIG_PRINTK
22045 + cmpl $2,%ss:early_recursion_flag
22046 + je hlt_loop
22047 + incl %ss:early_recursion_flag
22048 + cld
22049 pushl %eax
22050 pushl %ecx
22051 pushl %edx
22052 @@ -634,9 +722,6 @@ ignore_int:
22053 movl $(__KERNEL_DS),%eax
22054 movl %eax,%ds
22055 movl %eax,%es
22056 - cmpl $2,early_recursion_flag
22057 - je hlt_loop
22058 - incl early_recursion_flag
22059 pushl 16(%esp)
22060 pushl 24(%esp)
22061 pushl 32(%esp)
22062 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
22063 /*
22064 * BSS section
22065 */
22066 -__PAGE_ALIGNED_BSS
22067 - .align PAGE_SIZE
22068 #ifdef CONFIG_X86_PAE
22069 +.section .initial_pg_pmd,"a",@progbits
22070 initial_pg_pmd:
22071 .fill 1024*KPMDS,4,0
22072 #else
22073 +.section .initial_page_table,"a",@progbits
22074 ENTRY(initial_page_table)
22075 .fill 1024,4,0
22076 #endif
22077 +.section .initial_pg_fixmap,"a",@progbits
22078 initial_pg_fixmap:
22079 .fill 1024,4,0
22080 +.section .empty_zero_page,"a",@progbits
22081 ENTRY(empty_zero_page)
22082 .fill 4096,1,0
22083 +.section .swapper_pg_dir,"a",@progbits
22084 ENTRY(swapper_pg_dir)
22085 +#ifdef CONFIG_X86_PAE
22086 + .fill 4,8,0
22087 +#else
22088 .fill 1024,4,0
22089 +#endif
22090 +
22091 +/*
22092 + * The IDT has to be page-aligned to simplify the Pentium
22093 + * F0 0F bug workaround.. We have a special link segment
22094 + * for this.
22095 + */
22096 +.section .idt,"a",@progbits
22097 +ENTRY(idt_table)
22098 + .fill 256,8,0
22099
22100 /*
22101 * This starts the data section.
22102 */
22103 #ifdef CONFIG_X86_PAE
22104 -__PAGE_ALIGNED_DATA
22105 - /* Page-aligned for the benefit of paravirt? */
22106 - .align PAGE_SIZE
22107 +.section .initial_page_table,"a",@progbits
22108 ENTRY(initial_page_table)
22109 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22110 # if KPMDS == 3
22111 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
22112 # error "Kernel PMDs should be 1, 2 or 3"
22113 # endif
22114 .align PAGE_SIZE /* needs to be page-sized too */
22115 +
22116 +#ifdef CONFIG_PAX_PER_CPU_PGD
22117 +ENTRY(cpu_pgd)
22118 + .rept 2*NR_CPUS
22119 + .fill 4,8,0
22120 + .endr
22121 +#endif
22122 +
22123 #endif
22124
22125 .data
22126 .balign 4
22127 ENTRY(stack_start)
22128 - .long init_thread_union+THREAD_SIZE
22129 + .long init_thread_union+THREAD_SIZE-8
22130
22131 __INITRODATA
22132 int_msg:
22133 @@ -744,7 +851,7 @@ fault_msg:
22134 * segment size, and 32-bit linear address value:
22135 */
22136
22137 - .data
22138 +.section .rodata,"a",@progbits
22139 .globl boot_gdt_descr
22140 .globl idt_descr
22141
22142 @@ -753,7 +860,7 @@ fault_msg:
22143 .word 0 # 32 bit align gdt_desc.address
22144 boot_gdt_descr:
22145 .word __BOOT_DS+7
22146 - .long boot_gdt - __PAGE_OFFSET
22147 + .long pa(boot_gdt)
22148
22149 .word 0 # 32-bit align idt_desc.address
22150 idt_descr:
22151 @@ -764,7 +871,7 @@ idt_descr:
22152 .word 0 # 32 bit align gdt_desc.address
22153 ENTRY(early_gdt_descr)
22154 .word GDT_ENTRIES*8-1
22155 - .long gdt_page /* Overwritten for secondary CPUs */
22156 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22157
22158 /*
22159 * The boot_gdt must mirror the equivalent in setup.S and is
22160 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
22161 .align L1_CACHE_BYTES
22162 ENTRY(boot_gdt)
22163 .fill GDT_ENTRY_BOOT_CS,8,0
22164 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22165 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22166 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22167 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22168 +
22169 + .align PAGE_SIZE_asm
22170 +ENTRY(cpu_gdt_table)
22171 + .rept NR_CPUS
22172 + .quad 0x0000000000000000 /* NULL descriptor */
22173 + .quad 0x0000000000000000 /* 0x0b reserved */
22174 + .quad 0x0000000000000000 /* 0x13 reserved */
22175 + .quad 0x0000000000000000 /* 0x1b reserved */
22176 +
22177 +#ifdef CONFIG_PAX_KERNEXEC
22178 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22179 +#else
22180 + .quad 0x0000000000000000 /* 0x20 unused */
22181 +#endif
22182 +
22183 + .quad 0x0000000000000000 /* 0x28 unused */
22184 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22185 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22186 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22187 + .quad 0x0000000000000000 /* 0x4b reserved */
22188 + .quad 0x0000000000000000 /* 0x53 reserved */
22189 + .quad 0x0000000000000000 /* 0x5b reserved */
22190 +
22191 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
22192 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
22193 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
22194 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
22195 +
22196 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
22197 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
22198 +
22199 + /*
22200 + * Segments used for calling PnP BIOS have byte granularity.
22201 + * The code segments and data segments have fixed 64k limits,
22202 + * the transfer segment sizes are set at run time.
22203 + */
22204 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
22205 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
22206 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
22207 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
22208 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
22209 +
22210 + /*
22211 + * The APM segments have byte granularity and their bases
22212 + * are set at run time. All have 64k limits.
22213 + */
22214 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
22215 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
22216 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
22217 +
22218 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
22219 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
22220 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
22221 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
22222 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
22223 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
22224 +
22225 + /* Be sure this is zeroed to avoid false validations in Xen */
22226 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
22227 + .endr
22228 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
22229 index a836860..1b5c665 100644
22230 --- a/arch/x86/kernel/head_64.S
22231 +++ b/arch/x86/kernel/head_64.S
22232 @@ -20,6 +20,8 @@
22233 #include <asm/processor-flags.h>
22234 #include <asm/percpu.h>
22235 #include <asm/nops.h>
22236 +#include <asm/cpufeature.h>
22237 +#include <asm/alternative-asm.h>
22238
22239 #ifdef CONFIG_PARAVIRT
22240 #include <asm/asm-offsets.h>
22241 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
22242 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
22243 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
22244 L3_START_KERNEL = pud_index(__START_KERNEL_map)
22245 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
22246 +L3_VMALLOC_START = pud_index(VMALLOC_START)
22247 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
22248 +L3_VMALLOC_END = pud_index(VMALLOC_END)
22249 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
22250 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
22251
22252 .text
22253 __HEAD
22254 @@ -89,11 +97,23 @@ startup_64:
22255 * Fixup the physical addresses in the page table
22256 */
22257 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
22258 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
22259 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
22260 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
22261 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
22262 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
22263
22264 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
22265 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
22266 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
22267 +#ifndef CONFIG_XEN
22268 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
22269 +#endif
22270
22271 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
22272 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
22273 +
22274 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
22275 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
22276 +
22277 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
22278
22279 /*
22280 * Set up the identity mapping for the switchover. These
22281 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
22282 movq $(init_level4_pgt - __START_KERNEL_map), %rax
22283 1:
22284
22285 - /* Enable PAE mode and PGE */
22286 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
22287 + /* Enable PAE mode and PSE/PGE */
22288 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
22289 movq %rcx, %cr4
22290
22291 /* Setup early boot stage 4 level pagetables. */
22292 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
22293 movl $MSR_EFER, %ecx
22294 rdmsr
22295 btsl $_EFER_SCE, %eax /* Enable System Call */
22296 - btl $20,%edi /* No Execute supported? */
22297 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
22298 jnc 1f
22299 btsl $_EFER_NX, %eax
22300 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
22301 + leaq init_level4_pgt(%rip), %rdi
22302 +#ifndef CONFIG_EFI
22303 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
22304 +#endif
22305 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
22306 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
22307 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
22308 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
22309 1: wrmsr /* Make changes effective */
22310
22311 /* Setup cr0 */
22312 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
22313 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
22314 * address given in m16:64.
22315 */
22316 + pax_set_fptr_mask
22317 movq initial_code(%rip),%rax
22318 pushq $0 # fake return address to stop unwinder
22319 pushq $__KERNEL_CS # set correct cs
22320 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
22321 call dump_stack
22322 #ifdef CONFIG_KALLSYMS
22323 leaq early_idt_ripmsg(%rip),%rdi
22324 - movq 40(%rsp),%rsi # %rip again
22325 + movq 88(%rsp),%rsi # %rip again
22326 call __print_symbol
22327 #endif
22328 #endif /* EARLY_PRINTK */
22329 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
22330 early_recursion_flag:
22331 .long 0
22332
22333 + .section .rodata,"a",@progbits
22334 #ifdef CONFIG_EARLY_PRINTK
22335 early_idt_msg:
22336 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
22337 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
22338 NEXT_PAGE(early_dynamic_pgts)
22339 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
22340
22341 - .data
22342 + .section .rodata,"a",@progbits
22343
22344 -#ifndef CONFIG_XEN
22345 NEXT_PAGE(init_level4_pgt)
22346 - .fill 512,8,0
22347 -#else
22348 -NEXT_PAGE(init_level4_pgt)
22349 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
22350 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
22351 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
22352 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
22353 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
22354 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
22355 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
22356 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
22357 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
22358 .org init_level4_pgt + L4_START_KERNEL*8, 0
22359 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
22360 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
22361
22362 +#ifdef CONFIG_PAX_PER_CPU_PGD
22363 +NEXT_PAGE(cpu_pgd)
22364 + .rept 2*NR_CPUS
22365 + .fill 512,8,0
22366 + .endr
22367 +#endif
22368 +
22369 NEXT_PAGE(level3_ident_pgt)
22370 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
22371 +#ifdef CONFIG_XEN
22372 .fill 511, 8, 0
22373 +#else
22374 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
22375 + .fill 510,8,0
22376 +#endif
22377 +
22378 +NEXT_PAGE(level3_vmalloc_start_pgt)
22379 + .fill 512,8,0
22380 +
22381 +NEXT_PAGE(level3_vmalloc_end_pgt)
22382 + .fill 512,8,0
22383 +
22384 +NEXT_PAGE(level3_vmemmap_pgt)
22385 + .fill L3_VMEMMAP_START,8,0
22386 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
22387 +
22388 NEXT_PAGE(level2_ident_pgt)
22389 - /* Since I easily can, map the first 1G.
22390 + /* Since I easily can, map the first 2G.
22391 * Don't set NX because code runs from these pages.
22392 */
22393 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
22394 -#endif
22395 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
22396
22397 NEXT_PAGE(level3_kernel_pgt)
22398 .fill L3_START_KERNEL,8,0
22399 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
22400 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
22401 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
22402
22403 +NEXT_PAGE(level2_vmemmap_pgt)
22404 + .fill 512,8,0
22405 +
22406 NEXT_PAGE(level2_kernel_pgt)
22407 /*
22408 * 512 MB kernel mapping. We spend a full page on this pagetable
22409 @@ -488,39 +544,70 @@ NEXT_PAGE(level2_kernel_pgt)
22410 KERNEL_IMAGE_SIZE/PMD_SIZE)
22411
22412 NEXT_PAGE(level2_fixmap_pgt)
22413 - .fill 506,8,0
22414 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
22415 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
22416 - .fill 5,8,0
22417 + .fill 507,8,0
22418 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
22419 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
22420 + .fill 4,8,0
22421
22422 -NEXT_PAGE(level1_fixmap_pgt)
22423 +NEXT_PAGE(level1_vsyscall_pgt)
22424 .fill 512,8,0
22425
22426 #undef PMDS
22427
22428 - .data
22429 + .align PAGE_SIZE
22430 +ENTRY(cpu_gdt_table)
22431 + .rept NR_CPUS
22432 + .quad 0x0000000000000000 /* NULL descriptor */
22433 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
22434 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
22435 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
22436 + .quad 0x00cffb000000ffff /* __USER32_CS */
22437 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
22438 + .quad 0x00affb000000ffff /* __USER_CS */
22439 +
22440 +#ifdef CONFIG_PAX_KERNEXEC
22441 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
22442 +#else
22443 + .quad 0x0 /* unused */
22444 +#endif
22445 +
22446 + .quad 0,0 /* TSS */
22447 + .quad 0,0 /* LDT */
22448 + .quad 0,0,0 /* three TLS descriptors */
22449 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
22450 + /* asm/segment.h:GDT_ENTRIES must match this */
22451 +
22452 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22453 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
22454 +#else
22455 + .quad 0x0 /* unused */
22456 +#endif
22457 +
22458 + /* zero the remaining page */
22459 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
22460 + .endr
22461 +
22462 .align 16
22463 .globl early_gdt_descr
22464 early_gdt_descr:
22465 .word GDT_ENTRIES*8-1
22466 early_gdt_descr_base:
22467 - .quad INIT_PER_CPU_VAR(gdt_page)
22468 + .quad cpu_gdt_table
22469
22470 ENTRY(phys_base)
22471 /* This must match the first entry in level2_kernel_pgt */
22472 .quad 0x0000000000000000
22473
22474 #include "../../x86/xen/xen-head.S"
22475 -
22476 - .section .bss, "aw", @nobits
22477 +
22478 + .section .rodata,"a",@progbits
22479 +NEXT_PAGE(empty_zero_page)
22480 + .skip PAGE_SIZE
22481 +
22482 .align PAGE_SIZE
22483 ENTRY(idt_table)
22484 - .skip IDT_ENTRIES * 16
22485 + .fill 512,8,0
22486
22487 .align L1_CACHE_BYTES
22488 ENTRY(nmi_idt_table)
22489 - .skip IDT_ENTRIES * 16
22490 -
22491 - __PAGE_ALIGNED_BSS
22492 -NEXT_PAGE(empty_zero_page)
22493 - .skip PAGE_SIZE
22494 + .fill 512,8,0
22495 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
22496 index 0fa6912..37fce70 100644
22497 --- a/arch/x86/kernel/i386_ksyms_32.c
22498 +++ b/arch/x86/kernel/i386_ksyms_32.c
22499 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
22500 EXPORT_SYMBOL(cmpxchg8b_emu);
22501 #endif
22502
22503 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
22504 +
22505 /* Networking helper routines. */
22506 EXPORT_SYMBOL(csum_partial_copy_generic);
22507 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
22508 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
22509
22510 EXPORT_SYMBOL(__get_user_1);
22511 EXPORT_SYMBOL(__get_user_2);
22512 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
22513
22514 EXPORT_SYMBOL(csum_partial);
22515 EXPORT_SYMBOL(empty_zero_page);
22516 +
22517 +#ifdef CONFIG_PAX_KERNEXEC
22518 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
22519 +#endif
22520 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
22521 index f7ea30d..6318acc 100644
22522 --- a/arch/x86/kernel/i387.c
22523 +++ b/arch/x86/kernel/i387.c
22524 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
22525 static inline bool interrupted_user_mode(void)
22526 {
22527 struct pt_regs *regs = get_irq_regs();
22528 - return regs && user_mode_vm(regs);
22529 + return regs && user_mode(regs);
22530 }
22531
22532 /*
22533 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
22534 index 9a5c460..84868423 100644
22535 --- a/arch/x86/kernel/i8259.c
22536 +++ b/arch/x86/kernel/i8259.c
22537 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
22538 static void make_8259A_irq(unsigned int irq)
22539 {
22540 disable_irq_nosync(irq);
22541 - io_apic_irqs &= ~(1<<irq);
22542 + io_apic_irqs &= ~(1UL<<irq);
22543 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
22544 i8259A_chip.name);
22545 enable_irq(irq);
22546 @@ -209,7 +209,7 @@ spurious_8259A_irq:
22547 "spurious 8259A interrupt: IRQ%d.\n", irq);
22548 spurious_irq_mask |= irqmask;
22549 }
22550 - atomic_inc(&irq_err_count);
22551 + atomic_inc_unchecked(&irq_err_count);
22552 /*
22553 * Theoretically we do not have to handle this IRQ,
22554 * but in Linux this does not cause problems and is
22555 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
22556 /* (slave's support for AEOI in flat mode is to be investigated) */
22557 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
22558
22559 + pax_open_kernel();
22560 if (auto_eoi)
22561 /*
22562 * In AEOI mode we just have to mask the interrupt
22563 * when acking.
22564 */
22565 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
22566 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
22567 else
22568 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
22569 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
22570 + pax_close_kernel();
22571
22572 udelay(100); /* wait for 8259A to initialize */
22573
22574 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
22575 index a979b5b..1d6db75 100644
22576 --- a/arch/x86/kernel/io_delay.c
22577 +++ b/arch/x86/kernel/io_delay.c
22578 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
22579 * Quirk table for systems that misbehave (lock up, etc.) if port
22580 * 0x80 is used:
22581 */
22582 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
22583 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
22584 {
22585 .callback = dmi_io_delay_0xed_port,
22586 .ident = "Compaq Presario V6000",
22587 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
22588 index 4ddaf66..6292f4e 100644
22589 --- a/arch/x86/kernel/ioport.c
22590 +++ b/arch/x86/kernel/ioport.c
22591 @@ -6,6 +6,7 @@
22592 #include <linux/sched.h>
22593 #include <linux/kernel.h>
22594 #include <linux/capability.h>
22595 +#include <linux/security.h>
22596 #include <linux/errno.h>
22597 #include <linux/types.h>
22598 #include <linux/ioport.h>
22599 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
22600
22601 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
22602 return -EINVAL;
22603 +#ifdef CONFIG_GRKERNSEC_IO
22604 + if (turn_on && grsec_disable_privio) {
22605 + gr_handle_ioperm();
22606 + return -EPERM;
22607 + }
22608 +#endif
22609 if (turn_on && !capable(CAP_SYS_RAWIO))
22610 return -EPERM;
22611
22612 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
22613 * because the ->io_bitmap_max value must match the bitmap
22614 * contents:
22615 */
22616 - tss = &per_cpu(init_tss, get_cpu());
22617 + tss = init_tss + get_cpu();
22618
22619 if (turn_on)
22620 bitmap_clear(t->io_bitmap_ptr, from, num);
22621 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
22622 return -EINVAL;
22623 /* Trying to gain more privileges? */
22624 if (level > old) {
22625 +#ifdef CONFIG_GRKERNSEC_IO
22626 + if (grsec_disable_privio) {
22627 + gr_handle_iopl();
22628 + return -EPERM;
22629 + }
22630 +#endif
22631 if (!capable(CAP_SYS_RAWIO))
22632 return -EPERM;
22633 }
22634 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
22635 index ac0631d..ff7cb62 100644
22636 --- a/arch/x86/kernel/irq.c
22637 +++ b/arch/x86/kernel/irq.c
22638 @@ -18,7 +18,7 @@
22639 #include <asm/mce.h>
22640 #include <asm/hw_irq.h>
22641
22642 -atomic_t irq_err_count;
22643 +atomic_unchecked_t irq_err_count;
22644
22645 /* Function pointer for generic interrupt vector handling */
22646 void (*x86_platform_ipi_callback)(void) = NULL;
22647 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
22648 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
22649 seq_printf(p, " Machine check polls\n");
22650 #endif
22651 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
22652 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
22653 #if defined(CONFIG_X86_IO_APIC)
22654 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
22655 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
22656 #endif
22657 return 0;
22658 }
22659 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
22660
22661 u64 arch_irq_stat(void)
22662 {
22663 - u64 sum = atomic_read(&irq_err_count);
22664 + u64 sum = atomic_read_unchecked(&irq_err_count);
22665 return sum;
22666 }
22667
22668 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
22669 index 344faf8..355f60d 100644
22670 --- a/arch/x86/kernel/irq_32.c
22671 +++ b/arch/x86/kernel/irq_32.c
22672 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
22673 __asm__ __volatile__("andl %%esp,%0" :
22674 "=r" (sp) : "0" (THREAD_SIZE - 1));
22675
22676 - return sp < (sizeof(struct thread_info) + STACK_WARN);
22677 + return sp < STACK_WARN;
22678 }
22679
22680 static void print_stack_overflow(void)
22681 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
22682 * per-CPU IRQ handling contexts (thread information and stack)
22683 */
22684 union irq_ctx {
22685 - struct thread_info tinfo;
22686 - u32 stack[THREAD_SIZE/sizeof(u32)];
22687 + unsigned long previous_esp;
22688 + u32 stack[THREAD_SIZE/sizeof(u32)];
22689 } __attribute__((aligned(THREAD_SIZE)));
22690
22691 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
22692 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
22693 static inline int
22694 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
22695 {
22696 - union irq_ctx *curctx, *irqctx;
22697 + union irq_ctx *irqctx;
22698 u32 *isp, arg1, arg2;
22699
22700 - curctx = (union irq_ctx *) current_thread_info();
22701 irqctx = __this_cpu_read(hardirq_ctx);
22702
22703 /*
22704 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
22705 * handler) we can't do that and just have to keep using the
22706 * current stack (which is the irq stack already after all)
22707 */
22708 - if (unlikely(curctx == irqctx))
22709 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
22710 return 0;
22711
22712 /* build the stack frame on the IRQ stack */
22713 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
22714 - irqctx->tinfo.task = curctx->tinfo.task;
22715 - irqctx->tinfo.previous_esp = current_stack_pointer;
22716 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
22717 + irqctx->previous_esp = current_stack_pointer;
22718
22719 - /* Copy the preempt_count so that the [soft]irq checks work. */
22720 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
22721 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22722 + __set_fs(MAKE_MM_SEG(0));
22723 +#endif
22724
22725 if (unlikely(overflow))
22726 call_on_stack(print_stack_overflow, isp);
22727 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
22728 : "0" (irq), "1" (desc), "2" (isp),
22729 "D" (desc->handle_irq)
22730 : "memory", "cc", "ecx");
22731 +
22732 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22733 + __set_fs(current_thread_info()->addr_limit);
22734 +#endif
22735 +
22736 return 1;
22737 }
22738
22739 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
22740 */
22741 void __cpuinit irq_ctx_init(int cpu)
22742 {
22743 - union irq_ctx *irqctx;
22744 -
22745 if (per_cpu(hardirq_ctx, cpu))
22746 return;
22747
22748 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
22749 - THREADINFO_GFP,
22750 - THREAD_SIZE_ORDER));
22751 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
22752 - irqctx->tinfo.cpu = cpu;
22753 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
22754 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
22755 -
22756 - per_cpu(hardirq_ctx, cpu) = irqctx;
22757 -
22758 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
22759 - THREADINFO_GFP,
22760 - THREAD_SIZE_ORDER));
22761 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
22762 - irqctx->tinfo.cpu = cpu;
22763 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
22764 -
22765 - per_cpu(softirq_ctx, cpu) = irqctx;
22766 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
22767 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
22768 +
22769 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
22770 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
22771
22772 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
22773 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
22774 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
22775 asmlinkage void do_softirq(void)
22776 {
22777 unsigned long flags;
22778 - struct thread_info *curctx;
22779 union irq_ctx *irqctx;
22780 u32 *isp;
22781
22782 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
22783 local_irq_save(flags);
22784
22785 if (local_softirq_pending()) {
22786 - curctx = current_thread_info();
22787 irqctx = __this_cpu_read(softirq_ctx);
22788 - irqctx->tinfo.task = curctx->task;
22789 - irqctx->tinfo.previous_esp = current_stack_pointer;
22790 + irqctx->previous_esp = current_stack_pointer;
22791
22792 /* build the stack frame on the softirq stack */
22793 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
22794 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
22795 +
22796 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22797 + __set_fs(MAKE_MM_SEG(0));
22798 +#endif
22799
22800 call_on_stack(__do_softirq, isp);
22801 +
22802 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22803 + __set_fs(current_thread_info()->addr_limit);
22804 +#endif
22805 +
22806 /*
22807 * Shouldn't happen, we returned above if in_interrupt():
22808 */
22809 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
22810 if (unlikely(!desc))
22811 return false;
22812
22813 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
22814 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
22815 if (unlikely(overflow))
22816 print_stack_overflow();
22817 desc->handle_irq(irq, desc);
22818 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
22819 index d04d3ec..ea4b374 100644
22820 --- a/arch/x86/kernel/irq_64.c
22821 +++ b/arch/x86/kernel/irq_64.c
22822 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
22823 u64 estack_top, estack_bottom;
22824 u64 curbase = (u64)task_stack_page(current);
22825
22826 - if (user_mode_vm(regs))
22827 + if (user_mode(regs))
22828 return;
22829
22830 if (regs->sp >= curbase + sizeof(struct thread_info) +
22831 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
22832 index dc1404b..bbc43e7 100644
22833 --- a/arch/x86/kernel/kdebugfs.c
22834 +++ b/arch/x86/kernel/kdebugfs.c
22835 @@ -27,7 +27,7 @@ struct setup_data_node {
22836 u32 len;
22837 };
22838
22839 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
22840 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
22841 size_t count, loff_t *ppos)
22842 {
22843 struct setup_data_node *node = file->private_data;
22844 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
22845 index 836f832..a8bda67 100644
22846 --- a/arch/x86/kernel/kgdb.c
22847 +++ b/arch/x86/kernel/kgdb.c
22848 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
22849 #ifdef CONFIG_X86_32
22850 switch (regno) {
22851 case GDB_SS:
22852 - if (!user_mode_vm(regs))
22853 + if (!user_mode(regs))
22854 *(unsigned long *)mem = __KERNEL_DS;
22855 break;
22856 case GDB_SP:
22857 - if (!user_mode_vm(regs))
22858 + if (!user_mode(regs))
22859 *(unsigned long *)mem = kernel_stack_pointer(regs);
22860 break;
22861 case GDB_GS:
22862 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
22863 bp->attr.bp_addr = breakinfo[breakno].addr;
22864 bp->attr.bp_len = breakinfo[breakno].len;
22865 bp->attr.bp_type = breakinfo[breakno].type;
22866 - info->address = breakinfo[breakno].addr;
22867 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
22868 + info->address = ktla_ktva(breakinfo[breakno].addr);
22869 + else
22870 + info->address = breakinfo[breakno].addr;
22871 info->len = breakinfo[breakno].len;
22872 info->type = breakinfo[breakno].type;
22873 val = arch_install_hw_breakpoint(bp);
22874 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
22875 case 'k':
22876 /* clear the trace bit */
22877 linux_regs->flags &= ~X86_EFLAGS_TF;
22878 - atomic_set(&kgdb_cpu_doing_single_step, -1);
22879 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
22880
22881 /* set the trace bit if we're stepping */
22882 if (remcomInBuffer[0] == 's') {
22883 linux_regs->flags |= X86_EFLAGS_TF;
22884 - atomic_set(&kgdb_cpu_doing_single_step,
22885 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
22886 raw_smp_processor_id());
22887 }
22888
22889 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
22890
22891 switch (cmd) {
22892 case DIE_DEBUG:
22893 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
22894 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
22895 if (user_mode(regs))
22896 return single_step_cont(regs, args);
22897 break;
22898 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
22899 #endif /* CONFIG_DEBUG_RODATA */
22900
22901 bpt->type = BP_BREAKPOINT;
22902 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
22903 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
22904 BREAK_INSTR_SIZE);
22905 if (err)
22906 return err;
22907 - err = probe_kernel_write((char *)bpt->bpt_addr,
22908 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
22909 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
22910 #ifdef CONFIG_DEBUG_RODATA
22911 if (!err)
22912 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
22913 return -EBUSY;
22914 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
22915 BREAK_INSTR_SIZE);
22916 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
22917 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
22918 if (err)
22919 return err;
22920 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
22921 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
22922 if (mutex_is_locked(&text_mutex))
22923 goto knl_write;
22924 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
22925 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
22926 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
22927 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
22928 goto knl_write;
22929 return err;
22930 knl_write:
22931 #endif /* CONFIG_DEBUG_RODATA */
22932 - return probe_kernel_write((char *)bpt->bpt_addr,
22933 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
22934 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
22935 }
22936
22937 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
22938 index 211bce4..6e2580a 100644
22939 --- a/arch/x86/kernel/kprobes/core.c
22940 +++ b/arch/x86/kernel/kprobes/core.c
22941 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
22942 s32 raddr;
22943 } __packed *insn;
22944
22945 - insn = (struct __arch_relative_insn *)from;
22946 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
22947 +
22948 + pax_open_kernel();
22949 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
22950 insn->op = op;
22951 + pax_close_kernel();
22952 }
22953
22954 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
22955 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
22956 kprobe_opcode_t opcode;
22957 kprobe_opcode_t *orig_opcodes = opcodes;
22958
22959 - if (search_exception_tables((unsigned long)opcodes))
22960 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
22961 return 0; /* Page fault may occur on this address. */
22962
22963 retry:
22964 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
22965 * for the first byte, we can recover the original instruction
22966 * from it and kp->opcode.
22967 */
22968 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
22969 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
22970 buf[0] = kp->opcode;
22971 - return (unsigned long)buf;
22972 + return ktva_ktla((unsigned long)buf);
22973 }
22974
22975 /*
22976 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
22977 /* Another subsystem puts a breakpoint, failed to recover */
22978 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
22979 return 0;
22980 + pax_open_kernel();
22981 memcpy(dest, insn.kaddr, insn.length);
22982 + pax_close_kernel();
22983
22984 #ifdef CONFIG_X86_64
22985 if (insn_rip_relative(&insn)) {
22986 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
22987 return 0;
22988 }
22989 disp = (u8 *) dest + insn_offset_displacement(&insn);
22990 + pax_open_kernel();
22991 *(s32 *) disp = (s32) newdisp;
22992 + pax_close_kernel();
22993 }
22994 #endif
22995 return insn.length;
22996 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
22997 * nor set current_kprobe, because it doesn't use single
22998 * stepping.
22999 */
23000 - regs->ip = (unsigned long)p->ainsn.insn;
23001 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23002 preempt_enable_no_resched();
23003 return;
23004 }
23005 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23006 regs->flags &= ~X86_EFLAGS_IF;
23007 /* single step inline if the instruction is an int3 */
23008 if (p->opcode == BREAKPOINT_INSTRUCTION)
23009 - regs->ip = (unsigned long)p->addr;
23010 + regs->ip = ktla_ktva((unsigned long)p->addr);
23011 else
23012 - regs->ip = (unsigned long)p->ainsn.insn;
23013 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23014 }
23015
23016 /*
23017 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23018 setup_singlestep(p, regs, kcb, 0);
23019 return 1;
23020 }
23021 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23022 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23023 /*
23024 * The breakpoint instruction was removed right
23025 * after we hit it. Another cpu has removed
23026 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23027 " movq %rax, 152(%rsp)\n"
23028 RESTORE_REGS_STRING
23029 " popfq\n"
23030 +#ifdef KERNEXEC_PLUGIN
23031 + " btsq $63,(%rsp)\n"
23032 +#endif
23033 #else
23034 " pushf\n"
23035 SAVE_REGS_STRING
23036 @@ -779,7 +789,7 @@ static void __kprobes
23037 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23038 {
23039 unsigned long *tos = stack_addr(regs);
23040 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23041 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23042 unsigned long orig_ip = (unsigned long)p->addr;
23043 kprobe_opcode_t *insn = p->ainsn.insn;
23044
23045 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23046 struct die_args *args = data;
23047 int ret = NOTIFY_DONE;
23048
23049 - if (args->regs && user_mode_vm(args->regs))
23050 + if (args->regs && user_mode(args->regs))
23051 return ret;
23052
23053 switch (val) {
23054 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23055 index 76dc6f0..66bdfc3 100644
23056 --- a/arch/x86/kernel/kprobes/opt.c
23057 +++ b/arch/x86/kernel/kprobes/opt.c
23058 @@ -79,6 +79,7 @@ found:
23059 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23060 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23061 {
23062 + pax_open_kernel();
23063 #ifdef CONFIG_X86_64
23064 *addr++ = 0x48;
23065 *addr++ = 0xbf;
23066 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23067 *addr++ = 0xb8;
23068 #endif
23069 *(unsigned long *)addr = val;
23070 + pax_close_kernel();
23071 }
23072
23073 static void __used __kprobes kprobes_optinsn_template_holder(void)
23074 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23075 * Verify if the address gap is in 2GB range, because this uses
23076 * a relative jump.
23077 */
23078 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23079 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23080 if (abs(rel) > 0x7fffffff)
23081 return -ERANGE;
23082
23083 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23084 op->optinsn.size = ret;
23085
23086 /* Copy arch-dep-instance from template */
23087 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23088 + pax_open_kernel();
23089 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23090 + pax_close_kernel();
23091
23092 /* Set probe information */
23093 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23094
23095 /* Set probe function call */
23096 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23097 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23098
23099 /* Set returning jmp instruction at the tail of out-of-line buffer */
23100 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23101 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23102 (u8 *)op->kp.addr + op->optinsn.size);
23103
23104 flush_icache_range((unsigned long) buf,
23105 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
23106 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
23107
23108 /* Backup instructions which will be replaced by jump address */
23109 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23110 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23111 RELATIVE_ADDR_SIZE);
23112
23113 insn_buf[0] = RELATIVEJUMP_OPCODE;
23114 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23115 /* This kprobe is really able to run optimized path. */
23116 op = container_of(p, struct optimized_kprobe, kp);
23117 /* Detour through copied instructions */
23118 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23119 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23120 if (!reenter)
23121 reset_current_kprobe();
23122 preempt_enable_no_resched();
23123 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
23124 index cd6d9a5..16245a4 100644
23125 --- a/arch/x86/kernel/kvm.c
23126 +++ b/arch/x86/kernel/kvm.c
23127 @@ -455,7 +455,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
23128 return NOTIFY_OK;
23129 }
23130
23131 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
23132 +static struct notifier_block kvm_cpu_notifier = {
23133 .notifier_call = kvm_cpu_notify,
23134 };
23135 #endif
23136 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23137 index ebc9873..1b9724b 100644
23138 --- a/arch/x86/kernel/ldt.c
23139 +++ b/arch/x86/kernel/ldt.c
23140 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23141 if (reload) {
23142 #ifdef CONFIG_SMP
23143 preempt_disable();
23144 - load_LDT(pc);
23145 + load_LDT_nolock(pc);
23146 if (!cpumask_equal(mm_cpumask(current->mm),
23147 cpumask_of(smp_processor_id())))
23148 smp_call_function(flush_ldt, current->mm, 1);
23149 preempt_enable();
23150 #else
23151 - load_LDT(pc);
23152 + load_LDT_nolock(pc);
23153 #endif
23154 }
23155 if (oldsize) {
23156 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23157 return err;
23158
23159 for (i = 0; i < old->size; i++)
23160 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23161 + write_ldt_entry(new->ldt, i, old->ldt + i);
23162 return 0;
23163 }
23164
23165 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23166 retval = copy_ldt(&mm->context, &old_mm->context);
23167 mutex_unlock(&old_mm->context.lock);
23168 }
23169 +
23170 + if (tsk == current) {
23171 + mm->context.vdso = 0;
23172 +
23173 +#ifdef CONFIG_X86_32
23174 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23175 + mm->context.user_cs_base = 0UL;
23176 + mm->context.user_cs_limit = ~0UL;
23177 +
23178 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23179 + cpus_clear(mm->context.cpu_user_cs_mask);
23180 +#endif
23181 +
23182 +#endif
23183 +#endif
23184 +
23185 + }
23186 +
23187 return retval;
23188 }
23189
23190 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23191 }
23192 }
23193
23194 +#ifdef CONFIG_PAX_SEGMEXEC
23195 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23196 + error = -EINVAL;
23197 + goto out_unlock;
23198 + }
23199 +#endif
23200 +
23201 fill_ldt(&ldt, &ldt_info);
23202 if (oldmode)
23203 ldt.avl = 0;
23204 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
23205 index 5b19e4d..6476a76 100644
23206 --- a/arch/x86/kernel/machine_kexec_32.c
23207 +++ b/arch/x86/kernel/machine_kexec_32.c
23208 @@ -26,7 +26,7 @@
23209 #include <asm/cacheflush.h>
23210 #include <asm/debugreg.h>
23211
23212 -static void set_idt(void *newidt, __u16 limit)
23213 +static void set_idt(struct desc_struct *newidt, __u16 limit)
23214 {
23215 struct desc_ptr curidt;
23216
23217 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
23218 }
23219
23220
23221 -static void set_gdt(void *newgdt, __u16 limit)
23222 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
23223 {
23224 struct desc_ptr curgdt;
23225
23226 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
23227 }
23228
23229 control_page = page_address(image->control_code_page);
23230 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
23231 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
23232
23233 relocate_kernel_ptr = control_page;
23234 page_list[PA_CONTROL_PAGE] = __pa(control_page);
23235 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
23236 index 22db92b..d546bec 100644
23237 --- a/arch/x86/kernel/microcode_core.c
23238 +++ b/arch/x86/kernel/microcode_core.c
23239 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
23240 return NOTIFY_OK;
23241 }
23242
23243 -static struct notifier_block __refdata mc_cpu_notifier = {
23244 +static struct notifier_block mc_cpu_notifier = {
23245 .notifier_call = mc_cpu_callback,
23246 };
23247
23248 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
23249 index 5fb2ceb..3ae90bb 100644
23250 --- a/arch/x86/kernel/microcode_intel.c
23251 +++ b/arch/x86/kernel/microcode_intel.c
23252 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
23253
23254 static int get_ucode_user(void *to, const void *from, size_t n)
23255 {
23256 - return copy_from_user(to, from, n);
23257 + return copy_from_user(to, (const void __force_user *)from, n);
23258 }
23259
23260 static enum ucode_state
23261 request_microcode_user(int cpu, const void __user *buf, size_t size)
23262 {
23263 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
23264 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
23265 }
23266
23267 static void microcode_fini_cpu(int cpu)
23268 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
23269 index 216a4d7..228255a 100644
23270 --- a/arch/x86/kernel/module.c
23271 +++ b/arch/x86/kernel/module.c
23272 @@ -43,15 +43,60 @@ do { \
23273 } while (0)
23274 #endif
23275
23276 -void *module_alloc(unsigned long size)
23277 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
23278 {
23279 - if (PAGE_ALIGN(size) > MODULES_LEN)
23280 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
23281 return NULL;
23282 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
23283 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
23284 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
23285 -1, __builtin_return_address(0));
23286 }
23287
23288 +void *module_alloc(unsigned long size)
23289 +{
23290 +
23291 +#ifdef CONFIG_PAX_KERNEXEC
23292 + return __module_alloc(size, PAGE_KERNEL);
23293 +#else
23294 + return __module_alloc(size, PAGE_KERNEL_EXEC);
23295 +#endif
23296 +
23297 +}
23298 +
23299 +#ifdef CONFIG_PAX_KERNEXEC
23300 +#ifdef CONFIG_X86_32
23301 +void *module_alloc_exec(unsigned long size)
23302 +{
23303 + struct vm_struct *area;
23304 +
23305 + if (size == 0)
23306 + return NULL;
23307 +
23308 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
23309 + return area ? area->addr : NULL;
23310 +}
23311 +EXPORT_SYMBOL(module_alloc_exec);
23312 +
23313 +void module_free_exec(struct module *mod, void *module_region)
23314 +{
23315 + vunmap(module_region);
23316 +}
23317 +EXPORT_SYMBOL(module_free_exec);
23318 +#else
23319 +void module_free_exec(struct module *mod, void *module_region)
23320 +{
23321 + module_free(mod, module_region);
23322 +}
23323 +EXPORT_SYMBOL(module_free_exec);
23324 +
23325 +void *module_alloc_exec(unsigned long size)
23326 +{
23327 + return __module_alloc(size, PAGE_KERNEL_RX);
23328 +}
23329 +EXPORT_SYMBOL(module_alloc_exec);
23330 +#endif
23331 +#endif
23332 +
23333 #ifdef CONFIG_X86_32
23334 int apply_relocate(Elf32_Shdr *sechdrs,
23335 const char *strtab,
23336 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
23337 unsigned int i;
23338 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
23339 Elf32_Sym *sym;
23340 - uint32_t *location;
23341 + uint32_t *plocation, location;
23342
23343 DEBUGP("Applying relocate section %u to %u\n",
23344 relsec, sechdrs[relsec].sh_info);
23345 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
23346 /* This is where to make the change */
23347 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
23348 - + rel[i].r_offset;
23349 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
23350 + location = (uint32_t)plocation;
23351 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
23352 + plocation = ktla_ktva((void *)plocation);
23353 /* This is the symbol it is referring to. Note that all
23354 undefined symbols have been resolved. */
23355 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
23356 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
23357 switch (ELF32_R_TYPE(rel[i].r_info)) {
23358 case R_386_32:
23359 /* We add the value into the location given */
23360 - *location += sym->st_value;
23361 + pax_open_kernel();
23362 + *plocation += sym->st_value;
23363 + pax_close_kernel();
23364 break;
23365 case R_386_PC32:
23366 /* Add the value, subtract its position */
23367 - *location += sym->st_value - (uint32_t)location;
23368 + pax_open_kernel();
23369 + *plocation += sym->st_value - location;
23370 + pax_close_kernel();
23371 break;
23372 default:
23373 pr_err("%s: Unknown relocation: %u\n",
23374 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
23375 case R_X86_64_NONE:
23376 break;
23377 case R_X86_64_64:
23378 + pax_open_kernel();
23379 *(u64 *)loc = val;
23380 + pax_close_kernel();
23381 break;
23382 case R_X86_64_32:
23383 + pax_open_kernel();
23384 *(u32 *)loc = val;
23385 + pax_close_kernel();
23386 if (val != *(u32 *)loc)
23387 goto overflow;
23388 break;
23389 case R_X86_64_32S:
23390 + pax_open_kernel();
23391 *(s32 *)loc = val;
23392 + pax_close_kernel();
23393 if ((s64)val != *(s32 *)loc)
23394 goto overflow;
23395 break;
23396 case R_X86_64_PC32:
23397 val -= (u64)loc;
23398 + pax_open_kernel();
23399 *(u32 *)loc = val;
23400 + pax_close_kernel();
23401 +
23402 #if 0
23403 if ((s64)val != *(s32 *)loc)
23404 goto overflow;
23405 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
23406 index ce13049..e2e9c3c 100644
23407 --- a/arch/x86/kernel/msr.c
23408 +++ b/arch/x86/kernel/msr.c
23409 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
23410 return notifier_from_errno(err);
23411 }
23412
23413 -static struct notifier_block __refdata msr_class_cpu_notifier = {
23414 +static struct notifier_block msr_class_cpu_notifier = {
23415 .notifier_call = msr_class_cpu_callback,
23416 };
23417
23418 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
23419 index 6030805..2d33f21 100644
23420 --- a/arch/x86/kernel/nmi.c
23421 +++ b/arch/x86/kernel/nmi.c
23422 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
23423 return handled;
23424 }
23425
23426 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
23427 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
23428 {
23429 struct nmi_desc *desc = nmi_to_desc(type);
23430 unsigned long flags;
23431 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
23432 * event confuses some handlers (kdump uses this flag)
23433 */
23434 if (action->flags & NMI_FLAG_FIRST)
23435 - list_add_rcu(&action->list, &desc->head);
23436 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
23437 else
23438 - list_add_tail_rcu(&action->list, &desc->head);
23439 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
23440
23441 spin_unlock_irqrestore(&desc->lock, flags);
23442 return 0;
23443 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
23444 if (!strcmp(n->name, name)) {
23445 WARN(in_nmi(),
23446 "Trying to free NMI (%s) from NMI context!\n", n->name);
23447 - list_del_rcu(&n->list);
23448 + pax_list_del_rcu((struct list_head *)&n->list);
23449 break;
23450 }
23451 }
23452 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
23453 dotraplinkage notrace __kprobes void
23454 do_nmi(struct pt_regs *regs, long error_code)
23455 {
23456 +
23457 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23458 + if (!user_mode(regs)) {
23459 + unsigned long cs = regs->cs & 0xFFFF;
23460 + unsigned long ip = ktva_ktla(regs->ip);
23461 +
23462 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
23463 + regs->ip = ip;
23464 + }
23465 +#endif
23466 +
23467 nmi_nesting_preprocess(regs);
23468
23469 nmi_enter();
23470 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
23471 index 6d9582e..f746287 100644
23472 --- a/arch/x86/kernel/nmi_selftest.c
23473 +++ b/arch/x86/kernel/nmi_selftest.c
23474 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
23475 {
23476 /* trap all the unknown NMIs we may generate */
23477 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
23478 - __initdata);
23479 + __initconst);
23480 }
23481
23482 static void __init cleanup_nmi_testsuite(void)
23483 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
23484 unsigned long timeout;
23485
23486 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
23487 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
23488 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
23489 nmi_fail = FAILURE;
23490 return;
23491 }
23492 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
23493 index 676b8c7..870ba04 100644
23494 --- a/arch/x86/kernel/paravirt-spinlocks.c
23495 +++ b/arch/x86/kernel/paravirt-spinlocks.c
23496 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
23497 arch_spin_lock(lock);
23498 }
23499
23500 -struct pv_lock_ops pv_lock_ops = {
23501 +struct pv_lock_ops pv_lock_ops __read_only = {
23502 #ifdef CONFIG_SMP
23503 .spin_is_locked = __ticket_spin_is_locked,
23504 .spin_is_contended = __ticket_spin_is_contended,
23505 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
23506 index cd6de64..27c6af0 100644
23507 --- a/arch/x86/kernel/paravirt.c
23508 +++ b/arch/x86/kernel/paravirt.c
23509 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
23510 {
23511 return x;
23512 }
23513 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
23514 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
23515 +#endif
23516
23517 void __init default_banner(void)
23518 {
23519 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
23520 if (opfunc == NULL)
23521 /* If there's no function, patch it with a ud2a (BUG) */
23522 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
23523 - else if (opfunc == _paravirt_nop)
23524 + else if (opfunc == (void *)_paravirt_nop)
23525 /* If the operation is a nop, then nop the callsite */
23526 ret = paravirt_patch_nop();
23527
23528 /* identity functions just return their single argument */
23529 - else if (opfunc == _paravirt_ident_32)
23530 + else if (opfunc == (void *)_paravirt_ident_32)
23531 ret = paravirt_patch_ident_32(insnbuf, len);
23532 - else if (opfunc == _paravirt_ident_64)
23533 + else if (opfunc == (void *)_paravirt_ident_64)
23534 ret = paravirt_patch_ident_64(insnbuf, len);
23535 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
23536 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
23537 + ret = paravirt_patch_ident_64(insnbuf, len);
23538 +#endif
23539
23540 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
23541 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
23542 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
23543 if (insn_len > len || start == NULL)
23544 insn_len = len;
23545 else
23546 - memcpy(insnbuf, start, insn_len);
23547 + memcpy(insnbuf, ktla_ktva(start), insn_len);
23548
23549 return insn_len;
23550 }
23551 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
23552 return this_cpu_read(paravirt_lazy_mode);
23553 }
23554
23555 -struct pv_info pv_info = {
23556 +struct pv_info pv_info __read_only = {
23557 .name = "bare hardware",
23558 .paravirt_enabled = 0,
23559 .kernel_rpl = 0,
23560 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
23561 #endif
23562 };
23563
23564 -struct pv_init_ops pv_init_ops = {
23565 +struct pv_init_ops pv_init_ops __read_only = {
23566 .patch = native_patch,
23567 };
23568
23569 -struct pv_time_ops pv_time_ops = {
23570 +struct pv_time_ops pv_time_ops __read_only = {
23571 .sched_clock = native_sched_clock,
23572 .steal_clock = native_steal_clock,
23573 };
23574
23575 -struct pv_irq_ops pv_irq_ops = {
23576 +struct pv_irq_ops pv_irq_ops __read_only = {
23577 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
23578 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
23579 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
23580 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
23581 #endif
23582 };
23583
23584 -struct pv_cpu_ops pv_cpu_ops = {
23585 +struct pv_cpu_ops pv_cpu_ops __read_only = {
23586 .cpuid = native_cpuid,
23587 .get_debugreg = native_get_debugreg,
23588 .set_debugreg = native_set_debugreg,
23589 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
23590 .end_context_switch = paravirt_nop,
23591 };
23592
23593 -struct pv_apic_ops pv_apic_ops = {
23594 +struct pv_apic_ops pv_apic_ops __read_only= {
23595 #ifdef CONFIG_X86_LOCAL_APIC
23596 .startup_ipi_hook = paravirt_nop,
23597 #endif
23598 };
23599
23600 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
23601 +#ifdef CONFIG_X86_32
23602 +#ifdef CONFIG_X86_PAE
23603 +/* 64-bit pagetable entries */
23604 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
23605 +#else
23606 /* 32-bit pagetable entries */
23607 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
23608 +#endif
23609 #else
23610 /* 64-bit pagetable entries */
23611 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
23612 #endif
23613
23614 -struct pv_mmu_ops pv_mmu_ops = {
23615 +struct pv_mmu_ops pv_mmu_ops __read_only = {
23616
23617 .read_cr2 = native_read_cr2,
23618 .write_cr2 = native_write_cr2,
23619 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
23620 .make_pud = PTE_IDENT,
23621
23622 .set_pgd = native_set_pgd,
23623 + .set_pgd_batched = native_set_pgd_batched,
23624 #endif
23625 #endif /* PAGETABLE_LEVELS >= 3 */
23626
23627 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
23628 },
23629
23630 .set_fixmap = native_set_fixmap,
23631 +
23632 +#ifdef CONFIG_PAX_KERNEXEC
23633 + .pax_open_kernel = native_pax_open_kernel,
23634 + .pax_close_kernel = native_pax_close_kernel,
23635 +#endif
23636 +
23637 };
23638
23639 EXPORT_SYMBOL_GPL(pv_time_ops);
23640 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
23641 index 299d493..2ccb0ee 100644
23642 --- a/arch/x86/kernel/pci-calgary_64.c
23643 +++ b/arch/x86/kernel/pci-calgary_64.c
23644 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
23645 tce_space = be64_to_cpu(readq(target));
23646 tce_space = tce_space & TAR_SW_BITS;
23647
23648 - tce_space = tce_space & (~specified_table_size);
23649 + tce_space = tce_space & (~(unsigned long)specified_table_size);
23650 info->tce_space = (u64 *)__va(tce_space);
23651 }
23652 }
23653 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
23654 index 35ccf75..7a15747 100644
23655 --- a/arch/x86/kernel/pci-iommu_table.c
23656 +++ b/arch/x86/kernel/pci-iommu_table.c
23657 @@ -2,7 +2,7 @@
23658 #include <asm/iommu_table.h>
23659 #include <linux/string.h>
23660 #include <linux/kallsyms.h>
23661 -
23662 +#include <linux/sched.h>
23663
23664 #define DEBUG 1
23665
23666 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
23667 index 6c483ba..d10ce2f 100644
23668 --- a/arch/x86/kernel/pci-swiotlb.c
23669 +++ b/arch/x86/kernel/pci-swiotlb.c
23670 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
23671 void *vaddr, dma_addr_t dma_addr,
23672 struct dma_attrs *attrs)
23673 {
23674 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
23675 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
23676 }
23677
23678 static struct dma_map_ops swiotlb_dma_ops = {
23679 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
23680 index 81a5f5e..20f8b58 100644
23681 --- a/arch/x86/kernel/process.c
23682 +++ b/arch/x86/kernel/process.c
23683 @@ -36,7 +36,8 @@
23684 * section. Since TSS's are completely CPU-local, we want them
23685 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
23686 */
23687 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
23688 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
23689 +EXPORT_SYMBOL(init_tss);
23690
23691 #ifdef CONFIG_X86_64
23692 static DEFINE_PER_CPU(unsigned char, is_idle);
23693 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
23694 task_xstate_cachep =
23695 kmem_cache_create("task_xstate", xstate_size,
23696 __alignof__(union thread_xstate),
23697 - SLAB_PANIC | SLAB_NOTRACK, NULL);
23698 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
23699 }
23700
23701 /*
23702 @@ -105,7 +106,7 @@ void exit_thread(void)
23703 unsigned long *bp = t->io_bitmap_ptr;
23704
23705 if (bp) {
23706 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
23707 + struct tss_struct *tss = init_tss + get_cpu();
23708
23709 t->io_bitmap_ptr = NULL;
23710 clear_thread_flag(TIF_IO_BITMAP);
23711 @@ -125,6 +126,9 @@ void flush_thread(void)
23712 {
23713 struct task_struct *tsk = current;
23714
23715 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
23716 + loadsegment(gs, 0);
23717 +#endif
23718 flush_ptrace_hw_breakpoint(tsk);
23719 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
23720 drop_init_fpu(tsk);
23721 @@ -271,7 +275,7 @@ static void __exit_idle(void)
23722 void exit_idle(void)
23723 {
23724 /* idle loop has pid 0 */
23725 - if (current->pid)
23726 + if (task_pid_nr(current))
23727 return;
23728 __exit_idle();
23729 }
23730 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
23731 return ret;
23732 }
23733 #endif
23734 -void stop_this_cpu(void *dummy)
23735 +__noreturn void stop_this_cpu(void *dummy)
23736 {
23737 local_irq_disable();
23738 /*
23739 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
23740 }
23741 early_param("idle", idle_setup);
23742
23743 -unsigned long arch_align_stack(unsigned long sp)
23744 +#ifdef CONFIG_PAX_RANDKSTACK
23745 +void pax_randomize_kstack(struct pt_regs *regs)
23746 {
23747 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
23748 - sp -= get_random_int() % 8192;
23749 - return sp & ~0xf;
23750 -}
23751 + struct thread_struct *thread = &current->thread;
23752 + unsigned long time;
23753
23754 -unsigned long arch_randomize_brk(struct mm_struct *mm)
23755 -{
23756 - unsigned long range_end = mm->brk + 0x02000000;
23757 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
23758 -}
23759 + if (!randomize_va_space)
23760 + return;
23761 +
23762 + if (v8086_mode(regs))
23763 + return;
23764
23765 + rdtscl(time);
23766 +
23767 + /* P4 seems to return a 0 LSB, ignore it */
23768 +#ifdef CONFIG_MPENTIUM4
23769 + time &= 0x3EUL;
23770 + time <<= 2;
23771 +#elif defined(CONFIG_X86_64)
23772 + time &= 0xFUL;
23773 + time <<= 4;
23774 +#else
23775 + time &= 0x1FUL;
23776 + time <<= 3;
23777 +#endif
23778 +
23779 + thread->sp0 ^= time;
23780 + load_sp0(init_tss + smp_processor_id(), thread);
23781 +
23782 +#ifdef CONFIG_X86_64
23783 + this_cpu_write(kernel_stack, thread->sp0);
23784 +#endif
23785 +}
23786 +#endif
23787 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
23788 index 7305f7d..22f73d6 100644
23789 --- a/arch/x86/kernel/process_32.c
23790 +++ b/arch/x86/kernel/process_32.c
23791 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
23792 unsigned long thread_saved_pc(struct task_struct *tsk)
23793 {
23794 return ((unsigned long *)tsk->thread.sp)[3];
23795 +//XXX return tsk->thread.eip;
23796 }
23797
23798 void __show_regs(struct pt_regs *regs, int all)
23799 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
23800 unsigned long sp;
23801 unsigned short ss, gs;
23802
23803 - if (user_mode_vm(regs)) {
23804 + if (user_mode(regs)) {
23805 sp = regs->sp;
23806 ss = regs->ss & 0xffff;
23807 - gs = get_user_gs(regs);
23808 } else {
23809 sp = kernel_stack_pointer(regs);
23810 savesegment(ss, ss);
23811 - savesegment(gs, gs);
23812 }
23813 + gs = get_user_gs(regs);
23814
23815 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
23816 (u16)regs->cs, regs->ip, regs->flags,
23817 - smp_processor_id());
23818 + raw_smp_processor_id());
23819 print_symbol("EIP is at %s\n", regs->ip);
23820
23821 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
23822 @@ -128,20 +128,21 @@ void release_thread(struct task_struct *dead_task)
23823 int copy_thread(unsigned long clone_flags, unsigned long sp,
23824 unsigned long arg, struct task_struct *p)
23825 {
23826 - struct pt_regs *childregs = task_pt_regs(p);
23827 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
23828 struct task_struct *tsk;
23829 int err;
23830
23831 p->thread.sp = (unsigned long) childregs;
23832 p->thread.sp0 = (unsigned long) (childregs+1);
23833 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
23834
23835 if (unlikely(p->flags & PF_KTHREAD)) {
23836 /* kernel thread */
23837 memset(childregs, 0, sizeof(struct pt_regs));
23838 p->thread.ip = (unsigned long) ret_from_kernel_thread;
23839 - task_user_gs(p) = __KERNEL_STACK_CANARY;
23840 - childregs->ds = __USER_DS;
23841 - childregs->es = __USER_DS;
23842 + savesegment(gs, childregs->gs);
23843 + childregs->ds = __KERNEL_DS;
23844 + childregs->es = __KERNEL_DS;
23845 childregs->fs = __KERNEL_PERCPU;
23846 childregs->bx = sp; /* function */
23847 childregs->bp = arg;
23848 @@ -248,7 +249,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23849 struct thread_struct *prev = &prev_p->thread,
23850 *next = &next_p->thread;
23851 int cpu = smp_processor_id();
23852 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
23853 + struct tss_struct *tss = init_tss + cpu;
23854 fpu_switch_t fpu;
23855
23856 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
23857 @@ -272,6 +273,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23858 */
23859 lazy_save_gs(prev->gs);
23860
23861 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23862 + __set_fs(task_thread_info(next_p)->addr_limit);
23863 +#endif
23864 +
23865 /*
23866 * Load the per-thread Thread-Local Storage descriptor.
23867 */
23868 @@ -302,6 +307,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23869 */
23870 arch_end_context_switch(next_p);
23871
23872 + this_cpu_write(current_task, next_p);
23873 + this_cpu_write(current_tinfo, &next_p->tinfo);
23874 +
23875 /*
23876 * Restore %gs if needed (which is common)
23877 */
23878 @@ -310,8 +318,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23879
23880 switch_fpu_finish(next_p, fpu);
23881
23882 - this_cpu_write(current_task, next_p);
23883 -
23884 return prev_p;
23885 }
23886
23887 @@ -341,4 +347,3 @@ unsigned long get_wchan(struct task_struct *p)
23888 } while (count++ < 16);
23889 return 0;
23890 }
23891 -
23892 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
23893 index 355ae06..560fbbe 100644
23894 --- a/arch/x86/kernel/process_64.c
23895 +++ b/arch/x86/kernel/process_64.c
23896 @@ -151,10 +151,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
23897 struct pt_regs *childregs;
23898 struct task_struct *me = current;
23899
23900 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
23901 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
23902 childregs = task_pt_regs(p);
23903 p->thread.sp = (unsigned long) childregs;
23904 p->thread.usersp = me->thread.usersp;
23905 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
23906 set_tsk_thread_flag(p, TIF_FORK);
23907 p->fpu_counter = 0;
23908 p->thread.io_bitmap_ptr = NULL;
23909 @@ -165,6 +166,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
23910 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
23911 savesegment(es, p->thread.es);
23912 savesegment(ds, p->thread.ds);
23913 + savesegment(ss, p->thread.ss);
23914 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
23915 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
23916
23917 if (unlikely(p->flags & PF_KTHREAD)) {
23918 @@ -273,7 +276,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23919 struct thread_struct *prev = &prev_p->thread;
23920 struct thread_struct *next = &next_p->thread;
23921 int cpu = smp_processor_id();
23922 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
23923 + struct tss_struct *tss = init_tss + cpu;
23924 unsigned fsindex, gsindex;
23925 fpu_switch_t fpu;
23926
23927 @@ -296,6 +299,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23928 if (unlikely(next->ds | prev->ds))
23929 loadsegment(ds, next->ds);
23930
23931 + savesegment(ss, prev->ss);
23932 + if (unlikely(next->ss != prev->ss))
23933 + loadsegment(ss, next->ss);
23934
23935 /* We must save %fs and %gs before load_TLS() because
23936 * %fs and %gs may be cleared by load_TLS().
23937 @@ -355,10 +361,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23938 prev->usersp = this_cpu_read(old_rsp);
23939 this_cpu_write(old_rsp, next->usersp);
23940 this_cpu_write(current_task, next_p);
23941 + this_cpu_write(current_tinfo, &next_p->tinfo);
23942
23943 - this_cpu_write(kernel_stack,
23944 - (unsigned long)task_stack_page(next_p) +
23945 - THREAD_SIZE - KERNEL_STACK_OFFSET);
23946 + this_cpu_write(kernel_stack, next->sp0);
23947
23948 /*
23949 * Now maybe reload the debug registers and handle I/O bitmaps
23950 @@ -427,12 +432,11 @@ unsigned long get_wchan(struct task_struct *p)
23951 if (!p || p == current || p->state == TASK_RUNNING)
23952 return 0;
23953 stack = (unsigned long)task_stack_page(p);
23954 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
23955 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
23956 return 0;
23957 fp = *(u64 *)(p->thread.sp);
23958 do {
23959 - if (fp < (unsigned long)stack ||
23960 - fp >= (unsigned long)stack+THREAD_SIZE)
23961 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
23962 return 0;
23963 ip = *(u64 *)(fp+8);
23964 if (!in_sched_functions(ip))
23965 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
23966 index 29a8120..a50b5ee 100644
23967 --- a/arch/x86/kernel/ptrace.c
23968 +++ b/arch/x86/kernel/ptrace.c
23969 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
23970 {
23971 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
23972 unsigned long sp = (unsigned long)&regs->sp;
23973 - struct thread_info *tinfo;
23974
23975 - if (context == (sp & ~(THREAD_SIZE - 1)))
23976 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
23977 return sp;
23978
23979 - tinfo = (struct thread_info *)context;
23980 - if (tinfo->previous_esp)
23981 - return tinfo->previous_esp;
23982 + sp = *(unsigned long *)context;
23983 + if (sp)
23984 + return sp;
23985
23986 return (unsigned long)regs;
23987 }
23988 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
23989 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
23990 {
23991 int i;
23992 - int dr7 = 0;
23993 + unsigned long dr7 = 0;
23994 struct arch_hw_breakpoint *info;
23995
23996 for (i = 0; i < HBP_NUM; i++) {
23997 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
23998 unsigned long addr, unsigned long data)
23999 {
24000 int ret;
24001 - unsigned long __user *datap = (unsigned long __user *)data;
24002 + unsigned long __user *datap = (__force unsigned long __user *)data;
24003
24004 switch (request) {
24005 /* read the word at location addr in the USER area. */
24006 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
24007 if ((int) addr < 0)
24008 return -EIO;
24009 ret = do_get_thread_area(child, addr,
24010 - (struct user_desc __user *)data);
24011 + (__force struct user_desc __user *) data);
24012 break;
24013
24014 case PTRACE_SET_THREAD_AREA:
24015 if ((int) addr < 0)
24016 return -EIO;
24017 ret = do_set_thread_area(child, addr,
24018 - (struct user_desc __user *)data, 0);
24019 + (__force struct user_desc __user *) data, 0);
24020 break;
24021 #endif
24022
24023 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24024
24025 #ifdef CONFIG_X86_64
24026
24027 -static struct user_regset x86_64_regsets[] __read_mostly = {
24028 +static user_regset_no_const x86_64_regsets[] __read_only = {
24029 [REGSET_GENERAL] = {
24030 .core_note_type = NT_PRSTATUS,
24031 .n = sizeof(struct user_regs_struct) / sizeof(long),
24032 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
24033 #endif /* CONFIG_X86_64 */
24034
24035 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24036 -static struct user_regset x86_32_regsets[] __read_mostly = {
24037 +static user_regset_no_const x86_32_regsets[] __read_only = {
24038 [REGSET_GENERAL] = {
24039 .core_note_type = NT_PRSTATUS,
24040 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24041 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
24042 */
24043 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24044
24045 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24046 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24047 {
24048 #ifdef CONFIG_X86_64
24049 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24050 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24051 memset(info, 0, sizeof(*info));
24052 info->si_signo = SIGTRAP;
24053 info->si_code = si_code;
24054 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24055 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24056 }
24057
24058 void user_single_step_siginfo(struct task_struct *tsk,
24059 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24060 # define IS_IA32 0
24061 #endif
24062
24063 +#ifdef CONFIG_GRKERNSEC_SETXID
24064 +extern void gr_delayed_cred_worker(void);
24065 +#endif
24066 +
24067 /*
24068 * We must return the syscall number to actually look up in the table.
24069 * This can be -1L to skip running any syscall at all.
24070 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24071
24072 user_exit();
24073
24074 +#ifdef CONFIG_GRKERNSEC_SETXID
24075 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24076 + gr_delayed_cred_worker();
24077 +#endif
24078 +
24079 /*
24080 * If we stepped into a sysenter/syscall insn, it trapped in
24081 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24082 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24083 */
24084 user_exit();
24085
24086 +#ifdef CONFIG_GRKERNSEC_SETXID
24087 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24088 + gr_delayed_cred_worker();
24089 +#endif
24090 +
24091 audit_syscall_exit(regs);
24092
24093 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24094 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24095 index 2cb9470..ff1fd80 100644
24096 --- a/arch/x86/kernel/pvclock.c
24097 +++ b/arch/x86/kernel/pvclock.c
24098 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24099 return pv_tsc_khz;
24100 }
24101
24102 -static atomic64_t last_value = ATOMIC64_INIT(0);
24103 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24104
24105 void pvclock_resume(void)
24106 {
24107 - atomic64_set(&last_value, 0);
24108 + atomic64_set_unchecked(&last_value, 0);
24109 }
24110
24111 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24112 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24113 * updating at the same time, and one of them could be slightly behind,
24114 * making the assumption that last_value always go forward fail to hold.
24115 */
24116 - last = atomic64_read(&last_value);
24117 + last = atomic64_read_unchecked(&last_value);
24118 do {
24119 if (ret < last)
24120 return last;
24121 - last = atomic64_cmpxchg(&last_value, last, ret);
24122 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24123 } while (unlikely(last != ret));
24124
24125 return ret;
24126 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24127 index 76fa1e9..abf09ea 100644
24128 --- a/arch/x86/kernel/reboot.c
24129 +++ b/arch/x86/kernel/reboot.c
24130 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
24131 EXPORT_SYMBOL(pm_power_off);
24132
24133 static const struct desc_ptr no_idt = {};
24134 -static int reboot_mode;
24135 +static unsigned short reboot_mode;
24136 enum reboot_type reboot_type = BOOT_ACPI;
24137 int reboot_force;
24138
24139 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24140
24141 void __noreturn machine_real_restart(unsigned int type)
24142 {
24143 +
24144 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24145 + struct desc_struct *gdt;
24146 +#endif
24147 +
24148 local_irq_disable();
24149
24150 /*
24151 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
24152
24153 /* Jump to the identity-mapped low memory code */
24154 #ifdef CONFIG_X86_32
24155 - asm volatile("jmpl *%0" : :
24156 +
24157 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24158 + gdt = get_cpu_gdt_table(smp_processor_id());
24159 + pax_open_kernel();
24160 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24161 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24162 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24163 + loadsegment(ds, __KERNEL_DS);
24164 + loadsegment(es, __KERNEL_DS);
24165 + loadsegment(ss, __KERNEL_DS);
24166 +#endif
24167 +#ifdef CONFIG_PAX_KERNEXEC
24168 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24169 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24170 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24171 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24172 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24173 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24174 +#endif
24175 + pax_close_kernel();
24176 +#endif
24177 +
24178 + asm volatile("ljmpl *%0" : :
24179 "rm" (real_mode_header->machine_real_restart_asm),
24180 "a" (type));
24181 #else
24182 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24183 * try to force a triple fault and then cycle between hitting the keyboard
24184 * controller and doing that
24185 */
24186 -static void native_machine_emergency_restart(void)
24187 +static void __noreturn native_machine_emergency_restart(void)
24188 {
24189 int i;
24190 int attempt = 0;
24191 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
24192 #endif
24193 }
24194
24195 -static void __machine_emergency_restart(int emergency)
24196 +static void __noreturn __machine_emergency_restart(int emergency)
24197 {
24198 reboot_emergency = emergency;
24199 machine_ops.emergency_restart();
24200 }
24201
24202 -static void native_machine_restart(char *__unused)
24203 +static void __noreturn native_machine_restart(char *__unused)
24204 {
24205 pr_notice("machine restart\n");
24206
24207 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
24208 __machine_emergency_restart(0);
24209 }
24210
24211 -static void native_machine_halt(void)
24212 +static void __noreturn native_machine_halt(void)
24213 {
24214 /* Stop other cpus and apics */
24215 machine_shutdown();
24216 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
24217 stop_this_cpu(NULL);
24218 }
24219
24220 -static void native_machine_power_off(void)
24221 +static void __noreturn native_machine_power_off(void)
24222 {
24223 if (pm_power_off) {
24224 if (!reboot_force)
24225 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
24226 }
24227 /* A fallback in case there is no PM info available */
24228 tboot_shutdown(TB_SHUTDOWN_HALT);
24229 + unreachable();
24230 }
24231
24232 -struct machine_ops machine_ops = {
24233 +struct machine_ops machine_ops __read_only = {
24234 .power_off = native_machine_power_off,
24235 .shutdown = native_machine_shutdown,
24236 .emergency_restart = native_machine_emergency_restart,
24237 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
24238 index c8e41e9..64049ef 100644
24239 --- a/arch/x86/kernel/reboot_fixups_32.c
24240 +++ b/arch/x86/kernel/reboot_fixups_32.c
24241 @@ -57,7 +57,7 @@ struct device_fixup {
24242 unsigned int vendor;
24243 unsigned int device;
24244 void (*reboot_fixup)(struct pci_dev *);
24245 -};
24246 +} __do_const;
24247
24248 /*
24249 * PCI ids solely used for fixups_table go here
24250 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
24251 index f2bb9c9..bed145d7 100644
24252 --- a/arch/x86/kernel/relocate_kernel_64.S
24253 +++ b/arch/x86/kernel/relocate_kernel_64.S
24254 @@ -11,6 +11,7 @@
24255 #include <asm/kexec.h>
24256 #include <asm/processor-flags.h>
24257 #include <asm/pgtable_types.h>
24258 +#include <asm/alternative-asm.h>
24259
24260 /*
24261 * Must be relocatable PIC code callable as a C function
24262 @@ -167,6 +168,7 @@ identity_mapped:
24263 xorq %r14, %r14
24264 xorq %r15, %r15
24265
24266 + pax_force_retaddr 0, 1
24267 ret
24268
24269 1:
24270 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
24271 index 56f7fcf..3b88ad1 100644
24272 --- a/arch/x86/kernel/setup.c
24273 +++ b/arch/x86/kernel/setup.c
24274 @@ -110,6 +110,7 @@
24275 #include <asm/mce.h>
24276 #include <asm/alternative.h>
24277 #include <asm/prom.h>
24278 +#include <asm/boot.h>
24279
24280 /*
24281 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
24282 @@ -205,10 +206,12 @@ EXPORT_SYMBOL(boot_cpu_data);
24283 #endif
24284
24285
24286 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
24287 -unsigned long mmu_cr4_features;
24288 +#ifdef CONFIG_X86_64
24289 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
24290 +#elif defined(CONFIG_X86_PAE)
24291 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
24292 #else
24293 -unsigned long mmu_cr4_features = X86_CR4_PAE;
24294 +unsigned long mmu_cr4_features __read_only;
24295 #endif
24296
24297 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
24298 @@ -444,7 +447,7 @@ static void __init parse_setup_data(void)
24299
24300 switch (data->type) {
24301 case SETUP_E820_EXT:
24302 - parse_e820_ext(data);
24303 + parse_e820_ext((struct setup_data __force_kernel *)data);
24304 break;
24305 case SETUP_DTB:
24306 add_dtb(pa_data);
24307 @@ -771,7 +774,7 @@ static void __init trim_bios_range(void)
24308 * area (640->1Mb) as ram even though it is not.
24309 * take them out.
24310 */
24311 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
24312 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
24313
24314 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
24315 }
24316 @@ -779,7 +782,7 @@ static void __init trim_bios_range(void)
24317 /* called before trim_bios_range() to spare extra sanitize */
24318 static void __init e820_add_kernel_range(void)
24319 {
24320 - u64 start = __pa_symbol(_text);
24321 + u64 start = __pa_symbol(ktla_ktva(_text));
24322 u64 size = __pa_symbol(_end) - start;
24323
24324 /*
24325 @@ -841,8 +844,12 @@ static void __init trim_low_memory_range(void)
24326
24327 void __init setup_arch(char **cmdline_p)
24328 {
24329 +#ifdef CONFIG_X86_32
24330 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
24331 +#else
24332 memblock_reserve(__pa_symbol(_text),
24333 (unsigned long)__bss_stop - (unsigned long)_text);
24334 +#endif
24335
24336 early_reserve_initrd();
24337
24338 @@ -934,14 +941,14 @@ void __init setup_arch(char **cmdline_p)
24339
24340 if (!boot_params.hdr.root_flags)
24341 root_mountflags &= ~MS_RDONLY;
24342 - init_mm.start_code = (unsigned long) _text;
24343 - init_mm.end_code = (unsigned long) _etext;
24344 + init_mm.start_code = ktla_ktva((unsigned long) _text);
24345 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
24346 init_mm.end_data = (unsigned long) _edata;
24347 init_mm.brk = _brk_end;
24348
24349 - code_resource.start = __pa_symbol(_text);
24350 - code_resource.end = __pa_symbol(_etext)-1;
24351 - data_resource.start = __pa_symbol(_etext);
24352 + code_resource.start = __pa_symbol(ktla_ktva(_text));
24353 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
24354 + data_resource.start = __pa_symbol(_sdata);
24355 data_resource.end = __pa_symbol(_edata)-1;
24356 bss_resource.start = __pa_symbol(__bss_start);
24357 bss_resource.end = __pa_symbol(__bss_stop)-1;
24358 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
24359 index 5cdff03..80fa283 100644
24360 --- a/arch/x86/kernel/setup_percpu.c
24361 +++ b/arch/x86/kernel/setup_percpu.c
24362 @@ -21,19 +21,17 @@
24363 #include <asm/cpu.h>
24364 #include <asm/stackprotector.h>
24365
24366 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
24367 +#ifdef CONFIG_SMP
24368 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
24369 EXPORT_PER_CPU_SYMBOL(cpu_number);
24370 +#endif
24371
24372 -#ifdef CONFIG_X86_64
24373 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
24374 -#else
24375 -#define BOOT_PERCPU_OFFSET 0
24376 -#endif
24377
24378 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
24379 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
24380
24381 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
24382 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
24383 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
24384 };
24385 EXPORT_SYMBOL(__per_cpu_offset);
24386 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
24387 {
24388 #ifdef CONFIG_NEED_MULTIPLE_NODES
24389 pg_data_t *last = NULL;
24390 - unsigned int cpu;
24391 + int cpu;
24392
24393 for_each_possible_cpu(cpu) {
24394 int node = early_cpu_to_node(cpu);
24395 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
24396 {
24397 #ifdef CONFIG_X86_32
24398 struct desc_struct gdt;
24399 + unsigned long base = per_cpu_offset(cpu);
24400
24401 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
24402 - 0x2 | DESCTYPE_S, 0x8);
24403 - gdt.s = 1;
24404 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
24405 + 0x83 | DESCTYPE_S, 0xC);
24406 write_gdt_entry(get_cpu_gdt_table(cpu),
24407 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
24408 #endif
24409 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
24410 /* alrighty, percpu areas up and running */
24411 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
24412 for_each_possible_cpu(cpu) {
24413 +#ifdef CONFIG_CC_STACKPROTECTOR
24414 +#ifdef CONFIG_X86_32
24415 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
24416 +#endif
24417 +#endif
24418 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
24419 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
24420 per_cpu(cpu_number, cpu) = cpu;
24421 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
24422 */
24423 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
24424 #endif
24425 +#ifdef CONFIG_CC_STACKPROTECTOR
24426 +#ifdef CONFIG_X86_32
24427 + if (!cpu)
24428 + per_cpu(stack_canary.canary, cpu) = canary;
24429 +#endif
24430 +#endif
24431 /*
24432 * Up to this point, the boot CPU has been using .init.data
24433 * area. Reload any changed state for the boot CPU.
24434 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
24435 index 6956299..18126ec4 100644
24436 --- a/arch/x86/kernel/signal.c
24437 +++ b/arch/x86/kernel/signal.c
24438 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
24439 * Align the stack pointer according to the i386 ABI,
24440 * i.e. so that on function entry ((sp + 4) & 15) == 0.
24441 */
24442 - sp = ((sp + 4) & -16ul) - 4;
24443 + sp = ((sp - 12) & -16ul) - 4;
24444 #else /* !CONFIG_X86_32 */
24445 sp = round_down(sp, 16) - 8;
24446 #endif
24447 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
24448 }
24449
24450 if (current->mm->context.vdso)
24451 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
24452 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
24453 else
24454 - restorer = &frame->retcode;
24455 + restorer = (void __user *)&frame->retcode;
24456 if (ksig->ka.sa.sa_flags & SA_RESTORER)
24457 restorer = ksig->ka.sa.sa_restorer;
24458
24459 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
24460 * reasons and because gdb uses it as a signature to notice
24461 * signal handler stack frames.
24462 */
24463 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
24464 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
24465
24466 if (err)
24467 return -EFAULT;
24468 @@ -364,10 +364,13 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
24469 else
24470 put_user_ex(0, &frame->uc.uc_flags);
24471 put_user_ex(0, &frame->uc.uc_link);
24472 - err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
24473 + __save_altstack_ex(&frame->uc.uc_stack, regs->sp);
24474
24475 /* Set up to return from userspace. */
24476 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
24477 + if (current->mm->context.vdso)
24478 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
24479 + else
24480 + restorer = (void __user *)&frame->retcode;
24481 if (ksig->ka.sa.sa_flags & SA_RESTORER)
24482 restorer = ksig->ka.sa.sa_restorer;
24483 put_user_ex(restorer, &frame->pretcode);
24484 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
24485 * reasons and because gdb uses it as a signature to notice
24486 * signal handler stack frames.
24487 */
24488 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
24489 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
24490 } put_user_catch(err);
24491
24492 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
24493 @@ -429,7 +432,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
24494 else
24495 put_user_ex(0, &frame->uc.uc_flags);
24496 put_user_ex(0, &frame->uc.uc_link);
24497 - err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
24498 + __save_altstack_ex(&frame->uc.uc_stack, regs->sp);
24499
24500 /* Set up to return from userspace. If provided, use a stub
24501 already in userspace. */
24502 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
24503 {
24504 int usig = signr_convert(ksig->sig);
24505 sigset_t *set = sigmask_to_save();
24506 - compat_sigset_t *cset = (compat_sigset_t *) set;
24507 + sigset_t sigcopy;
24508 + compat_sigset_t *cset;
24509 +
24510 + sigcopy = *set;
24511 +
24512 + cset = (compat_sigset_t *) &sigcopy;
24513
24514 /* Set up the stack frame */
24515 if (is_ia32_frame()) {
24516 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
24517 } else if (is_x32_frame()) {
24518 return x32_setup_rt_frame(ksig, cset, regs);
24519 } else {
24520 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
24521 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
24522 }
24523 }
24524
24525 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
24526 index 48d2b7d..90d328a 100644
24527 --- a/arch/x86/kernel/smp.c
24528 +++ b/arch/x86/kernel/smp.c
24529 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
24530
24531 __setup("nonmi_ipi", nonmi_ipi_setup);
24532
24533 -struct smp_ops smp_ops = {
24534 +struct smp_ops smp_ops __read_only = {
24535 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
24536 .smp_prepare_cpus = native_smp_prepare_cpus,
24537 .smp_cpus_done = native_smp_cpus_done,
24538 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
24539 index bfd348e..f0c1bf2 100644
24540 --- a/arch/x86/kernel/smpboot.c
24541 +++ b/arch/x86/kernel/smpboot.c
24542 @@ -251,14 +251,18 @@ notrace static void __cpuinit start_secondary(void *unused)
24543
24544 enable_start_cpu0 = 0;
24545
24546 -#ifdef CONFIG_X86_32
24547 - /* switch away from the initial page table */
24548 - load_cr3(swapper_pg_dir);
24549 - __flush_tlb_all();
24550 -#endif
24551 -
24552 /* otherwise gcc will move up smp_processor_id before the cpu_init */
24553 barrier();
24554 +
24555 + /* switch away from the initial page table */
24556 +#ifdef CONFIG_PAX_PER_CPU_PGD
24557 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
24558 + __flush_tlb_all();
24559 +#elif defined(CONFIG_X86_32)
24560 + load_cr3(swapper_pg_dir);
24561 + __flush_tlb_all();
24562 +#endif
24563 +
24564 /*
24565 * Check TSC synchronization with the BP:
24566 */
24567 @@ -748,6 +752,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
24568 idle->thread.sp = (unsigned long) (((struct pt_regs *)
24569 (THREAD_SIZE + task_stack_page(idle))) - 1);
24570 per_cpu(current_task, cpu) = idle;
24571 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
24572
24573 #ifdef CONFIG_X86_32
24574 /* Stack for startup_32 can be just as for start_secondary onwards */
24575 @@ -755,11 +760,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
24576 #else
24577 clear_tsk_thread_flag(idle, TIF_FORK);
24578 initial_gs = per_cpu_offset(cpu);
24579 - per_cpu(kernel_stack, cpu) =
24580 - (unsigned long)task_stack_page(idle) -
24581 - KERNEL_STACK_OFFSET + THREAD_SIZE;
24582 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
24583 #endif
24584 +
24585 + pax_open_kernel();
24586 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
24587 + pax_close_kernel();
24588 +
24589 initial_code = (unsigned long)start_secondary;
24590 stack_start = idle->thread.sp;
24591
24592 @@ -908,6 +915,18 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
24593 /* the FPU context is blank, nobody can own it */
24594 __cpu_disable_lazy_restore(cpu);
24595
24596 +#ifdef CONFIG_PAX_PER_CPU_PGD
24597 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
24598 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
24599 + KERNEL_PGD_PTRS);
24600 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
24601 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
24602 + KERNEL_PGD_PTRS);
24603 +#endif
24604 +
24605 + /* the FPU context is blank, nobody can own it */
24606 + __cpu_disable_lazy_restore(cpu);
24607 +
24608 err = do_boot_cpu(apicid, cpu, tidle);
24609 if (err) {
24610 pr_debug("do_boot_cpu failed %d\n", err);
24611 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
24612 index 9b4d51d..5d28b58 100644
24613 --- a/arch/x86/kernel/step.c
24614 +++ b/arch/x86/kernel/step.c
24615 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
24616 struct desc_struct *desc;
24617 unsigned long base;
24618
24619 - seg &= ~7UL;
24620 + seg >>= 3;
24621
24622 mutex_lock(&child->mm->context.lock);
24623 - if (unlikely((seg >> 3) >= child->mm->context.size))
24624 + if (unlikely(seg >= child->mm->context.size))
24625 addr = -1L; /* bogus selector, access would fault */
24626 else {
24627 desc = child->mm->context.ldt + seg;
24628 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
24629 addr += base;
24630 }
24631 mutex_unlock(&child->mm->context.lock);
24632 - }
24633 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
24634 + addr = ktla_ktva(addr);
24635
24636 return addr;
24637 }
24638 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
24639 unsigned char opcode[15];
24640 unsigned long addr = convert_ip_to_linear(child, regs);
24641
24642 + if (addr == -EINVAL)
24643 + return 0;
24644 +
24645 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
24646 for (i = 0; i < copied; i++) {
24647 switch (opcode[i]) {
24648 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
24649 new file mode 100644
24650 index 0000000..5877189
24651 --- /dev/null
24652 +++ b/arch/x86/kernel/sys_i386_32.c
24653 @@ -0,0 +1,189 @@
24654 +/*
24655 + * This file contains various random system calls that
24656 + * have a non-standard calling sequence on the Linux/i386
24657 + * platform.
24658 + */
24659 +
24660 +#include <linux/errno.h>
24661 +#include <linux/sched.h>
24662 +#include <linux/mm.h>
24663 +#include <linux/fs.h>
24664 +#include <linux/smp.h>
24665 +#include <linux/sem.h>
24666 +#include <linux/msg.h>
24667 +#include <linux/shm.h>
24668 +#include <linux/stat.h>
24669 +#include <linux/syscalls.h>
24670 +#include <linux/mman.h>
24671 +#include <linux/file.h>
24672 +#include <linux/utsname.h>
24673 +#include <linux/ipc.h>
24674 +#include <linux/elf.h>
24675 +
24676 +#include <linux/uaccess.h>
24677 +#include <linux/unistd.h>
24678 +
24679 +#include <asm/syscalls.h>
24680 +
24681 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
24682 +{
24683 + unsigned long pax_task_size = TASK_SIZE;
24684 +
24685 +#ifdef CONFIG_PAX_SEGMEXEC
24686 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
24687 + pax_task_size = SEGMEXEC_TASK_SIZE;
24688 +#endif
24689 +
24690 + if (flags & MAP_FIXED)
24691 + if (len > pax_task_size || addr > pax_task_size - len)
24692 + return -EINVAL;
24693 +
24694 + return 0;
24695 +}
24696 +
24697 +/*
24698 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
24699 + */
24700 +static unsigned long get_align_mask(void)
24701 +{
24702 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
24703 + return 0;
24704 +
24705 + if (!(current->flags & PF_RANDOMIZE))
24706 + return 0;
24707 +
24708 + return va_align.mask;
24709 +}
24710 +
24711 +unsigned long
24712 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
24713 + unsigned long len, unsigned long pgoff, unsigned long flags)
24714 +{
24715 + struct mm_struct *mm = current->mm;
24716 + struct vm_area_struct *vma;
24717 + unsigned long pax_task_size = TASK_SIZE;
24718 + struct vm_unmapped_area_info info;
24719 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
24720 +
24721 +#ifdef CONFIG_PAX_SEGMEXEC
24722 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
24723 + pax_task_size = SEGMEXEC_TASK_SIZE;
24724 +#endif
24725 +
24726 + pax_task_size -= PAGE_SIZE;
24727 +
24728 + if (len > pax_task_size)
24729 + return -ENOMEM;
24730 +
24731 + if (flags & MAP_FIXED)
24732 + return addr;
24733 +
24734 +#ifdef CONFIG_PAX_RANDMMAP
24735 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
24736 +#endif
24737 +
24738 + if (addr) {
24739 + addr = PAGE_ALIGN(addr);
24740 + if (pax_task_size - len >= addr) {
24741 + vma = find_vma(mm, addr);
24742 + if (check_heap_stack_gap(vma, addr, len, offset))
24743 + return addr;
24744 + }
24745 + }
24746 +
24747 + info.flags = 0;
24748 + info.length = len;
24749 + info.align_mask = filp ? get_align_mask() : 0;
24750 + info.align_offset = pgoff << PAGE_SHIFT;
24751 + info.threadstack_offset = offset;
24752 +
24753 +#ifdef CONFIG_PAX_PAGEEXEC
24754 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
24755 + info.low_limit = 0x00110000UL;
24756 + info.high_limit = mm->start_code;
24757 +
24758 +#ifdef CONFIG_PAX_RANDMMAP
24759 + if (mm->pax_flags & MF_PAX_RANDMMAP)
24760 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
24761 +#endif
24762 +
24763 + if (info.low_limit < info.high_limit) {
24764 + addr = vm_unmapped_area(&info);
24765 + if (!IS_ERR_VALUE(addr))
24766 + return addr;
24767 + }
24768 + } else
24769 +#endif
24770 +
24771 + info.low_limit = mm->mmap_base;
24772 + info.high_limit = pax_task_size;
24773 +
24774 + return vm_unmapped_area(&info);
24775 +}
24776 +
24777 +unsigned long
24778 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
24779 + const unsigned long len, const unsigned long pgoff,
24780 + const unsigned long flags)
24781 +{
24782 + struct vm_area_struct *vma;
24783 + struct mm_struct *mm = current->mm;
24784 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
24785 + struct vm_unmapped_area_info info;
24786 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
24787 +
24788 +#ifdef CONFIG_PAX_SEGMEXEC
24789 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
24790 + pax_task_size = SEGMEXEC_TASK_SIZE;
24791 +#endif
24792 +
24793 + pax_task_size -= PAGE_SIZE;
24794 +
24795 + /* requested length too big for entire address space */
24796 + if (len > pax_task_size)
24797 + return -ENOMEM;
24798 +
24799 + if (flags & MAP_FIXED)
24800 + return addr;
24801 +
24802 +#ifdef CONFIG_PAX_PAGEEXEC
24803 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
24804 + goto bottomup;
24805 +#endif
24806 +
24807 +#ifdef CONFIG_PAX_RANDMMAP
24808 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
24809 +#endif
24810 +
24811 + /* requesting a specific address */
24812 + if (addr) {
24813 + addr = PAGE_ALIGN(addr);
24814 + if (pax_task_size - len >= addr) {
24815 + vma = find_vma(mm, addr);
24816 + if (check_heap_stack_gap(vma, addr, len, offset))
24817 + return addr;
24818 + }
24819 + }
24820 +
24821 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
24822 + info.length = len;
24823 + info.low_limit = PAGE_SIZE;
24824 + info.high_limit = mm->mmap_base;
24825 + info.align_mask = filp ? get_align_mask() : 0;
24826 + info.align_offset = pgoff << PAGE_SHIFT;
24827 + info.threadstack_offset = offset;
24828 +
24829 + addr = vm_unmapped_area(&info);
24830 + if (!(addr & ~PAGE_MASK))
24831 + return addr;
24832 + VM_BUG_ON(addr != -ENOMEM);
24833 +
24834 +bottomup:
24835 + /*
24836 + * A failed mmap() very likely causes application failure,
24837 + * so fall back to the bottom-up function here. This scenario
24838 + * can happen with large stack limits and large mmap()
24839 + * allocations.
24840 + */
24841 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
24842 +}
24843 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
24844 index dbded5a..ace2781 100644
24845 --- a/arch/x86/kernel/sys_x86_64.c
24846 +++ b/arch/x86/kernel/sys_x86_64.c
24847 @@ -81,8 +81,8 @@ out:
24848 return error;
24849 }
24850
24851 -static void find_start_end(unsigned long flags, unsigned long *begin,
24852 - unsigned long *end)
24853 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
24854 + unsigned long *begin, unsigned long *end)
24855 {
24856 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
24857 unsigned long new_begin;
24858 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
24859 *begin = new_begin;
24860 }
24861 } else {
24862 - *begin = TASK_UNMAPPED_BASE;
24863 + *begin = mm->mmap_base;
24864 *end = TASK_SIZE;
24865 }
24866 }
24867 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
24868 struct vm_area_struct *vma;
24869 struct vm_unmapped_area_info info;
24870 unsigned long begin, end;
24871 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
24872
24873 if (flags & MAP_FIXED)
24874 return addr;
24875
24876 - find_start_end(flags, &begin, &end);
24877 + find_start_end(mm, flags, &begin, &end);
24878
24879 if (len > end)
24880 return -ENOMEM;
24881
24882 +#ifdef CONFIG_PAX_RANDMMAP
24883 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
24884 +#endif
24885 +
24886 if (addr) {
24887 addr = PAGE_ALIGN(addr);
24888 vma = find_vma(mm, addr);
24889 - if (end - len >= addr &&
24890 - (!vma || addr + len <= vma->vm_start))
24891 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
24892 return addr;
24893 }
24894
24895 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
24896 info.high_limit = end;
24897 info.align_mask = filp ? get_align_mask() : 0;
24898 info.align_offset = pgoff << PAGE_SHIFT;
24899 + info.threadstack_offset = offset;
24900 return vm_unmapped_area(&info);
24901 }
24902
24903 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
24904 struct mm_struct *mm = current->mm;
24905 unsigned long addr = addr0;
24906 struct vm_unmapped_area_info info;
24907 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
24908
24909 /* requested length too big for entire address space */
24910 if (len > TASK_SIZE)
24911 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
24912 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
24913 goto bottomup;
24914
24915 +#ifdef CONFIG_PAX_RANDMMAP
24916 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
24917 +#endif
24918 +
24919 /* requesting a specific address */
24920 if (addr) {
24921 addr = PAGE_ALIGN(addr);
24922 vma = find_vma(mm, addr);
24923 - if (TASK_SIZE - len >= addr &&
24924 - (!vma || addr + len <= vma->vm_start))
24925 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
24926 return addr;
24927 }
24928
24929 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
24930 info.high_limit = mm->mmap_base;
24931 info.align_mask = filp ? get_align_mask() : 0;
24932 info.align_offset = pgoff << PAGE_SHIFT;
24933 + info.threadstack_offset = offset;
24934 addr = vm_unmapped_area(&info);
24935 if (!(addr & ~PAGE_MASK))
24936 return addr;
24937 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
24938 index f84fe00..f41d9f1 100644
24939 --- a/arch/x86/kernel/tboot.c
24940 +++ b/arch/x86/kernel/tboot.c
24941 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
24942
24943 void tboot_shutdown(u32 shutdown_type)
24944 {
24945 - void (*shutdown)(void);
24946 + void (* __noreturn shutdown)(void);
24947
24948 if (!tboot_enabled())
24949 return;
24950 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
24951
24952 switch_to_tboot_pt();
24953
24954 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
24955 + shutdown = (void *)tboot->shutdown_entry;
24956 shutdown();
24957
24958 /* should not reach here */
24959 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
24960 return 0;
24961 }
24962
24963 -static atomic_t ap_wfs_count;
24964 +static atomic_unchecked_t ap_wfs_count;
24965
24966 static int tboot_wait_for_aps(int num_aps)
24967 {
24968 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
24969 {
24970 switch (action) {
24971 case CPU_DYING:
24972 - atomic_inc(&ap_wfs_count);
24973 + atomic_inc_unchecked(&ap_wfs_count);
24974 if (num_online_cpus() == 1)
24975 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
24976 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
24977 return NOTIFY_BAD;
24978 break;
24979 }
24980 return NOTIFY_OK;
24981 }
24982
24983 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
24984 +static struct notifier_block tboot_cpu_notifier =
24985 {
24986 .notifier_call = tboot_cpu_callback,
24987 };
24988 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
24989
24990 tboot_create_trampoline();
24991
24992 - atomic_set(&ap_wfs_count, 0);
24993 + atomic_set_unchecked(&ap_wfs_count, 0);
24994 register_hotcpu_notifier(&tboot_cpu_notifier);
24995
24996 acpi_os_set_prepare_sleep(&tboot_sleep);
24997 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
24998 index 24d3c91..d06b473 100644
24999 --- a/arch/x86/kernel/time.c
25000 +++ b/arch/x86/kernel/time.c
25001 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25002 {
25003 unsigned long pc = instruction_pointer(regs);
25004
25005 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25006 + if (!user_mode(regs) && in_lock_functions(pc)) {
25007 #ifdef CONFIG_FRAME_POINTER
25008 - return *(unsigned long *)(regs->bp + sizeof(long));
25009 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25010 #else
25011 unsigned long *sp =
25012 (unsigned long *)kernel_stack_pointer(regs);
25013 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25014 * or above a saved flags. Eflags has bits 22-31 zero,
25015 * kernel addresses don't.
25016 */
25017 +
25018 +#ifdef CONFIG_PAX_KERNEXEC
25019 + return ktla_ktva(sp[0]);
25020 +#else
25021 if (sp[0] >> 22)
25022 return sp[0];
25023 if (sp[1] >> 22)
25024 return sp[1];
25025 #endif
25026 +
25027 +#endif
25028 }
25029 return pc;
25030 }
25031 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25032 index f7fec09..9991981 100644
25033 --- a/arch/x86/kernel/tls.c
25034 +++ b/arch/x86/kernel/tls.c
25035 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25036 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25037 return -EINVAL;
25038
25039 +#ifdef CONFIG_PAX_SEGMEXEC
25040 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25041 + return -EINVAL;
25042 +#endif
25043 +
25044 set_tls_desc(p, idx, &info, 1);
25045
25046 return 0;
25047 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25048
25049 if (kbuf)
25050 info = kbuf;
25051 - else if (__copy_from_user(infobuf, ubuf, count))
25052 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25053 return -EFAULT;
25054 else
25055 info = infobuf;
25056 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25057 index 772e2a8..bad5bf6 100644
25058 --- a/arch/x86/kernel/traps.c
25059 +++ b/arch/x86/kernel/traps.c
25060 @@ -68,12 +68,6 @@
25061 #include <asm/setup.h>
25062
25063 asmlinkage int system_call(void);
25064 -
25065 -/*
25066 - * The IDT has to be page-aligned to simplify the Pentium
25067 - * F0 0F bug workaround.
25068 - */
25069 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
25070 #endif
25071
25072 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25073 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25074 }
25075
25076 static int __kprobes
25077 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25078 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25079 struct pt_regs *regs, long error_code)
25080 {
25081 #ifdef CONFIG_X86_32
25082 - if (regs->flags & X86_VM_MASK) {
25083 + if (v8086_mode(regs)) {
25084 /*
25085 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25086 * On nmi (interrupt 2), do_trap should not be called.
25087 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25088 return -1;
25089 }
25090 #endif
25091 - if (!user_mode(regs)) {
25092 + if (!user_mode_novm(regs)) {
25093 if (!fixup_exception(regs)) {
25094 tsk->thread.error_code = error_code;
25095 tsk->thread.trap_nr = trapnr;
25096 +
25097 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25098 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25099 + str = "PAX: suspicious stack segment fault";
25100 +#endif
25101 +
25102 die(str, regs, error_code);
25103 }
25104 +
25105 +#ifdef CONFIG_PAX_REFCOUNT
25106 + if (trapnr == 4)
25107 + pax_report_refcount_overflow(regs);
25108 +#endif
25109 +
25110 return 0;
25111 }
25112
25113 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25114 }
25115
25116 static void __kprobes
25117 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25118 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25119 long error_code, siginfo_t *info)
25120 {
25121 struct task_struct *tsk = current;
25122 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25123 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25124 printk_ratelimit()) {
25125 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25126 - tsk->comm, tsk->pid, str,
25127 + tsk->comm, task_pid_nr(tsk), str,
25128 regs->ip, regs->sp, error_code);
25129 print_vma_addr(" in ", regs->ip);
25130 pr_cont("\n");
25131 @@ -273,7 +279,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25132 conditional_sti(regs);
25133
25134 #ifdef CONFIG_X86_32
25135 - if (regs->flags & X86_VM_MASK) {
25136 + if (v8086_mode(regs)) {
25137 local_irq_enable();
25138 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25139 goto exit;
25140 @@ -281,18 +287,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25141 #endif
25142
25143 tsk = current;
25144 - if (!user_mode(regs)) {
25145 + if (!user_mode_novm(regs)) {
25146 if (fixup_exception(regs))
25147 goto exit;
25148
25149 tsk->thread.error_code = error_code;
25150 tsk->thread.trap_nr = X86_TRAP_GP;
25151 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25152 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25153 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25154 +
25155 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25156 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25157 + die("PAX: suspicious general protection fault", regs, error_code);
25158 + else
25159 +#endif
25160 +
25161 die("general protection fault", regs, error_code);
25162 + }
25163 goto exit;
25164 }
25165
25166 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25167 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25168 + struct mm_struct *mm = tsk->mm;
25169 + unsigned long limit;
25170 +
25171 + down_write(&mm->mmap_sem);
25172 + limit = mm->context.user_cs_limit;
25173 + if (limit < TASK_SIZE) {
25174 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
25175 + up_write(&mm->mmap_sem);
25176 + return;
25177 + }
25178 + up_write(&mm->mmap_sem);
25179 + }
25180 +#endif
25181 +
25182 tsk->thread.error_code = error_code;
25183 tsk->thread.trap_nr = X86_TRAP_GP;
25184
25185 @@ -450,7 +480,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25186 /* It's safe to allow irq's after DR6 has been saved */
25187 preempt_conditional_sti(regs);
25188
25189 - if (regs->flags & X86_VM_MASK) {
25190 + if (v8086_mode(regs)) {
25191 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
25192 X86_TRAP_DB);
25193 preempt_conditional_cli(regs);
25194 @@ -465,7 +495,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25195 * We already checked v86 mode above, so we can check for kernel mode
25196 * by just checking the CPL of CS.
25197 */
25198 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
25199 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
25200 tsk->thread.debugreg6 &= ~DR_STEP;
25201 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
25202 regs->flags &= ~X86_EFLAGS_TF;
25203 @@ -497,7 +527,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
25204 return;
25205 conditional_sti(regs);
25206
25207 - if (!user_mode_vm(regs))
25208 + if (!user_mode(regs))
25209 {
25210 if (!fixup_exception(regs)) {
25211 task->thread.error_code = error_code;
25212 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
25213 index 2ed8459..7cf329f 100644
25214 --- a/arch/x86/kernel/uprobes.c
25215 +++ b/arch/x86/kernel/uprobes.c
25216 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
25217 int ret = NOTIFY_DONE;
25218
25219 /* We are only interested in userspace traps */
25220 - if (regs && !user_mode_vm(regs))
25221 + if (regs && !user_mode(regs))
25222 return NOTIFY_DONE;
25223
25224 switch (val) {
25225 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
25226
25227 if (ncopied != rasize) {
25228 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
25229 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
25230 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
25231
25232 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
25233 }
25234 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
25235 index b9242ba..50c5edd 100644
25236 --- a/arch/x86/kernel/verify_cpu.S
25237 +++ b/arch/x86/kernel/verify_cpu.S
25238 @@ -20,6 +20,7 @@
25239 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
25240 * arch/x86/kernel/trampoline_64.S: secondary processor verification
25241 * arch/x86/kernel/head_32.S: processor startup
25242 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
25243 *
25244 * verify_cpu, returns the status of longmode and SSE in register %eax.
25245 * 0: Success 1: Failure
25246 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
25247 index e8edcf5..27f9344 100644
25248 --- a/arch/x86/kernel/vm86_32.c
25249 +++ b/arch/x86/kernel/vm86_32.c
25250 @@ -44,6 +44,7 @@
25251 #include <linux/ptrace.h>
25252 #include <linux/audit.h>
25253 #include <linux/stddef.h>
25254 +#include <linux/grsecurity.h>
25255
25256 #include <asm/uaccess.h>
25257 #include <asm/io.h>
25258 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
25259 do_exit(SIGSEGV);
25260 }
25261
25262 - tss = &per_cpu(init_tss, get_cpu());
25263 + tss = init_tss + get_cpu();
25264 current->thread.sp0 = current->thread.saved_sp0;
25265 current->thread.sysenter_cs = __KERNEL_CS;
25266 load_sp0(tss, &current->thread);
25267 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
25268
25269 if (tsk->thread.saved_sp0)
25270 return -EPERM;
25271 +
25272 +#ifdef CONFIG_GRKERNSEC_VM86
25273 + if (!capable(CAP_SYS_RAWIO)) {
25274 + gr_handle_vm86();
25275 + return -EPERM;
25276 + }
25277 +#endif
25278 +
25279 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
25280 offsetof(struct kernel_vm86_struct, vm86plus) -
25281 sizeof(info.regs));
25282 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
25283 int tmp;
25284 struct vm86plus_struct __user *v86;
25285
25286 +#ifdef CONFIG_GRKERNSEC_VM86
25287 + if (!capable(CAP_SYS_RAWIO)) {
25288 + gr_handle_vm86();
25289 + return -EPERM;
25290 + }
25291 +#endif
25292 +
25293 tsk = current;
25294 switch (cmd) {
25295 case VM86_REQUEST_IRQ:
25296 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
25297 tsk->thread.saved_fs = info->regs32->fs;
25298 tsk->thread.saved_gs = get_user_gs(info->regs32);
25299
25300 - tss = &per_cpu(init_tss, get_cpu());
25301 + tss = init_tss + get_cpu();
25302 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
25303 if (cpu_has_sep)
25304 tsk->thread.sysenter_cs = 0;
25305 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
25306 goto cannot_handle;
25307 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
25308 goto cannot_handle;
25309 - intr_ptr = (unsigned long __user *) (i << 2);
25310 + intr_ptr = (__force unsigned long __user *) (i << 2);
25311 if (get_user(segoffs, intr_ptr))
25312 goto cannot_handle;
25313 if ((segoffs >> 16) == BIOSSEG)
25314 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
25315 index 10c4f30..57377c2 100644
25316 --- a/arch/x86/kernel/vmlinux.lds.S
25317 +++ b/arch/x86/kernel/vmlinux.lds.S
25318 @@ -26,6 +26,13 @@
25319 #include <asm/page_types.h>
25320 #include <asm/cache.h>
25321 #include <asm/boot.h>
25322 +#include <asm/segment.h>
25323 +
25324 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25325 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
25326 +#else
25327 +#define __KERNEL_TEXT_OFFSET 0
25328 +#endif
25329
25330 #undef i386 /* in case the preprocessor is a 32bit one */
25331
25332 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
25333
25334 PHDRS {
25335 text PT_LOAD FLAGS(5); /* R_E */
25336 +#ifdef CONFIG_X86_32
25337 + module PT_LOAD FLAGS(5); /* R_E */
25338 +#endif
25339 +#ifdef CONFIG_XEN
25340 + rodata PT_LOAD FLAGS(5); /* R_E */
25341 +#else
25342 + rodata PT_LOAD FLAGS(4); /* R__ */
25343 +#endif
25344 data PT_LOAD FLAGS(6); /* RW_ */
25345 -#ifdef CONFIG_X86_64
25346 + init.begin PT_LOAD FLAGS(6); /* RW_ */
25347 #ifdef CONFIG_SMP
25348 percpu PT_LOAD FLAGS(6); /* RW_ */
25349 #endif
25350 + text.init PT_LOAD FLAGS(5); /* R_E */
25351 + text.exit PT_LOAD FLAGS(5); /* R_E */
25352 init PT_LOAD FLAGS(7); /* RWE */
25353 -#endif
25354 note PT_NOTE FLAGS(0); /* ___ */
25355 }
25356
25357 SECTIONS
25358 {
25359 #ifdef CONFIG_X86_32
25360 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
25361 - phys_startup_32 = startup_32 - LOAD_OFFSET;
25362 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
25363 #else
25364 - . = __START_KERNEL;
25365 - phys_startup_64 = startup_64 - LOAD_OFFSET;
25366 + . = __START_KERNEL;
25367 #endif
25368
25369 /* Text and read-only data */
25370 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
25371 - _text = .;
25372 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
25373 /* bootstrapping code */
25374 +#ifdef CONFIG_X86_32
25375 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
25376 +#else
25377 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
25378 +#endif
25379 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
25380 + _text = .;
25381 HEAD_TEXT
25382 . = ALIGN(8);
25383 _stext = .;
25384 @@ -104,13 +124,48 @@ SECTIONS
25385 IRQENTRY_TEXT
25386 *(.fixup)
25387 *(.gnu.warning)
25388 - /* End of text section */
25389 - _etext = .;
25390 } :text = 0x9090
25391
25392 - NOTES :text :note
25393 + . += __KERNEL_TEXT_OFFSET;
25394
25395 - EXCEPTION_TABLE(16) :text = 0x9090
25396 +#ifdef CONFIG_X86_32
25397 + . = ALIGN(PAGE_SIZE);
25398 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
25399 +
25400 +#ifdef CONFIG_PAX_KERNEXEC
25401 + MODULES_EXEC_VADDR = .;
25402 + BYTE(0)
25403 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
25404 + . = ALIGN(HPAGE_SIZE) - 1;
25405 + MODULES_EXEC_END = .;
25406 +#endif
25407 +
25408 + } :module
25409 +#endif
25410 +
25411 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
25412 + /* End of text section */
25413 + BYTE(0)
25414 + _etext = . - __KERNEL_TEXT_OFFSET;
25415 + }
25416 +
25417 +#ifdef CONFIG_X86_32
25418 + . = ALIGN(PAGE_SIZE);
25419 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
25420 + *(.idt)
25421 + . = ALIGN(PAGE_SIZE);
25422 + *(.empty_zero_page)
25423 + *(.initial_pg_fixmap)
25424 + *(.initial_pg_pmd)
25425 + *(.initial_page_table)
25426 + *(.swapper_pg_dir)
25427 + } :rodata
25428 +#endif
25429 +
25430 + . = ALIGN(PAGE_SIZE);
25431 + NOTES :rodata :note
25432 +
25433 + EXCEPTION_TABLE(16) :rodata
25434
25435 #if defined(CONFIG_DEBUG_RODATA)
25436 /* .text should occupy whole number of pages */
25437 @@ -122,16 +177,20 @@ SECTIONS
25438
25439 /* Data */
25440 .data : AT(ADDR(.data) - LOAD_OFFSET) {
25441 +
25442 +#ifdef CONFIG_PAX_KERNEXEC
25443 + . = ALIGN(HPAGE_SIZE);
25444 +#else
25445 + . = ALIGN(PAGE_SIZE);
25446 +#endif
25447 +
25448 /* Start of data section */
25449 _sdata = .;
25450
25451 /* init_task */
25452 INIT_TASK_DATA(THREAD_SIZE)
25453
25454 -#ifdef CONFIG_X86_32
25455 - /* 32 bit has nosave before _edata */
25456 NOSAVE_DATA
25457 -#endif
25458
25459 PAGE_ALIGNED_DATA(PAGE_SIZE)
25460
25461 @@ -172,12 +231,19 @@ SECTIONS
25462 #endif /* CONFIG_X86_64 */
25463
25464 /* Init code and data - will be freed after init */
25465 - . = ALIGN(PAGE_SIZE);
25466 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
25467 + BYTE(0)
25468 +
25469 +#ifdef CONFIG_PAX_KERNEXEC
25470 + . = ALIGN(HPAGE_SIZE);
25471 +#else
25472 + . = ALIGN(PAGE_SIZE);
25473 +#endif
25474 +
25475 __init_begin = .; /* paired with __init_end */
25476 - }
25477 + } :init.begin
25478
25479 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
25480 +#ifdef CONFIG_SMP
25481 /*
25482 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
25483 * output PHDR, so the next output section - .init.text - should
25484 @@ -186,12 +252,27 @@ SECTIONS
25485 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
25486 #endif
25487
25488 - INIT_TEXT_SECTION(PAGE_SIZE)
25489 -#ifdef CONFIG_X86_64
25490 - :init
25491 -#endif
25492 + . = ALIGN(PAGE_SIZE);
25493 + init_begin = .;
25494 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
25495 + VMLINUX_SYMBOL(_sinittext) = .;
25496 + INIT_TEXT
25497 + VMLINUX_SYMBOL(_einittext) = .;
25498 + . = ALIGN(PAGE_SIZE);
25499 + } :text.init
25500
25501 - INIT_DATA_SECTION(16)
25502 + /*
25503 + * .exit.text is discard at runtime, not link time, to deal with
25504 + * references from .altinstructions and .eh_frame
25505 + */
25506 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
25507 + EXIT_TEXT
25508 + . = ALIGN(16);
25509 + } :text.exit
25510 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
25511 +
25512 + . = ALIGN(PAGE_SIZE);
25513 + INIT_DATA_SECTION(16) :init
25514
25515 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
25516 __x86_cpu_dev_start = .;
25517 @@ -253,19 +334,12 @@ SECTIONS
25518 }
25519
25520 . = ALIGN(8);
25521 - /*
25522 - * .exit.text is discard at runtime, not link time, to deal with
25523 - * references from .altinstructions and .eh_frame
25524 - */
25525 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
25526 - EXIT_TEXT
25527 - }
25528
25529 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
25530 EXIT_DATA
25531 }
25532
25533 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
25534 +#ifndef CONFIG_SMP
25535 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
25536 #endif
25537
25538 @@ -284,16 +358,10 @@ SECTIONS
25539 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
25540 __smp_locks = .;
25541 *(.smp_locks)
25542 - . = ALIGN(PAGE_SIZE);
25543 __smp_locks_end = .;
25544 + . = ALIGN(PAGE_SIZE);
25545 }
25546
25547 -#ifdef CONFIG_X86_64
25548 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
25549 - NOSAVE_DATA
25550 - }
25551 -#endif
25552 -
25553 /* BSS */
25554 . = ALIGN(PAGE_SIZE);
25555 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
25556 @@ -309,6 +377,7 @@ SECTIONS
25557 __brk_base = .;
25558 . += 64 * 1024; /* 64k alignment slop space */
25559 *(.brk_reservation) /* areas brk users have reserved */
25560 + . = ALIGN(HPAGE_SIZE);
25561 __brk_limit = .;
25562 }
25563
25564 @@ -335,13 +404,12 @@ SECTIONS
25565 * for the boot processor.
25566 */
25567 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
25568 -INIT_PER_CPU(gdt_page);
25569 INIT_PER_CPU(irq_stack_union);
25570
25571 /*
25572 * Build-time check on the image size:
25573 */
25574 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
25575 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
25576 "kernel image bigger than KERNEL_IMAGE_SIZE");
25577
25578 #ifdef CONFIG_SMP
25579 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
25580 index 9a907a6..f83f921 100644
25581 --- a/arch/x86/kernel/vsyscall_64.c
25582 +++ b/arch/x86/kernel/vsyscall_64.c
25583 @@ -56,15 +56,13 @@
25584 DEFINE_VVAR(int, vgetcpu_mode);
25585 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
25586
25587 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
25588 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
25589
25590 static int __init vsyscall_setup(char *str)
25591 {
25592 if (str) {
25593 if (!strcmp("emulate", str))
25594 vsyscall_mode = EMULATE;
25595 - else if (!strcmp("native", str))
25596 - vsyscall_mode = NATIVE;
25597 else if (!strcmp("none", str))
25598 vsyscall_mode = NONE;
25599 else
25600 @@ -323,8 +321,7 @@ do_ret:
25601 return true;
25602
25603 sigsegv:
25604 - force_sig(SIGSEGV, current);
25605 - return true;
25606 + do_group_exit(SIGKILL);
25607 }
25608
25609 /*
25610 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
25611 extern char __vvar_page;
25612 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
25613
25614 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
25615 - vsyscall_mode == NATIVE
25616 - ? PAGE_KERNEL_VSYSCALL
25617 - : PAGE_KERNEL_VVAR);
25618 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
25619 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
25620 (unsigned long)VSYSCALL_START);
25621
25622 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
25623 index b014d94..6d6ca7b 100644
25624 --- a/arch/x86/kernel/x8664_ksyms_64.c
25625 +++ b/arch/x86/kernel/x8664_ksyms_64.c
25626 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
25627 EXPORT_SYMBOL(copy_user_generic_unrolled);
25628 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
25629 EXPORT_SYMBOL(__copy_user_nocache);
25630 -EXPORT_SYMBOL(_copy_from_user);
25631 -EXPORT_SYMBOL(_copy_to_user);
25632
25633 EXPORT_SYMBOL(copy_page);
25634 EXPORT_SYMBOL(clear_page);
25635 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
25636 index 45a14db..075bb9b 100644
25637 --- a/arch/x86/kernel/x86_init.c
25638 +++ b/arch/x86/kernel/x86_init.c
25639 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
25640 },
25641 };
25642
25643 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
25644 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
25645 .early_percpu_clock_init = x86_init_noop,
25646 .setup_percpu_clockev = setup_secondary_APIC_clock,
25647 };
25648 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
25649 static void default_nmi_init(void) { };
25650 static int default_i8042_detect(void) { return 1; };
25651
25652 -struct x86_platform_ops x86_platform = {
25653 +struct x86_platform_ops x86_platform __read_only = {
25654 .calibrate_tsc = native_calibrate_tsc,
25655 .get_wallclock = mach_get_cmos_time,
25656 .set_wallclock = mach_set_rtc_mmss,
25657 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
25658 };
25659
25660 EXPORT_SYMBOL_GPL(x86_platform);
25661 -struct x86_msi_ops x86_msi = {
25662 +struct x86_msi_ops x86_msi __read_only = {
25663 .setup_msi_irqs = native_setup_msi_irqs,
25664 .compose_msi_msg = native_compose_msi_msg,
25665 .teardown_msi_irq = native_teardown_msi_irq,
25666 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
25667 .setup_hpet_msi = default_setup_hpet_msi,
25668 };
25669
25670 -struct x86_io_apic_ops x86_io_apic_ops = {
25671 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
25672 .init = native_io_apic_init_mappings,
25673 .read = native_io_apic_read,
25674 .write = native_io_apic_write,
25675 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
25676 index ada87a3..afea76d 100644
25677 --- a/arch/x86/kernel/xsave.c
25678 +++ b/arch/x86/kernel/xsave.c
25679 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
25680 {
25681 int err;
25682
25683 + buf = (struct xsave_struct __user *)____m(buf);
25684 if (use_xsave())
25685 err = xsave_user(buf);
25686 else if (use_fxsr())
25687 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
25688 */
25689 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
25690 {
25691 + buf = (void __user *)____m(buf);
25692 if (use_xsave()) {
25693 if ((unsigned long)buf % 64 || fx_only) {
25694 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
25695 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
25696 index a20ecb5..d0e2194 100644
25697 --- a/arch/x86/kvm/cpuid.c
25698 +++ b/arch/x86/kvm/cpuid.c
25699 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
25700 struct kvm_cpuid2 *cpuid,
25701 struct kvm_cpuid_entry2 __user *entries)
25702 {
25703 - int r;
25704 + int r, i;
25705
25706 r = -E2BIG;
25707 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
25708 goto out;
25709 r = -EFAULT;
25710 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
25711 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
25712 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
25713 goto out;
25714 + for (i = 0; i < cpuid->nent; ++i) {
25715 + struct kvm_cpuid_entry2 cpuid_entry;
25716 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
25717 + goto out;
25718 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
25719 + }
25720 vcpu->arch.cpuid_nent = cpuid->nent;
25721 kvm_apic_set_version(vcpu);
25722 kvm_x86_ops->cpuid_update(vcpu);
25723 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
25724 struct kvm_cpuid2 *cpuid,
25725 struct kvm_cpuid_entry2 __user *entries)
25726 {
25727 - int r;
25728 + int r, i;
25729
25730 r = -E2BIG;
25731 if (cpuid->nent < vcpu->arch.cpuid_nent)
25732 goto out;
25733 r = -EFAULT;
25734 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
25735 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
25736 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
25737 goto out;
25738 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
25739 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
25740 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
25741 + goto out;
25742 + }
25743 return 0;
25744
25745 out:
25746 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
25747 index 5953dce..f11a7d2 100644
25748 --- a/arch/x86/kvm/emulate.c
25749 +++ b/arch/x86/kvm/emulate.c
25750 @@ -329,6 +329,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
25751
25752 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
25753 do { \
25754 + unsigned long _tmp; \
25755 __asm__ __volatile__ ( \
25756 _PRE_EFLAGS("0", "4", "2") \
25757 _op _suffix " %"_x"3,%1; " \
25758 @@ -343,8 +344,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
25759 /* Raw emulation: instruction has two explicit operands. */
25760 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
25761 do { \
25762 - unsigned long _tmp; \
25763 - \
25764 switch ((ctxt)->dst.bytes) { \
25765 case 2: \
25766 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
25767 @@ -360,7 +359,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
25768
25769 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
25770 do { \
25771 - unsigned long _tmp; \
25772 switch ((ctxt)->dst.bytes) { \
25773 case 1: \
25774 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
25775 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
25776 index 0eee2c8..94a32c3 100644
25777 --- a/arch/x86/kvm/lapic.c
25778 +++ b/arch/x86/kvm/lapic.c
25779 @@ -55,7 +55,7 @@
25780 #define APIC_BUS_CYCLE_NS 1
25781
25782 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
25783 -#define apic_debug(fmt, arg...)
25784 +#define apic_debug(fmt, arg...) do {} while (0)
25785
25786 #define APIC_LVT_NUM 6
25787 /* 14 is the version for Xeon and Pentium 8.4.8*/
25788 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
25789 index da20860..d19fdf5 100644
25790 --- a/arch/x86/kvm/paging_tmpl.h
25791 +++ b/arch/x86/kvm/paging_tmpl.h
25792 @@ -208,7 +208,7 @@ retry_walk:
25793 if (unlikely(kvm_is_error_hva(host_addr)))
25794 goto error;
25795
25796 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
25797 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
25798 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
25799 goto error;
25800 walker->ptep_user[walker->level - 1] = ptep_user;
25801 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
25802 index a14a6ea..dc86cf0 100644
25803 --- a/arch/x86/kvm/svm.c
25804 +++ b/arch/x86/kvm/svm.c
25805 @@ -3493,7 +3493,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
25806 int cpu = raw_smp_processor_id();
25807
25808 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
25809 +
25810 + pax_open_kernel();
25811 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
25812 + pax_close_kernel();
25813 +
25814 load_TR_desc();
25815 }
25816
25817 @@ -3894,6 +3898,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
25818 #endif
25819 #endif
25820
25821 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25822 + __set_fs(current_thread_info()->addr_limit);
25823 +#endif
25824 +
25825 reload_tss(vcpu);
25826
25827 local_irq_disable();
25828 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
25829 index 5402c94..c3bdeee 100644
25830 --- a/arch/x86/kvm/vmx.c
25831 +++ b/arch/x86/kvm/vmx.c
25832 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
25833 #endif
25834 }
25835
25836 -static void vmcs_clear_bits(unsigned long field, u32 mask)
25837 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
25838 {
25839 vmcs_writel(field, vmcs_readl(field) & ~mask);
25840 }
25841
25842 -static void vmcs_set_bits(unsigned long field, u32 mask)
25843 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
25844 {
25845 vmcs_writel(field, vmcs_readl(field) | mask);
25846 }
25847 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
25848 struct desc_struct *descs;
25849
25850 descs = (void *)gdt->address;
25851 +
25852 + pax_open_kernel();
25853 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
25854 + pax_close_kernel();
25855 +
25856 load_TR_desc();
25857 }
25858
25859 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
25860 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
25861 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
25862
25863 +#ifdef CONFIG_PAX_PER_CPU_PGD
25864 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
25865 +#endif
25866 +
25867 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
25868 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
25869 vmx->loaded_vmcs->cpu = cpu;
25870 @@ -2935,8 +2943,11 @@ static __init int hardware_setup(void)
25871 if (!cpu_has_vmx_flexpriority())
25872 flexpriority_enabled = 0;
25873
25874 - if (!cpu_has_vmx_tpr_shadow())
25875 - kvm_x86_ops->update_cr8_intercept = NULL;
25876 + if (!cpu_has_vmx_tpr_shadow()) {
25877 + pax_open_kernel();
25878 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
25879 + pax_close_kernel();
25880 + }
25881
25882 if (enable_ept && !cpu_has_vmx_ept_2m_page())
25883 kvm_disable_largepages();
25884 @@ -2947,13 +2958,15 @@ static __init int hardware_setup(void)
25885 if (!cpu_has_vmx_apicv())
25886 enable_apicv = 0;
25887
25888 + pax_open_kernel();
25889 if (enable_apicv)
25890 - kvm_x86_ops->update_cr8_intercept = NULL;
25891 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
25892 else {
25893 - kvm_x86_ops->hwapic_irr_update = NULL;
25894 - kvm_x86_ops->deliver_posted_interrupt = NULL;
25895 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
25896 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
25897 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
25898 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
25899 }
25900 + pax_close_kernel();
25901
25902 if (nested)
25903 nested_vmx_setup_ctls_msrs();
25904 @@ -4076,7 +4089,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
25905
25906 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
25907 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
25908 +
25909 +#ifndef CONFIG_PAX_PER_CPU_PGD
25910 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
25911 +#endif
25912
25913 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
25914 #ifdef CONFIG_X86_64
25915 @@ -4098,7 +4114,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
25916 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
25917 vmx->host_idt_base = dt.address;
25918
25919 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
25920 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
25921
25922 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
25923 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
25924 @@ -7030,6 +7046,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25925 "jmp 2f \n\t"
25926 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
25927 "2: "
25928 +
25929 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25930 + "ljmp %[cs],$3f\n\t"
25931 + "3: "
25932 +#endif
25933 +
25934 /* Save guest registers, load host registers, keep flags */
25935 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
25936 "pop %0 \n\t"
25937 @@ -7082,6 +7104,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25938 #endif
25939 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
25940 [wordsize]"i"(sizeof(ulong))
25941 +
25942 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25943 + ,[cs]"i"(__KERNEL_CS)
25944 +#endif
25945 +
25946 : "cc", "memory"
25947 #ifdef CONFIG_X86_64
25948 , "rax", "rbx", "rdi", "rsi"
25949 @@ -7095,7 +7122,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25950 if (debugctlmsr)
25951 update_debugctlmsr(debugctlmsr);
25952
25953 -#ifndef CONFIG_X86_64
25954 +#ifdef CONFIG_X86_32
25955 /*
25956 * The sysexit path does not restore ds/es, so we must set them to
25957 * a reasonable value ourselves.
25958 @@ -7104,8 +7131,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25959 * may be executed in interrupt context, which saves and restore segments
25960 * around it, nullifying its effect.
25961 */
25962 - loadsegment(ds, __USER_DS);
25963 - loadsegment(es, __USER_DS);
25964 + loadsegment(ds, __KERNEL_DS);
25965 + loadsegment(es, __KERNEL_DS);
25966 + loadsegment(ss, __KERNEL_DS);
25967 +
25968 +#ifdef CONFIG_PAX_KERNEXEC
25969 + loadsegment(fs, __KERNEL_PERCPU);
25970 +#endif
25971 +
25972 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25973 + __set_fs(current_thread_info()->addr_limit);
25974 +#endif
25975 +
25976 #endif
25977
25978 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
25979 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
25980 index e8ba99c..ee9d7d9 100644
25981 --- a/arch/x86/kvm/x86.c
25982 +++ b/arch/x86/kvm/x86.c
25983 @@ -1725,8 +1725,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
25984 {
25985 struct kvm *kvm = vcpu->kvm;
25986 int lm = is_long_mode(vcpu);
25987 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
25988 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
25989 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
25990 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
25991 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
25992 : kvm->arch.xen_hvm_config.blob_size_32;
25993 u32 page_num = data & ~PAGE_MASK;
25994 @@ -2609,6 +2609,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
25995 if (n < msr_list.nmsrs)
25996 goto out;
25997 r = -EFAULT;
25998 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
25999 + goto out;
26000 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26001 num_msrs_to_save * sizeof(u32)))
26002 goto out;
26003 @@ -5297,7 +5299,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26004 };
26005 #endif
26006
26007 -int kvm_arch_init(void *opaque)
26008 +int kvm_arch_init(const void *opaque)
26009 {
26010 int r;
26011 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
26012 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26013 index 7114c63..a1018fc 100644
26014 --- a/arch/x86/lguest/boot.c
26015 +++ b/arch/x86/lguest/boot.c
26016 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26017 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26018 * Launcher to reboot us.
26019 */
26020 -static void lguest_restart(char *reason)
26021 +static __noreturn void lguest_restart(char *reason)
26022 {
26023 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26024 + BUG();
26025 }
26026
26027 /*G:050
26028 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26029 index 00933d5..3a64af9 100644
26030 --- a/arch/x86/lib/atomic64_386_32.S
26031 +++ b/arch/x86/lib/atomic64_386_32.S
26032 @@ -48,6 +48,10 @@ BEGIN(read)
26033 movl (v), %eax
26034 movl 4(v), %edx
26035 RET_ENDP
26036 +BEGIN(read_unchecked)
26037 + movl (v), %eax
26038 + movl 4(v), %edx
26039 +RET_ENDP
26040 #undef v
26041
26042 #define v %esi
26043 @@ -55,6 +59,10 @@ BEGIN(set)
26044 movl %ebx, (v)
26045 movl %ecx, 4(v)
26046 RET_ENDP
26047 +BEGIN(set_unchecked)
26048 + movl %ebx, (v)
26049 + movl %ecx, 4(v)
26050 +RET_ENDP
26051 #undef v
26052
26053 #define v %esi
26054 @@ -70,6 +78,20 @@ RET_ENDP
26055 BEGIN(add)
26056 addl %eax, (v)
26057 adcl %edx, 4(v)
26058 +
26059 +#ifdef CONFIG_PAX_REFCOUNT
26060 + jno 0f
26061 + subl %eax, (v)
26062 + sbbl %edx, 4(v)
26063 + int $4
26064 +0:
26065 + _ASM_EXTABLE(0b, 0b)
26066 +#endif
26067 +
26068 +RET_ENDP
26069 +BEGIN(add_unchecked)
26070 + addl %eax, (v)
26071 + adcl %edx, 4(v)
26072 RET_ENDP
26073 #undef v
26074
26075 @@ -77,6 +99,24 @@ RET_ENDP
26076 BEGIN(add_return)
26077 addl (v), %eax
26078 adcl 4(v), %edx
26079 +
26080 +#ifdef CONFIG_PAX_REFCOUNT
26081 + into
26082 +1234:
26083 + _ASM_EXTABLE(1234b, 2f)
26084 +#endif
26085 +
26086 + movl %eax, (v)
26087 + movl %edx, 4(v)
26088 +
26089 +#ifdef CONFIG_PAX_REFCOUNT
26090 +2:
26091 +#endif
26092 +
26093 +RET_ENDP
26094 +BEGIN(add_return_unchecked)
26095 + addl (v), %eax
26096 + adcl 4(v), %edx
26097 movl %eax, (v)
26098 movl %edx, 4(v)
26099 RET_ENDP
26100 @@ -86,6 +126,20 @@ RET_ENDP
26101 BEGIN(sub)
26102 subl %eax, (v)
26103 sbbl %edx, 4(v)
26104 +
26105 +#ifdef CONFIG_PAX_REFCOUNT
26106 + jno 0f
26107 + addl %eax, (v)
26108 + adcl %edx, 4(v)
26109 + int $4
26110 +0:
26111 + _ASM_EXTABLE(0b, 0b)
26112 +#endif
26113 +
26114 +RET_ENDP
26115 +BEGIN(sub_unchecked)
26116 + subl %eax, (v)
26117 + sbbl %edx, 4(v)
26118 RET_ENDP
26119 #undef v
26120
26121 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26122 sbbl $0, %edx
26123 addl (v), %eax
26124 adcl 4(v), %edx
26125 +
26126 +#ifdef CONFIG_PAX_REFCOUNT
26127 + into
26128 +1234:
26129 + _ASM_EXTABLE(1234b, 2f)
26130 +#endif
26131 +
26132 + movl %eax, (v)
26133 + movl %edx, 4(v)
26134 +
26135 +#ifdef CONFIG_PAX_REFCOUNT
26136 +2:
26137 +#endif
26138 +
26139 +RET_ENDP
26140 +BEGIN(sub_return_unchecked)
26141 + negl %edx
26142 + negl %eax
26143 + sbbl $0, %edx
26144 + addl (v), %eax
26145 + adcl 4(v), %edx
26146 movl %eax, (v)
26147 movl %edx, 4(v)
26148 RET_ENDP
26149 @@ -105,6 +180,20 @@ RET_ENDP
26150 BEGIN(inc)
26151 addl $1, (v)
26152 adcl $0, 4(v)
26153 +
26154 +#ifdef CONFIG_PAX_REFCOUNT
26155 + jno 0f
26156 + subl $1, (v)
26157 + sbbl $0, 4(v)
26158 + int $4
26159 +0:
26160 + _ASM_EXTABLE(0b, 0b)
26161 +#endif
26162 +
26163 +RET_ENDP
26164 +BEGIN(inc_unchecked)
26165 + addl $1, (v)
26166 + adcl $0, 4(v)
26167 RET_ENDP
26168 #undef v
26169
26170 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26171 movl 4(v), %edx
26172 addl $1, %eax
26173 adcl $0, %edx
26174 +
26175 +#ifdef CONFIG_PAX_REFCOUNT
26176 + into
26177 +1234:
26178 + _ASM_EXTABLE(1234b, 2f)
26179 +#endif
26180 +
26181 + movl %eax, (v)
26182 + movl %edx, 4(v)
26183 +
26184 +#ifdef CONFIG_PAX_REFCOUNT
26185 +2:
26186 +#endif
26187 +
26188 +RET_ENDP
26189 +BEGIN(inc_return_unchecked)
26190 + movl (v), %eax
26191 + movl 4(v), %edx
26192 + addl $1, %eax
26193 + adcl $0, %edx
26194 movl %eax, (v)
26195 movl %edx, 4(v)
26196 RET_ENDP
26197 @@ -123,6 +232,20 @@ RET_ENDP
26198 BEGIN(dec)
26199 subl $1, (v)
26200 sbbl $0, 4(v)
26201 +
26202 +#ifdef CONFIG_PAX_REFCOUNT
26203 + jno 0f
26204 + addl $1, (v)
26205 + adcl $0, 4(v)
26206 + int $4
26207 +0:
26208 + _ASM_EXTABLE(0b, 0b)
26209 +#endif
26210 +
26211 +RET_ENDP
26212 +BEGIN(dec_unchecked)
26213 + subl $1, (v)
26214 + sbbl $0, 4(v)
26215 RET_ENDP
26216 #undef v
26217
26218 @@ -132,6 +255,26 @@ BEGIN(dec_return)
26219 movl 4(v), %edx
26220 subl $1, %eax
26221 sbbl $0, %edx
26222 +
26223 +#ifdef CONFIG_PAX_REFCOUNT
26224 + into
26225 +1234:
26226 + _ASM_EXTABLE(1234b, 2f)
26227 +#endif
26228 +
26229 + movl %eax, (v)
26230 + movl %edx, 4(v)
26231 +
26232 +#ifdef CONFIG_PAX_REFCOUNT
26233 +2:
26234 +#endif
26235 +
26236 +RET_ENDP
26237 +BEGIN(dec_return_unchecked)
26238 + movl (v), %eax
26239 + movl 4(v), %edx
26240 + subl $1, %eax
26241 + sbbl $0, %edx
26242 movl %eax, (v)
26243 movl %edx, 4(v)
26244 RET_ENDP
26245 @@ -143,6 +286,13 @@ BEGIN(add_unless)
26246 adcl %edx, %edi
26247 addl (v), %eax
26248 adcl 4(v), %edx
26249 +
26250 +#ifdef CONFIG_PAX_REFCOUNT
26251 + into
26252 +1234:
26253 + _ASM_EXTABLE(1234b, 2f)
26254 +#endif
26255 +
26256 cmpl %eax, %ecx
26257 je 3f
26258 1:
26259 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
26260 1:
26261 addl $1, %eax
26262 adcl $0, %edx
26263 +
26264 +#ifdef CONFIG_PAX_REFCOUNT
26265 + into
26266 +1234:
26267 + _ASM_EXTABLE(1234b, 2f)
26268 +#endif
26269 +
26270 movl %eax, (v)
26271 movl %edx, 4(v)
26272 movl $1, %eax
26273 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
26274 movl 4(v), %edx
26275 subl $1, %eax
26276 sbbl $0, %edx
26277 +
26278 +#ifdef CONFIG_PAX_REFCOUNT
26279 + into
26280 +1234:
26281 + _ASM_EXTABLE(1234b, 1f)
26282 +#endif
26283 +
26284 js 1f
26285 movl %eax, (v)
26286 movl %edx, 4(v)
26287 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
26288 index f5cc9eb..51fa319 100644
26289 --- a/arch/x86/lib/atomic64_cx8_32.S
26290 +++ b/arch/x86/lib/atomic64_cx8_32.S
26291 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
26292 CFI_STARTPROC
26293
26294 read64 %ecx
26295 + pax_force_retaddr
26296 ret
26297 CFI_ENDPROC
26298 ENDPROC(atomic64_read_cx8)
26299
26300 +ENTRY(atomic64_read_unchecked_cx8)
26301 + CFI_STARTPROC
26302 +
26303 + read64 %ecx
26304 + pax_force_retaddr
26305 + ret
26306 + CFI_ENDPROC
26307 +ENDPROC(atomic64_read_unchecked_cx8)
26308 +
26309 ENTRY(atomic64_set_cx8)
26310 CFI_STARTPROC
26311
26312 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
26313 cmpxchg8b (%esi)
26314 jne 1b
26315
26316 + pax_force_retaddr
26317 ret
26318 CFI_ENDPROC
26319 ENDPROC(atomic64_set_cx8)
26320
26321 +ENTRY(atomic64_set_unchecked_cx8)
26322 + CFI_STARTPROC
26323 +
26324 +1:
26325 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
26326 + * are atomic on 586 and newer */
26327 + cmpxchg8b (%esi)
26328 + jne 1b
26329 +
26330 + pax_force_retaddr
26331 + ret
26332 + CFI_ENDPROC
26333 +ENDPROC(atomic64_set_unchecked_cx8)
26334 +
26335 ENTRY(atomic64_xchg_cx8)
26336 CFI_STARTPROC
26337
26338 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
26339 cmpxchg8b (%esi)
26340 jne 1b
26341
26342 + pax_force_retaddr
26343 ret
26344 CFI_ENDPROC
26345 ENDPROC(atomic64_xchg_cx8)
26346
26347 -.macro addsub_return func ins insc
26348 -ENTRY(atomic64_\func\()_return_cx8)
26349 +.macro addsub_return func ins insc unchecked=""
26350 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
26351 CFI_STARTPROC
26352 SAVE ebp
26353 SAVE ebx
26354 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
26355 movl %edx, %ecx
26356 \ins\()l %esi, %ebx
26357 \insc\()l %edi, %ecx
26358 +
26359 +.ifb \unchecked
26360 +#ifdef CONFIG_PAX_REFCOUNT
26361 + into
26362 +2:
26363 + _ASM_EXTABLE(2b, 3f)
26364 +#endif
26365 +.endif
26366 +
26367 LOCK_PREFIX
26368 cmpxchg8b (%ebp)
26369 jne 1b
26370 -
26371 -10:
26372 movl %ebx, %eax
26373 movl %ecx, %edx
26374 +
26375 +.ifb \unchecked
26376 +#ifdef CONFIG_PAX_REFCOUNT
26377 +3:
26378 +#endif
26379 +.endif
26380 +
26381 RESTORE edi
26382 RESTORE esi
26383 RESTORE ebx
26384 RESTORE ebp
26385 + pax_force_retaddr
26386 ret
26387 CFI_ENDPROC
26388 -ENDPROC(atomic64_\func\()_return_cx8)
26389 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
26390 .endm
26391
26392 addsub_return add add adc
26393 addsub_return sub sub sbb
26394 +addsub_return add add adc _unchecked
26395 +addsub_return sub sub sbb _unchecked
26396
26397 -.macro incdec_return func ins insc
26398 -ENTRY(atomic64_\func\()_return_cx8)
26399 +.macro incdec_return func ins insc unchecked=""
26400 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
26401 CFI_STARTPROC
26402 SAVE ebx
26403
26404 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
26405 movl %edx, %ecx
26406 \ins\()l $1, %ebx
26407 \insc\()l $0, %ecx
26408 +
26409 +.ifb \unchecked
26410 +#ifdef CONFIG_PAX_REFCOUNT
26411 + into
26412 +2:
26413 + _ASM_EXTABLE(2b, 3f)
26414 +#endif
26415 +.endif
26416 +
26417 LOCK_PREFIX
26418 cmpxchg8b (%esi)
26419 jne 1b
26420
26421 -10:
26422 movl %ebx, %eax
26423 movl %ecx, %edx
26424 +
26425 +.ifb \unchecked
26426 +#ifdef CONFIG_PAX_REFCOUNT
26427 +3:
26428 +#endif
26429 +.endif
26430 +
26431 RESTORE ebx
26432 + pax_force_retaddr
26433 ret
26434 CFI_ENDPROC
26435 -ENDPROC(atomic64_\func\()_return_cx8)
26436 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
26437 .endm
26438
26439 incdec_return inc add adc
26440 incdec_return dec sub sbb
26441 +incdec_return inc add adc _unchecked
26442 +incdec_return dec sub sbb _unchecked
26443
26444 ENTRY(atomic64_dec_if_positive_cx8)
26445 CFI_STARTPROC
26446 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
26447 movl %edx, %ecx
26448 subl $1, %ebx
26449 sbb $0, %ecx
26450 +
26451 +#ifdef CONFIG_PAX_REFCOUNT
26452 + into
26453 +1234:
26454 + _ASM_EXTABLE(1234b, 2f)
26455 +#endif
26456 +
26457 js 2f
26458 LOCK_PREFIX
26459 cmpxchg8b (%esi)
26460 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
26461 movl %ebx, %eax
26462 movl %ecx, %edx
26463 RESTORE ebx
26464 + pax_force_retaddr
26465 ret
26466 CFI_ENDPROC
26467 ENDPROC(atomic64_dec_if_positive_cx8)
26468 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
26469 movl %edx, %ecx
26470 addl %ebp, %ebx
26471 adcl %edi, %ecx
26472 +
26473 +#ifdef CONFIG_PAX_REFCOUNT
26474 + into
26475 +1234:
26476 + _ASM_EXTABLE(1234b, 3f)
26477 +#endif
26478 +
26479 LOCK_PREFIX
26480 cmpxchg8b (%esi)
26481 jne 1b
26482 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
26483 CFI_ADJUST_CFA_OFFSET -8
26484 RESTORE ebx
26485 RESTORE ebp
26486 + pax_force_retaddr
26487 ret
26488 4:
26489 cmpl %edx, 4(%esp)
26490 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
26491 xorl %ecx, %ecx
26492 addl $1, %ebx
26493 adcl %edx, %ecx
26494 +
26495 +#ifdef CONFIG_PAX_REFCOUNT
26496 + into
26497 +1234:
26498 + _ASM_EXTABLE(1234b, 3f)
26499 +#endif
26500 +
26501 LOCK_PREFIX
26502 cmpxchg8b (%esi)
26503 jne 1b
26504 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
26505 movl $1, %eax
26506 3:
26507 RESTORE ebx
26508 + pax_force_retaddr
26509 ret
26510 CFI_ENDPROC
26511 ENDPROC(atomic64_inc_not_zero_cx8)
26512 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
26513 index e78b8ee..7e173a8 100644
26514 --- a/arch/x86/lib/checksum_32.S
26515 +++ b/arch/x86/lib/checksum_32.S
26516 @@ -29,7 +29,8 @@
26517 #include <asm/dwarf2.h>
26518 #include <asm/errno.h>
26519 #include <asm/asm.h>
26520 -
26521 +#include <asm/segment.h>
26522 +
26523 /*
26524 * computes a partial checksum, e.g. for TCP/UDP fragments
26525 */
26526 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
26527
26528 #define ARGBASE 16
26529 #define FP 12
26530 -
26531 -ENTRY(csum_partial_copy_generic)
26532 +
26533 +ENTRY(csum_partial_copy_generic_to_user)
26534 CFI_STARTPROC
26535 +
26536 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26537 + pushl_cfi %gs
26538 + popl_cfi %es
26539 + jmp csum_partial_copy_generic
26540 +#endif
26541 +
26542 +ENTRY(csum_partial_copy_generic_from_user)
26543 +
26544 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26545 + pushl_cfi %gs
26546 + popl_cfi %ds
26547 +#endif
26548 +
26549 +ENTRY(csum_partial_copy_generic)
26550 subl $4,%esp
26551 CFI_ADJUST_CFA_OFFSET 4
26552 pushl_cfi %edi
26553 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
26554 jmp 4f
26555 SRC(1: movw (%esi), %bx )
26556 addl $2, %esi
26557 -DST( movw %bx, (%edi) )
26558 +DST( movw %bx, %es:(%edi) )
26559 addl $2, %edi
26560 addw %bx, %ax
26561 adcl $0, %eax
26562 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
26563 SRC(1: movl (%esi), %ebx )
26564 SRC( movl 4(%esi), %edx )
26565 adcl %ebx, %eax
26566 -DST( movl %ebx, (%edi) )
26567 +DST( movl %ebx, %es:(%edi) )
26568 adcl %edx, %eax
26569 -DST( movl %edx, 4(%edi) )
26570 +DST( movl %edx, %es:4(%edi) )
26571
26572 SRC( movl 8(%esi), %ebx )
26573 SRC( movl 12(%esi), %edx )
26574 adcl %ebx, %eax
26575 -DST( movl %ebx, 8(%edi) )
26576 +DST( movl %ebx, %es:8(%edi) )
26577 adcl %edx, %eax
26578 -DST( movl %edx, 12(%edi) )
26579 +DST( movl %edx, %es:12(%edi) )
26580
26581 SRC( movl 16(%esi), %ebx )
26582 SRC( movl 20(%esi), %edx )
26583 adcl %ebx, %eax
26584 -DST( movl %ebx, 16(%edi) )
26585 +DST( movl %ebx, %es:16(%edi) )
26586 adcl %edx, %eax
26587 -DST( movl %edx, 20(%edi) )
26588 +DST( movl %edx, %es:20(%edi) )
26589
26590 SRC( movl 24(%esi), %ebx )
26591 SRC( movl 28(%esi), %edx )
26592 adcl %ebx, %eax
26593 -DST( movl %ebx, 24(%edi) )
26594 +DST( movl %ebx, %es:24(%edi) )
26595 adcl %edx, %eax
26596 -DST( movl %edx, 28(%edi) )
26597 +DST( movl %edx, %es:28(%edi) )
26598
26599 lea 32(%esi), %esi
26600 lea 32(%edi), %edi
26601 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
26602 shrl $2, %edx # This clears CF
26603 SRC(3: movl (%esi), %ebx )
26604 adcl %ebx, %eax
26605 -DST( movl %ebx, (%edi) )
26606 +DST( movl %ebx, %es:(%edi) )
26607 lea 4(%esi), %esi
26608 lea 4(%edi), %edi
26609 dec %edx
26610 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
26611 jb 5f
26612 SRC( movw (%esi), %cx )
26613 leal 2(%esi), %esi
26614 -DST( movw %cx, (%edi) )
26615 +DST( movw %cx, %es:(%edi) )
26616 leal 2(%edi), %edi
26617 je 6f
26618 shll $16,%ecx
26619 SRC(5: movb (%esi), %cl )
26620 -DST( movb %cl, (%edi) )
26621 +DST( movb %cl, %es:(%edi) )
26622 6: addl %ecx, %eax
26623 adcl $0, %eax
26624 7:
26625 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
26626
26627 6001:
26628 movl ARGBASE+20(%esp), %ebx # src_err_ptr
26629 - movl $-EFAULT, (%ebx)
26630 + movl $-EFAULT, %ss:(%ebx)
26631
26632 # zero the complete destination - computing the rest
26633 # is too much work
26634 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
26635
26636 6002:
26637 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
26638 - movl $-EFAULT,(%ebx)
26639 + movl $-EFAULT,%ss:(%ebx)
26640 jmp 5000b
26641
26642 .previous
26643
26644 + pushl_cfi %ss
26645 + popl_cfi %ds
26646 + pushl_cfi %ss
26647 + popl_cfi %es
26648 popl_cfi %ebx
26649 CFI_RESTORE ebx
26650 popl_cfi %esi
26651 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
26652 popl_cfi %ecx # equivalent to addl $4,%esp
26653 ret
26654 CFI_ENDPROC
26655 -ENDPROC(csum_partial_copy_generic)
26656 +ENDPROC(csum_partial_copy_generic_to_user)
26657
26658 #else
26659
26660 /* Version for PentiumII/PPro */
26661
26662 #define ROUND1(x) \
26663 + nop; nop; nop; \
26664 SRC(movl x(%esi), %ebx ) ; \
26665 addl %ebx, %eax ; \
26666 - DST(movl %ebx, x(%edi) ) ;
26667 + DST(movl %ebx, %es:x(%edi)) ;
26668
26669 #define ROUND(x) \
26670 + nop; nop; nop; \
26671 SRC(movl x(%esi), %ebx ) ; \
26672 adcl %ebx, %eax ; \
26673 - DST(movl %ebx, x(%edi) ) ;
26674 + DST(movl %ebx, %es:x(%edi)) ;
26675
26676 #define ARGBASE 12
26677 -
26678 -ENTRY(csum_partial_copy_generic)
26679 +
26680 +ENTRY(csum_partial_copy_generic_to_user)
26681 CFI_STARTPROC
26682 +
26683 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26684 + pushl_cfi %gs
26685 + popl_cfi %es
26686 + jmp csum_partial_copy_generic
26687 +#endif
26688 +
26689 +ENTRY(csum_partial_copy_generic_from_user)
26690 +
26691 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26692 + pushl_cfi %gs
26693 + popl_cfi %ds
26694 +#endif
26695 +
26696 +ENTRY(csum_partial_copy_generic)
26697 pushl_cfi %ebx
26698 CFI_REL_OFFSET ebx, 0
26699 pushl_cfi %edi
26700 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
26701 subl %ebx, %edi
26702 lea -1(%esi),%edx
26703 andl $-32,%edx
26704 - lea 3f(%ebx,%ebx), %ebx
26705 + lea 3f(%ebx,%ebx,2), %ebx
26706 testl %esi, %esi
26707 jmp *%ebx
26708 1: addl $64,%esi
26709 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
26710 jb 5f
26711 SRC( movw (%esi), %dx )
26712 leal 2(%esi), %esi
26713 -DST( movw %dx, (%edi) )
26714 +DST( movw %dx, %es:(%edi) )
26715 leal 2(%edi), %edi
26716 je 6f
26717 shll $16,%edx
26718 5:
26719 SRC( movb (%esi), %dl )
26720 -DST( movb %dl, (%edi) )
26721 +DST( movb %dl, %es:(%edi) )
26722 6: addl %edx, %eax
26723 adcl $0, %eax
26724 7:
26725 .section .fixup, "ax"
26726 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
26727 - movl $-EFAULT, (%ebx)
26728 + movl $-EFAULT, %ss:(%ebx)
26729 # zero the complete destination (computing the rest is too much work)
26730 movl ARGBASE+8(%esp),%edi # dst
26731 movl ARGBASE+12(%esp),%ecx # len
26732 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
26733 rep; stosb
26734 jmp 7b
26735 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
26736 - movl $-EFAULT, (%ebx)
26737 + movl $-EFAULT, %ss:(%ebx)
26738 jmp 7b
26739 .previous
26740
26741 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26742 + pushl_cfi %ss
26743 + popl_cfi %ds
26744 + pushl_cfi %ss
26745 + popl_cfi %es
26746 +#endif
26747 +
26748 popl_cfi %esi
26749 CFI_RESTORE esi
26750 popl_cfi %edi
26751 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
26752 CFI_RESTORE ebx
26753 ret
26754 CFI_ENDPROC
26755 -ENDPROC(csum_partial_copy_generic)
26756 +ENDPROC(csum_partial_copy_generic_to_user)
26757
26758 #undef ROUND
26759 #undef ROUND1
26760 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
26761 index f2145cf..cea889d 100644
26762 --- a/arch/x86/lib/clear_page_64.S
26763 +++ b/arch/x86/lib/clear_page_64.S
26764 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
26765 movl $4096/8,%ecx
26766 xorl %eax,%eax
26767 rep stosq
26768 + pax_force_retaddr
26769 ret
26770 CFI_ENDPROC
26771 ENDPROC(clear_page_c)
26772 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
26773 movl $4096,%ecx
26774 xorl %eax,%eax
26775 rep stosb
26776 + pax_force_retaddr
26777 ret
26778 CFI_ENDPROC
26779 ENDPROC(clear_page_c_e)
26780 @@ -43,6 +45,7 @@ ENTRY(clear_page)
26781 leaq 64(%rdi),%rdi
26782 jnz .Lloop
26783 nop
26784 + pax_force_retaddr
26785 ret
26786 CFI_ENDPROC
26787 .Lclear_page_end:
26788 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
26789
26790 #include <asm/cpufeature.h>
26791
26792 - .section .altinstr_replacement,"ax"
26793 + .section .altinstr_replacement,"a"
26794 1: .byte 0xeb /* jmp <disp8> */
26795 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
26796 2: .byte 0xeb /* jmp <disp8> */
26797 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
26798 index 1e572c5..2a162cd 100644
26799 --- a/arch/x86/lib/cmpxchg16b_emu.S
26800 +++ b/arch/x86/lib/cmpxchg16b_emu.S
26801 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
26802
26803 popf
26804 mov $1, %al
26805 + pax_force_retaddr
26806 ret
26807
26808 not_same:
26809 popf
26810 xor %al,%al
26811 + pax_force_retaddr
26812 ret
26813
26814 CFI_ENDPROC
26815 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
26816 index 176cca6..1166c50 100644
26817 --- a/arch/x86/lib/copy_page_64.S
26818 +++ b/arch/x86/lib/copy_page_64.S
26819 @@ -9,6 +9,7 @@ copy_page_rep:
26820 CFI_STARTPROC
26821 movl $4096/8, %ecx
26822 rep movsq
26823 + pax_force_retaddr
26824 ret
26825 CFI_ENDPROC
26826 ENDPROC(copy_page_rep)
26827 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
26828
26829 ENTRY(copy_page)
26830 CFI_STARTPROC
26831 - subq $2*8, %rsp
26832 - CFI_ADJUST_CFA_OFFSET 2*8
26833 + subq $3*8, %rsp
26834 + CFI_ADJUST_CFA_OFFSET 3*8
26835 movq %rbx, (%rsp)
26836 CFI_REL_OFFSET rbx, 0
26837 movq %r12, 1*8(%rsp)
26838 CFI_REL_OFFSET r12, 1*8
26839 + movq %r13, 2*8(%rsp)
26840 + CFI_REL_OFFSET r13, 2*8
26841
26842 movl $(4096/64)-5, %ecx
26843 .p2align 4
26844 @@ -36,7 +39,7 @@ ENTRY(copy_page)
26845 movq 0x8*2(%rsi), %rdx
26846 movq 0x8*3(%rsi), %r8
26847 movq 0x8*4(%rsi), %r9
26848 - movq 0x8*5(%rsi), %r10
26849 + movq 0x8*5(%rsi), %r13
26850 movq 0x8*6(%rsi), %r11
26851 movq 0x8*7(%rsi), %r12
26852
26853 @@ -47,7 +50,7 @@ ENTRY(copy_page)
26854 movq %rdx, 0x8*2(%rdi)
26855 movq %r8, 0x8*3(%rdi)
26856 movq %r9, 0x8*4(%rdi)
26857 - movq %r10, 0x8*5(%rdi)
26858 + movq %r13, 0x8*5(%rdi)
26859 movq %r11, 0x8*6(%rdi)
26860 movq %r12, 0x8*7(%rdi)
26861
26862 @@ -66,7 +69,7 @@ ENTRY(copy_page)
26863 movq 0x8*2(%rsi), %rdx
26864 movq 0x8*3(%rsi), %r8
26865 movq 0x8*4(%rsi), %r9
26866 - movq 0x8*5(%rsi), %r10
26867 + movq 0x8*5(%rsi), %r13
26868 movq 0x8*6(%rsi), %r11
26869 movq 0x8*7(%rsi), %r12
26870
26871 @@ -75,7 +78,7 @@ ENTRY(copy_page)
26872 movq %rdx, 0x8*2(%rdi)
26873 movq %r8, 0x8*3(%rdi)
26874 movq %r9, 0x8*4(%rdi)
26875 - movq %r10, 0x8*5(%rdi)
26876 + movq %r13, 0x8*5(%rdi)
26877 movq %r11, 0x8*6(%rdi)
26878 movq %r12, 0x8*7(%rdi)
26879
26880 @@ -87,8 +90,11 @@ ENTRY(copy_page)
26881 CFI_RESTORE rbx
26882 movq 1*8(%rsp), %r12
26883 CFI_RESTORE r12
26884 - addq $2*8, %rsp
26885 - CFI_ADJUST_CFA_OFFSET -2*8
26886 + movq 2*8(%rsp), %r13
26887 + CFI_RESTORE r13
26888 + addq $3*8, %rsp
26889 + CFI_ADJUST_CFA_OFFSET -3*8
26890 + pax_force_retaddr
26891 ret
26892 .Lcopy_page_end:
26893 CFI_ENDPROC
26894 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
26895
26896 #include <asm/cpufeature.h>
26897
26898 - .section .altinstr_replacement,"ax"
26899 + .section .altinstr_replacement,"a"
26900 1: .byte 0xeb /* jmp <disp8> */
26901 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
26902 2:
26903 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
26904 index a30ca15..6b3f4e1 100644
26905 --- a/arch/x86/lib/copy_user_64.S
26906 +++ b/arch/x86/lib/copy_user_64.S
26907 @@ -18,31 +18,7 @@
26908 #include <asm/alternative-asm.h>
26909 #include <asm/asm.h>
26910 #include <asm/smap.h>
26911 -
26912 -/*
26913 - * By placing feature2 after feature1 in altinstructions section, we logically
26914 - * implement:
26915 - * If CPU has feature2, jmp to alt2 is used
26916 - * else if CPU has feature1, jmp to alt1 is used
26917 - * else jmp to orig is used.
26918 - */
26919 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
26920 -0:
26921 - .byte 0xe9 /* 32bit jump */
26922 - .long \orig-1f /* by default jump to orig */
26923 -1:
26924 - .section .altinstr_replacement,"ax"
26925 -2: .byte 0xe9 /* near jump with 32bit immediate */
26926 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
26927 -3: .byte 0xe9 /* near jump with 32bit immediate */
26928 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
26929 - .previous
26930 -
26931 - .section .altinstructions,"a"
26932 - altinstruction_entry 0b,2b,\feature1,5,5
26933 - altinstruction_entry 0b,3b,\feature2,5,5
26934 - .previous
26935 - .endm
26936 +#include <asm/pgtable.h>
26937
26938 .macro ALIGN_DESTINATION
26939 #ifdef FIX_ALIGNMENT
26940 @@ -70,52 +46,6 @@
26941 #endif
26942 .endm
26943
26944 -/* Standard copy_to_user with segment limit checking */
26945 -ENTRY(_copy_to_user)
26946 - CFI_STARTPROC
26947 - GET_THREAD_INFO(%rax)
26948 - movq %rdi,%rcx
26949 - addq %rdx,%rcx
26950 - jc bad_to_user
26951 - cmpq TI_addr_limit(%rax),%rcx
26952 - ja bad_to_user
26953 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
26954 - copy_user_generic_unrolled,copy_user_generic_string, \
26955 - copy_user_enhanced_fast_string
26956 - CFI_ENDPROC
26957 -ENDPROC(_copy_to_user)
26958 -
26959 -/* Standard copy_from_user with segment limit checking */
26960 -ENTRY(_copy_from_user)
26961 - CFI_STARTPROC
26962 - GET_THREAD_INFO(%rax)
26963 - movq %rsi,%rcx
26964 - addq %rdx,%rcx
26965 - jc bad_from_user
26966 - cmpq TI_addr_limit(%rax),%rcx
26967 - ja bad_from_user
26968 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
26969 - copy_user_generic_unrolled,copy_user_generic_string, \
26970 - copy_user_enhanced_fast_string
26971 - CFI_ENDPROC
26972 -ENDPROC(_copy_from_user)
26973 -
26974 - .section .fixup,"ax"
26975 - /* must zero dest */
26976 -ENTRY(bad_from_user)
26977 -bad_from_user:
26978 - CFI_STARTPROC
26979 - movl %edx,%ecx
26980 - xorl %eax,%eax
26981 - rep
26982 - stosb
26983 -bad_to_user:
26984 - movl %edx,%eax
26985 - ret
26986 - CFI_ENDPROC
26987 -ENDPROC(bad_from_user)
26988 - .previous
26989 -
26990 /*
26991 * copy_user_generic_unrolled - memory copy with exception handling.
26992 * This version is for CPUs like P4 that don't have efficient micro
26993 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
26994 */
26995 ENTRY(copy_user_generic_unrolled)
26996 CFI_STARTPROC
26997 + ASM_PAX_OPEN_USERLAND
26998 ASM_STAC
26999 cmpl $8,%edx
27000 jb 20f /* less then 8 bytes, go to byte copy loop */
27001 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27002 jz 17f
27003 1: movq (%rsi),%r8
27004 2: movq 1*8(%rsi),%r9
27005 -3: movq 2*8(%rsi),%r10
27006 +3: movq 2*8(%rsi),%rax
27007 4: movq 3*8(%rsi),%r11
27008 5: movq %r8,(%rdi)
27009 6: movq %r9,1*8(%rdi)
27010 -7: movq %r10,2*8(%rdi)
27011 +7: movq %rax,2*8(%rdi)
27012 8: movq %r11,3*8(%rdi)
27013 9: movq 4*8(%rsi),%r8
27014 10: movq 5*8(%rsi),%r9
27015 -11: movq 6*8(%rsi),%r10
27016 +11: movq 6*8(%rsi),%rax
27017 12: movq 7*8(%rsi),%r11
27018 13: movq %r8,4*8(%rdi)
27019 14: movq %r9,5*8(%rdi)
27020 -15: movq %r10,6*8(%rdi)
27021 +15: movq %rax,6*8(%rdi)
27022 16: movq %r11,7*8(%rdi)
27023 leaq 64(%rsi),%rsi
27024 leaq 64(%rdi),%rdi
27025 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27026 jnz 21b
27027 23: xor %eax,%eax
27028 ASM_CLAC
27029 + ASM_PAX_CLOSE_USERLAND
27030 + pax_force_retaddr
27031 ret
27032
27033 .section .fixup,"ax"
27034 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27035 */
27036 ENTRY(copy_user_generic_string)
27037 CFI_STARTPROC
27038 + ASM_PAX_OPEN_USERLAND
27039 ASM_STAC
27040 andl %edx,%edx
27041 jz 4f
27042 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27043 movsb
27044 4: xorl %eax,%eax
27045 ASM_CLAC
27046 + ASM_PAX_CLOSE_USERLAND
27047 + pax_force_retaddr
27048 ret
27049
27050 .section .fixup,"ax"
27051 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27052 */
27053 ENTRY(copy_user_enhanced_fast_string)
27054 CFI_STARTPROC
27055 + ASM_PAX_OPEN_USERLAND
27056 ASM_STAC
27057 andl %edx,%edx
27058 jz 2f
27059 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27060 movsb
27061 2: xorl %eax,%eax
27062 ASM_CLAC
27063 + ASM_PAX_CLOSE_USERLAND
27064 + pax_force_retaddr
27065 ret
27066
27067 .section .fixup,"ax"
27068 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27069 index 6a4f43c..55d26f2 100644
27070 --- a/arch/x86/lib/copy_user_nocache_64.S
27071 +++ b/arch/x86/lib/copy_user_nocache_64.S
27072 @@ -8,6 +8,7 @@
27073
27074 #include <linux/linkage.h>
27075 #include <asm/dwarf2.h>
27076 +#include <asm/alternative-asm.h>
27077
27078 #define FIX_ALIGNMENT 1
27079
27080 @@ -16,6 +17,7 @@
27081 #include <asm/thread_info.h>
27082 #include <asm/asm.h>
27083 #include <asm/smap.h>
27084 +#include <asm/pgtable.h>
27085
27086 .macro ALIGN_DESTINATION
27087 #ifdef FIX_ALIGNMENT
27088 @@ -49,6 +51,16 @@
27089 */
27090 ENTRY(__copy_user_nocache)
27091 CFI_STARTPROC
27092 +
27093 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27094 + mov pax_user_shadow_base,%rcx
27095 + cmp %rcx,%rsi
27096 + jae 1f
27097 + add %rcx,%rsi
27098 +1:
27099 +#endif
27100 +
27101 + ASM_PAX_OPEN_USERLAND
27102 ASM_STAC
27103 cmpl $8,%edx
27104 jb 20f /* less then 8 bytes, go to byte copy loop */
27105 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27106 jz 17f
27107 1: movq (%rsi),%r8
27108 2: movq 1*8(%rsi),%r9
27109 -3: movq 2*8(%rsi),%r10
27110 +3: movq 2*8(%rsi),%rax
27111 4: movq 3*8(%rsi),%r11
27112 5: movnti %r8,(%rdi)
27113 6: movnti %r9,1*8(%rdi)
27114 -7: movnti %r10,2*8(%rdi)
27115 +7: movnti %rax,2*8(%rdi)
27116 8: movnti %r11,3*8(%rdi)
27117 9: movq 4*8(%rsi),%r8
27118 10: movq 5*8(%rsi),%r9
27119 -11: movq 6*8(%rsi),%r10
27120 +11: movq 6*8(%rsi),%rax
27121 12: movq 7*8(%rsi),%r11
27122 13: movnti %r8,4*8(%rdi)
27123 14: movnti %r9,5*8(%rdi)
27124 -15: movnti %r10,6*8(%rdi)
27125 +15: movnti %rax,6*8(%rdi)
27126 16: movnti %r11,7*8(%rdi)
27127 leaq 64(%rsi),%rsi
27128 leaq 64(%rdi),%rdi
27129 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27130 jnz 21b
27131 23: xorl %eax,%eax
27132 ASM_CLAC
27133 + ASM_PAX_CLOSE_USERLAND
27134 sfence
27135 + pax_force_retaddr
27136 ret
27137
27138 .section .fixup,"ax"
27139 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27140 index 2419d5f..953ee51 100644
27141 --- a/arch/x86/lib/csum-copy_64.S
27142 +++ b/arch/x86/lib/csum-copy_64.S
27143 @@ -9,6 +9,7 @@
27144 #include <asm/dwarf2.h>
27145 #include <asm/errno.h>
27146 #include <asm/asm.h>
27147 +#include <asm/alternative-asm.h>
27148
27149 /*
27150 * Checksum copy with exception handling.
27151 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27152 CFI_RESTORE rbp
27153 addq $7*8, %rsp
27154 CFI_ADJUST_CFA_OFFSET -7*8
27155 + pax_force_retaddr 0, 1
27156 ret
27157 CFI_RESTORE_STATE
27158
27159 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27160 index 25b7ae8..c40113e 100644
27161 --- a/arch/x86/lib/csum-wrappers_64.c
27162 +++ b/arch/x86/lib/csum-wrappers_64.c
27163 @@ -52,8 +52,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27164 len -= 2;
27165 }
27166 }
27167 - isum = csum_partial_copy_generic((__force const void *)src,
27168 + pax_open_userland();
27169 + stac();
27170 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27171 dst, len, isum, errp, NULL);
27172 + clac();
27173 + pax_close_userland();
27174 if (unlikely(*errp))
27175 goto out_err;
27176
27177 @@ -105,8 +109,13 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27178 }
27179
27180 *errp = 0;
27181 - return csum_partial_copy_generic(src, (void __force *)dst,
27182 + pax_open_userland();
27183 + stac();
27184 + isum = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27185 len, isum, NULL, errp);
27186 + clac();
27187 + pax_close_userland();
27188 + return isum;
27189 }
27190 EXPORT_SYMBOL(csum_partial_copy_to_user);
27191
27192 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
27193 index a451235..1daa956 100644
27194 --- a/arch/x86/lib/getuser.S
27195 +++ b/arch/x86/lib/getuser.S
27196 @@ -33,17 +33,40 @@
27197 #include <asm/thread_info.h>
27198 #include <asm/asm.h>
27199 #include <asm/smap.h>
27200 +#include <asm/segment.h>
27201 +#include <asm/pgtable.h>
27202 +#include <asm/alternative-asm.h>
27203 +
27204 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27205 +#define __copyuser_seg gs;
27206 +#else
27207 +#define __copyuser_seg
27208 +#endif
27209
27210 .text
27211 ENTRY(__get_user_1)
27212 CFI_STARTPROC
27213 +
27214 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27215 GET_THREAD_INFO(%_ASM_DX)
27216 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27217 jae bad_get_user
27218 ASM_STAC
27219 -1: movzbl (%_ASM_AX),%edx
27220 +
27221 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27222 + mov pax_user_shadow_base,%_ASM_DX
27223 + cmp %_ASM_DX,%_ASM_AX
27224 + jae 1234f
27225 + add %_ASM_DX,%_ASM_AX
27226 +1234:
27227 +#endif
27228 +
27229 +#endif
27230 +
27231 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
27232 xor %eax,%eax
27233 ASM_CLAC
27234 + pax_force_retaddr
27235 ret
27236 CFI_ENDPROC
27237 ENDPROC(__get_user_1)
27238 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
27239 ENTRY(__get_user_2)
27240 CFI_STARTPROC
27241 add $1,%_ASM_AX
27242 +
27243 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27244 jc bad_get_user
27245 GET_THREAD_INFO(%_ASM_DX)
27246 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27247 jae bad_get_user
27248 ASM_STAC
27249 -2: movzwl -1(%_ASM_AX),%edx
27250 +
27251 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27252 + mov pax_user_shadow_base,%_ASM_DX
27253 + cmp %_ASM_DX,%_ASM_AX
27254 + jae 1234f
27255 + add %_ASM_DX,%_ASM_AX
27256 +1234:
27257 +#endif
27258 +
27259 +#endif
27260 +
27261 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
27262 xor %eax,%eax
27263 ASM_CLAC
27264 + pax_force_retaddr
27265 ret
27266 CFI_ENDPROC
27267 ENDPROC(__get_user_2)
27268 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
27269 ENTRY(__get_user_4)
27270 CFI_STARTPROC
27271 add $3,%_ASM_AX
27272 +
27273 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27274 jc bad_get_user
27275 GET_THREAD_INFO(%_ASM_DX)
27276 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27277 jae bad_get_user
27278 ASM_STAC
27279 -3: movl -3(%_ASM_AX),%edx
27280 +
27281 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27282 + mov pax_user_shadow_base,%_ASM_DX
27283 + cmp %_ASM_DX,%_ASM_AX
27284 + jae 1234f
27285 + add %_ASM_DX,%_ASM_AX
27286 +1234:
27287 +#endif
27288 +
27289 +#endif
27290 +
27291 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
27292 xor %eax,%eax
27293 ASM_CLAC
27294 + pax_force_retaddr
27295 ret
27296 CFI_ENDPROC
27297 ENDPROC(__get_user_4)
27298 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
27299 GET_THREAD_INFO(%_ASM_DX)
27300 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27301 jae bad_get_user
27302 +
27303 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27304 + mov pax_user_shadow_base,%_ASM_DX
27305 + cmp %_ASM_DX,%_ASM_AX
27306 + jae 1234f
27307 + add %_ASM_DX,%_ASM_AX
27308 +1234:
27309 +#endif
27310 +
27311 ASM_STAC
27312 4: movq -7(%_ASM_AX),%rdx
27313 xor %eax,%eax
27314 ASM_CLAC
27315 + pax_force_retaddr
27316 ret
27317 #else
27318 add $7,%_ASM_AX
27319 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
27320 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27321 jae bad_get_user_8
27322 ASM_STAC
27323 -4: movl -7(%_ASM_AX),%edx
27324 -5: movl -3(%_ASM_AX),%ecx
27325 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
27326 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
27327 xor %eax,%eax
27328 ASM_CLAC
27329 + pax_force_retaddr
27330 ret
27331 #endif
27332 CFI_ENDPROC
27333 @@ -113,6 +175,7 @@ bad_get_user:
27334 xor %edx,%edx
27335 mov $(-EFAULT),%_ASM_AX
27336 ASM_CLAC
27337 + pax_force_retaddr
27338 ret
27339 CFI_ENDPROC
27340 END(bad_get_user)
27341 @@ -124,6 +187,7 @@ bad_get_user_8:
27342 xor %ecx,%ecx
27343 mov $(-EFAULT),%_ASM_AX
27344 ASM_CLAC
27345 + pax_force_retaddr
27346 ret
27347 CFI_ENDPROC
27348 END(bad_get_user_8)
27349 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
27350 index 54fcffe..7be149e 100644
27351 --- a/arch/x86/lib/insn.c
27352 +++ b/arch/x86/lib/insn.c
27353 @@ -20,8 +20,10 @@
27354
27355 #ifdef __KERNEL__
27356 #include <linux/string.h>
27357 +#include <asm/pgtable_types.h>
27358 #else
27359 #include <string.h>
27360 +#define ktla_ktva(addr) addr
27361 #endif
27362 #include <asm/inat.h>
27363 #include <asm/insn.h>
27364 @@ -53,8 +55,8 @@
27365 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
27366 {
27367 memset(insn, 0, sizeof(*insn));
27368 - insn->kaddr = kaddr;
27369 - insn->next_byte = kaddr;
27370 + insn->kaddr = ktla_ktva(kaddr);
27371 + insn->next_byte = ktla_ktva(kaddr);
27372 insn->x86_64 = x86_64 ? 1 : 0;
27373 insn->opnd_bytes = 4;
27374 if (x86_64)
27375 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
27376 index 05a95e7..326f2fa 100644
27377 --- a/arch/x86/lib/iomap_copy_64.S
27378 +++ b/arch/x86/lib/iomap_copy_64.S
27379 @@ -17,6 +17,7 @@
27380
27381 #include <linux/linkage.h>
27382 #include <asm/dwarf2.h>
27383 +#include <asm/alternative-asm.h>
27384
27385 /*
27386 * override generic version in lib/iomap_copy.c
27387 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
27388 CFI_STARTPROC
27389 movl %edx,%ecx
27390 rep movsd
27391 + pax_force_retaddr
27392 ret
27393 CFI_ENDPROC
27394 ENDPROC(__iowrite32_copy)
27395 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
27396 index 56313a3..9b59269 100644
27397 --- a/arch/x86/lib/memcpy_64.S
27398 +++ b/arch/x86/lib/memcpy_64.S
27399 @@ -24,7 +24,7 @@
27400 * This gets patched over the unrolled variant (below) via the
27401 * alternative instructions framework:
27402 */
27403 - .section .altinstr_replacement, "ax", @progbits
27404 + .section .altinstr_replacement, "a", @progbits
27405 .Lmemcpy_c:
27406 movq %rdi, %rax
27407 movq %rdx, %rcx
27408 @@ -33,6 +33,7 @@
27409 rep movsq
27410 movl %edx, %ecx
27411 rep movsb
27412 + pax_force_retaddr
27413 ret
27414 .Lmemcpy_e:
27415 .previous
27416 @@ -44,11 +45,12 @@
27417 * This gets patched over the unrolled variant (below) via the
27418 * alternative instructions framework:
27419 */
27420 - .section .altinstr_replacement, "ax", @progbits
27421 + .section .altinstr_replacement, "a", @progbits
27422 .Lmemcpy_c_e:
27423 movq %rdi, %rax
27424 movq %rdx, %rcx
27425 rep movsb
27426 + pax_force_retaddr
27427 ret
27428 .Lmemcpy_e_e:
27429 .previous
27430 @@ -76,13 +78,13 @@ ENTRY(memcpy)
27431 */
27432 movq 0*8(%rsi), %r8
27433 movq 1*8(%rsi), %r9
27434 - movq 2*8(%rsi), %r10
27435 + movq 2*8(%rsi), %rcx
27436 movq 3*8(%rsi), %r11
27437 leaq 4*8(%rsi), %rsi
27438
27439 movq %r8, 0*8(%rdi)
27440 movq %r9, 1*8(%rdi)
27441 - movq %r10, 2*8(%rdi)
27442 + movq %rcx, 2*8(%rdi)
27443 movq %r11, 3*8(%rdi)
27444 leaq 4*8(%rdi), %rdi
27445 jae .Lcopy_forward_loop
27446 @@ -105,12 +107,12 @@ ENTRY(memcpy)
27447 subq $0x20, %rdx
27448 movq -1*8(%rsi), %r8
27449 movq -2*8(%rsi), %r9
27450 - movq -3*8(%rsi), %r10
27451 + movq -3*8(%rsi), %rcx
27452 movq -4*8(%rsi), %r11
27453 leaq -4*8(%rsi), %rsi
27454 movq %r8, -1*8(%rdi)
27455 movq %r9, -2*8(%rdi)
27456 - movq %r10, -3*8(%rdi)
27457 + movq %rcx, -3*8(%rdi)
27458 movq %r11, -4*8(%rdi)
27459 leaq -4*8(%rdi), %rdi
27460 jae .Lcopy_backward_loop
27461 @@ -130,12 +132,13 @@ ENTRY(memcpy)
27462 */
27463 movq 0*8(%rsi), %r8
27464 movq 1*8(%rsi), %r9
27465 - movq -2*8(%rsi, %rdx), %r10
27466 + movq -2*8(%rsi, %rdx), %rcx
27467 movq -1*8(%rsi, %rdx), %r11
27468 movq %r8, 0*8(%rdi)
27469 movq %r9, 1*8(%rdi)
27470 - movq %r10, -2*8(%rdi, %rdx)
27471 + movq %rcx, -2*8(%rdi, %rdx)
27472 movq %r11, -1*8(%rdi, %rdx)
27473 + pax_force_retaddr
27474 retq
27475 .p2align 4
27476 .Lless_16bytes:
27477 @@ -148,6 +151,7 @@ ENTRY(memcpy)
27478 movq -1*8(%rsi, %rdx), %r9
27479 movq %r8, 0*8(%rdi)
27480 movq %r9, -1*8(%rdi, %rdx)
27481 + pax_force_retaddr
27482 retq
27483 .p2align 4
27484 .Lless_8bytes:
27485 @@ -161,6 +165,7 @@ ENTRY(memcpy)
27486 movl -4(%rsi, %rdx), %r8d
27487 movl %ecx, (%rdi)
27488 movl %r8d, -4(%rdi, %rdx)
27489 + pax_force_retaddr
27490 retq
27491 .p2align 4
27492 .Lless_3bytes:
27493 @@ -179,6 +184,7 @@ ENTRY(memcpy)
27494 movb %cl, (%rdi)
27495
27496 .Lend:
27497 + pax_force_retaddr
27498 retq
27499 CFI_ENDPROC
27500 ENDPROC(memcpy)
27501 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
27502 index 65268a6..5aa7815 100644
27503 --- a/arch/x86/lib/memmove_64.S
27504 +++ b/arch/x86/lib/memmove_64.S
27505 @@ -61,13 +61,13 @@ ENTRY(memmove)
27506 5:
27507 sub $0x20, %rdx
27508 movq 0*8(%rsi), %r11
27509 - movq 1*8(%rsi), %r10
27510 + movq 1*8(%rsi), %rcx
27511 movq 2*8(%rsi), %r9
27512 movq 3*8(%rsi), %r8
27513 leaq 4*8(%rsi), %rsi
27514
27515 movq %r11, 0*8(%rdi)
27516 - movq %r10, 1*8(%rdi)
27517 + movq %rcx, 1*8(%rdi)
27518 movq %r9, 2*8(%rdi)
27519 movq %r8, 3*8(%rdi)
27520 leaq 4*8(%rdi), %rdi
27521 @@ -81,10 +81,10 @@ ENTRY(memmove)
27522 4:
27523 movq %rdx, %rcx
27524 movq -8(%rsi, %rdx), %r11
27525 - lea -8(%rdi, %rdx), %r10
27526 + lea -8(%rdi, %rdx), %r9
27527 shrq $3, %rcx
27528 rep movsq
27529 - movq %r11, (%r10)
27530 + movq %r11, (%r9)
27531 jmp 13f
27532 .Lmemmove_end_forward:
27533
27534 @@ -95,14 +95,14 @@ ENTRY(memmove)
27535 7:
27536 movq %rdx, %rcx
27537 movq (%rsi), %r11
27538 - movq %rdi, %r10
27539 + movq %rdi, %r9
27540 leaq -8(%rsi, %rdx), %rsi
27541 leaq -8(%rdi, %rdx), %rdi
27542 shrq $3, %rcx
27543 std
27544 rep movsq
27545 cld
27546 - movq %r11, (%r10)
27547 + movq %r11, (%r9)
27548 jmp 13f
27549
27550 /*
27551 @@ -127,13 +127,13 @@ ENTRY(memmove)
27552 8:
27553 subq $0x20, %rdx
27554 movq -1*8(%rsi), %r11
27555 - movq -2*8(%rsi), %r10
27556 + movq -2*8(%rsi), %rcx
27557 movq -3*8(%rsi), %r9
27558 movq -4*8(%rsi), %r8
27559 leaq -4*8(%rsi), %rsi
27560
27561 movq %r11, -1*8(%rdi)
27562 - movq %r10, -2*8(%rdi)
27563 + movq %rcx, -2*8(%rdi)
27564 movq %r9, -3*8(%rdi)
27565 movq %r8, -4*8(%rdi)
27566 leaq -4*8(%rdi), %rdi
27567 @@ -151,11 +151,11 @@ ENTRY(memmove)
27568 * Move data from 16 bytes to 31 bytes.
27569 */
27570 movq 0*8(%rsi), %r11
27571 - movq 1*8(%rsi), %r10
27572 + movq 1*8(%rsi), %rcx
27573 movq -2*8(%rsi, %rdx), %r9
27574 movq -1*8(%rsi, %rdx), %r8
27575 movq %r11, 0*8(%rdi)
27576 - movq %r10, 1*8(%rdi)
27577 + movq %rcx, 1*8(%rdi)
27578 movq %r9, -2*8(%rdi, %rdx)
27579 movq %r8, -1*8(%rdi, %rdx)
27580 jmp 13f
27581 @@ -167,9 +167,9 @@ ENTRY(memmove)
27582 * Move data from 8 bytes to 15 bytes.
27583 */
27584 movq 0*8(%rsi), %r11
27585 - movq -1*8(%rsi, %rdx), %r10
27586 + movq -1*8(%rsi, %rdx), %r9
27587 movq %r11, 0*8(%rdi)
27588 - movq %r10, -1*8(%rdi, %rdx)
27589 + movq %r9, -1*8(%rdi, %rdx)
27590 jmp 13f
27591 10:
27592 cmpq $4, %rdx
27593 @@ -178,9 +178,9 @@ ENTRY(memmove)
27594 * Move data from 4 bytes to 7 bytes.
27595 */
27596 movl (%rsi), %r11d
27597 - movl -4(%rsi, %rdx), %r10d
27598 + movl -4(%rsi, %rdx), %r9d
27599 movl %r11d, (%rdi)
27600 - movl %r10d, -4(%rdi, %rdx)
27601 + movl %r9d, -4(%rdi, %rdx)
27602 jmp 13f
27603 11:
27604 cmp $2, %rdx
27605 @@ -189,9 +189,9 @@ ENTRY(memmove)
27606 * Move data from 2 bytes to 3 bytes.
27607 */
27608 movw (%rsi), %r11w
27609 - movw -2(%rsi, %rdx), %r10w
27610 + movw -2(%rsi, %rdx), %r9w
27611 movw %r11w, (%rdi)
27612 - movw %r10w, -2(%rdi, %rdx)
27613 + movw %r9w, -2(%rdi, %rdx)
27614 jmp 13f
27615 12:
27616 cmp $1, %rdx
27617 @@ -202,14 +202,16 @@ ENTRY(memmove)
27618 movb (%rsi), %r11b
27619 movb %r11b, (%rdi)
27620 13:
27621 + pax_force_retaddr
27622 retq
27623 CFI_ENDPROC
27624
27625 - .section .altinstr_replacement,"ax"
27626 + .section .altinstr_replacement,"a"
27627 .Lmemmove_begin_forward_efs:
27628 /* Forward moving data. */
27629 movq %rdx, %rcx
27630 rep movsb
27631 + pax_force_retaddr
27632 retq
27633 .Lmemmove_end_forward_efs:
27634 .previous
27635 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
27636 index 2dcb380..50a78bc 100644
27637 --- a/arch/x86/lib/memset_64.S
27638 +++ b/arch/x86/lib/memset_64.S
27639 @@ -16,7 +16,7 @@
27640 *
27641 * rax original destination
27642 */
27643 - .section .altinstr_replacement, "ax", @progbits
27644 + .section .altinstr_replacement, "a", @progbits
27645 .Lmemset_c:
27646 movq %rdi,%r9
27647 movq %rdx,%rcx
27648 @@ -30,6 +30,7 @@
27649 movl %edx,%ecx
27650 rep stosb
27651 movq %r9,%rax
27652 + pax_force_retaddr
27653 ret
27654 .Lmemset_e:
27655 .previous
27656 @@ -45,13 +46,14 @@
27657 *
27658 * rax original destination
27659 */
27660 - .section .altinstr_replacement, "ax", @progbits
27661 + .section .altinstr_replacement, "a", @progbits
27662 .Lmemset_c_e:
27663 movq %rdi,%r9
27664 movb %sil,%al
27665 movq %rdx,%rcx
27666 rep stosb
27667 movq %r9,%rax
27668 + pax_force_retaddr
27669 ret
27670 .Lmemset_e_e:
27671 .previous
27672 @@ -59,7 +61,7 @@
27673 ENTRY(memset)
27674 ENTRY(__memset)
27675 CFI_STARTPROC
27676 - movq %rdi,%r10
27677 + movq %rdi,%r11
27678
27679 /* expand byte value */
27680 movzbl %sil,%ecx
27681 @@ -117,7 +119,8 @@ ENTRY(__memset)
27682 jnz .Lloop_1
27683
27684 .Lende:
27685 - movq %r10,%rax
27686 + movq %r11,%rax
27687 + pax_force_retaddr
27688 ret
27689
27690 CFI_RESTORE_STATE
27691 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
27692 index c9f2d9b..e7fd2c0 100644
27693 --- a/arch/x86/lib/mmx_32.c
27694 +++ b/arch/x86/lib/mmx_32.c
27695 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
27696 {
27697 void *p;
27698 int i;
27699 + unsigned long cr0;
27700
27701 if (unlikely(in_interrupt()))
27702 return __memcpy(to, from, len);
27703 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
27704 kernel_fpu_begin();
27705
27706 __asm__ __volatile__ (
27707 - "1: prefetch (%0)\n" /* This set is 28 bytes */
27708 - " prefetch 64(%0)\n"
27709 - " prefetch 128(%0)\n"
27710 - " prefetch 192(%0)\n"
27711 - " prefetch 256(%0)\n"
27712 + "1: prefetch (%1)\n" /* This set is 28 bytes */
27713 + " prefetch 64(%1)\n"
27714 + " prefetch 128(%1)\n"
27715 + " prefetch 192(%1)\n"
27716 + " prefetch 256(%1)\n"
27717 "2: \n"
27718 ".section .fixup, \"ax\"\n"
27719 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27720 + "3: \n"
27721 +
27722 +#ifdef CONFIG_PAX_KERNEXEC
27723 + " movl %%cr0, %0\n"
27724 + " movl %0, %%eax\n"
27725 + " andl $0xFFFEFFFF, %%eax\n"
27726 + " movl %%eax, %%cr0\n"
27727 +#endif
27728 +
27729 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27730 +
27731 +#ifdef CONFIG_PAX_KERNEXEC
27732 + " movl %0, %%cr0\n"
27733 +#endif
27734 +
27735 " jmp 2b\n"
27736 ".previous\n"
27737 _ASM_EXTABLE(1b, 3b)
27738 - : : "r" (from));
27739 + : "=&r" (cr0) : "r" (from) : "ax");
27740
27741 for ( ; i > 5; i--) {
27742 __asm__ __volatile__ (
27743 - "1: prefetch 320(%0)\n"
27744 - "2: movq (%0), %%mm0\n"
27745 - " movq 8(%0), %%mm1\n"
27746 - " movq 16(%0), %%mm2\n"
27747 - " movq 24(%0), %%mm3\n"
27748 - " movq %%mm0, (%1)\n"
27749 - " movq %%mm1, 8(%1)\n"
27750 - " movq %%mm2, 16(%1)\n"
27751 - " movq %%mm3, 24(%1)\n"
27752 - " movq 32(%0), %%mm0\n"
27753 - " movq 40(%0), %%mm1\n"
27754 - " movq 48(%0), %%mm2\n"
27755 - " movq 56(%0), %%mm3\n"
27756 - " movq %%mm0, 32(%1)\n"
27757 - " movq %%mm1, 40(%1)\n"
27758 - " movq %%mm2, 48(%1)\n"
27759 - " movq %%mm3, 56(%1)\n"
27760 + "1: prefetch 320(%1)\n"
27761 + "2: movq (%1), %%mm0\n"
27762 + " movq 8(%1), %%mm1\n"
27763 + " movq 16(%1), %%mm2\n"
27764 + " movq 24(%1), %%mm3\n"
27765 + " movq %%mm0, (%2)\n"
27766 + " movq %%mm1, 8(%2)\n"
27767 + " movq %%mm2, 16(%2)\n"
27768 + " movq %%mm3, 24(%2)\n"
27769 + " movq 32(%1), %%mm0\n"
27770 + " movq 40(%1), %%mm1\n"
27771 + " movq 48(%1), %%mm2\n"
27772 + " movq 56(%1), %%mm3\n"
27773 + " movq %%mm0, 32(%2)\n"
27774 + " movq %%mm1, 40(%2)\n"
27775 + " movq %%mm2, 48(%2)\n"
27776 + " movq %%mm3, 56(%2)\n"
27777 ".section .fixup, \"ax\"\n"
27778 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27779 + "3:\n"
27780 +
27781 +#ifdef CONFIG_PAX_KERNEXEC
27782 + " movl %%cr0, %0\n"
27783 + " movl %0, %%eax\n"
27784 + " andl $0xFFFEFFFF, %%eax\n"
27785 + " movl %%eax, %%cr0\n"
27786 +#endif
27787 +
27788 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27789 +
27790 +#ifdef CONFIG_PAX_KERNEXEC
27791 + " movl %0, %%cr0\n"
27792 +#endif
27793 +
27794 " jmp 2b\n"
27795 ".previous\n"
27796 _ASM_EXTABLE(1b, 3b)
27797 - : : "r" (from), "r" (to) : "memory");
27798 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
27799
27800 from += 64;
27801 to += 64;
27802 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
27803 static void fast_copy_page(void *to, void *from)
27804 {
27805 int i;
27806 + unsigned long cr0;
27807
27808 kernel_fpu_begin();
27809
27810 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
27811 * but that is for later. -AV
27812 */
27813 __asm__ __volatile__(
27814 - "1: prefetch (%0)\n"
27815 - " prefetch 64(%0)\n"
27816 - " prefetch 128(%0)\n"
27817 - " prefetch 192(%0)\n"
27818 - " prefetch 256(%0)\n"
27819 + "1: prefetch (%1)\n"
27820 + " prefetch 64(%1)\n"
27821 + " prefetch 128(%1)\n"
27822 + " prefetch 192(%1)\n"
27823 + " prefetch 256(%1)\n"
27824 "2: \n"
27825 ".section .fixup, \"ax\"\n"
27826 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27827 + "3: \n"
27828 +
27829 +#ifdef CONFIG_PAX_KERNEXEC
27830 + " movl %%cr0, %0\n"
27831 + " movl %0, %%eax\n"
27832 + " andl $0xFFFEFFFF, %%eax\n"
27833 + " movl %%eax, %%cr0\n"
27834 +#endif
27835 +
27836 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27837 +
27838 +#ifdef CONFIG_PAX_KERNEXEC
27839 + " movl %0, %%cr0\n"
27840 +#endif
27841 +
27842 " jmp 2b\n"
27843 ".previous\n"
27844 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
27845 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
27846
27847 for (i = 0; i < (4096-320)/64; i++) {
27848 __asm__ __volatile__ (
27849 - "1: prefetch 320(%0)\n"
27850 - "2: movq (%0), %%mm0\n"
27851 - " movntq %%mm0, (%1)\n"
27852 - " movq 8(%0), %%mm1\n"
27853 - " movntq %%mm1, 8(%1)\n"
27854 - " movq 16(%0), %%mm2\n"
27855 - " movntq %%mm2, 16(%1)\n"
27856 - " movq 24(%0), %%mm3\n"
27857 - " movntq %%mm3, 24(%1)\n"
27858 - " movq 32(%0), %%mm4\n"
27859 - " movntq %%mm4, 32(%1)\n"
27860 - " movq 40(%0), %%mm5\n"
27861 - " movntq %%mm5, 40(%1)\n"
27862 - " movq 48(%0), %%mm6\n"
27863 - " movntq %%mm6, 48(%1)\n"
27864 - " movq 56(%0), %%mm7\n"
27865 - " movntq %%mm7, 56(%1)\n"
27866 + "1: prefetch 320(%1)\n"
27867 + "2: movq (%1), %%mm0\n"
27868 + " movntq %%mm0, (%2)\n"
27869 + " movq 8(%1), %%mm1\n"
27870 + " movntq %%mm1, 8(%2)\n"
27871 + " movq 16(%1), %%mm2\n"
27872 + " movntq %%mm2, 16(%2)\n"
27873 + " movq 24(%1), %%mm3\n"
27874 + " movntq %%mm3, 24(%2)\n"
27875 + " movq 32(%1), %%mm4\n"
27876 + " movntq %%mm4, 32(%2)\n"
27877 + " movq 40(%1), %%mm5\n"
27878 + " movntq %%mm5, 40(%2)\n"
27879 + " movq 48(%1), %%mm6\n"
27880 + " movntq %%mm6, 48(%2)\n"
27881 + " movq 56(%1), %%mm7\n"
27882 + " movntq %%mm7, 56(%2)\n"
27883 ".section .fixup, \"ax\"\n"
27884 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27885 + "3:\n"
27886 +
27887 +#ifdef CONFIG_PAX_KERNEXEC
27888 + " movl %%cr0, %0\n"
27889 + " movl %0, %%eax\n"
27890 + " andl $0xFFFEFFFF, %%eax\n"
27891 + " movl %%eax, %%cr0\n"
27892 +#endif
27893 +
27894 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27895 +
27896 +#ifdef CONFIG_PAX_KERNEXEC
27897 + " movl %0, %%cr0\n"
27898 +#endif
27899 +
27900 " jmp 2b\n"
27901 ".previous\n"
27902 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
27903 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
27904
27905 from += 64;
27906 to += 64;
27907 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
27908 static void fast_copy_page(void *to, void *from)
27909 {
27910 int i;
27911 + unsigned long cr0;
27912
27913 kernel_fpu_begin();
27914
27915 __asm__ __volatile__ (
27916 - "1: prefetch (%0)\n"
27917 - " prefetch 64(%0)\n"
27918 - " prefetch 128(%0)\n"
27919 - " prefetch 192(%0)\n"
27920 - " prefetch 256(%0)\n"
27921 + "1: prefetch (%1)\n"
27922 + " prefetch 64(%1)\n"
27923 + " prefetch 128(%1)\n"
27924 + " prefetch 192(%1)\n"
27925 + " prefetch 256(%1)\n"
27926 "2: \n"
27927 ".section .fixup, \"ax\"\n"
27928 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27929 + "3: \n"
27930 +
27931 +#ifdef CONFIG_PAX_KERNEXEC
27932 + " movl %%cr0, %0\n"
27933 + " movl %0, %%eax\n"
27934 + " andl $0xFFFEFFFF, %%eax\n"
27935 + " movl %%eax, %%cr0\n"
27936 +#endif
27937 +
27938 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27939 +
27940 +#ifdef CONFIG_PAX_KERNEXEC
27941 + " movl %0, %%cr0\n"
27942 +#endif
27943 +
27944 " jmp 2b\n"
27945 ".previous\n"
27946 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
27947 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
27948
27949 for (i = 0; i < 4096/64; i++) {
27950 __asm__ __volatile__ (
27951 - "1: prefetch 320(%0)\n"
27952 - "2: movq (%0), %%mm0\n"
27953 - " movq 8(%0), %%mm1\n"
27954 - " movq 16(%0), %%mm2\n"
27955 - " movq 24(%0), %%mm3\n"
27956 - " movq %%mm0, (%1)\n"
27957 - " movq %%mm1, 8(%1)\n"
27958 - " movq %%mm2, 16(%1)\n"
27959 - " movq %%mm3, 24(%1)\n"
27960 - " movq 32(%0), %%mm0\n"
27961 - " movq 40(%0), %%mm1\n"
27962 - " movq 48(%0), %%mm2\n"
27963 - " movq 56(%0), %%mm3\n"
27964 - " movq %%mm0, 32(%1)\n"
27965 - " movq %%mm1, 40(%1)\n"
27966 - " movq %%mm2, 48(%1)\n"
27967 - " movq %%mm3, 56(%1)\n"
27968 + "1: prefetch 320(%1)\n"
27969 + "2: movq (%1), %%mm0\n"
27970 + " movq 8(%1), %%mm1\n"
27971 + " movq 16(%1), %%mm2\n"
27972 + " movq 24(%1), %%mm3\n"
27973 + " movq %%mm0, (%2)\n"
27974 + " movq %%mm1, 8(%2)\n"
27975 + " movq %%mm2, 16(%2)\n"
27976 + " movq %%mm3, 24(%2)\n"
27977 + " movq 32(%1), %%mm0\n"
27978 + " movq 40(%1), %%mm1\n"
27979 + " movq 48(%1), %%mm2\n"
27980 + " movq 56(%1), %%mm3\n"
27981 + " movq %%mm0, 32(%2)\n"
27982 + " movq %%mm1, 40(%2)\n"
27983 + " movq %%mm2, 48(%2)\n"
27984 + " movq %%mm3, 56(%2)\n"
27985 ".section .fixup, \"ax\"\n"
27986 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27987 + "3:\n"
27988 +
27989 +#ifdef CONFIG_PAX_KERNEXEC
27990 + " movl %%cr0, %0\n"
27991 + " movl %0, %%eax\n"
27992 + " andl $0xFFFEFFFF, %%eax\n"
27993 + " movl %%eax, %%cr0\n"
27994 +#endif
27995 +
27996 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27997 +
27998 +#ifdef CONFIG_PAX_KERNEXEC
27999 + " movl %0, %%cr0\n"
28000 +#endif
28001 +
28002 " jmp 2b\n"
28003 ".previous\n"
28004 _ASM_EXTABLE(1b, 3b)
28005 - : : "r" (from), "r" (to) : "memory");
28006 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28007
28008 from += 64;
28009 to += 64;
28010 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28011 index f6d13ee..aca5f0b 100644
28012 --- a/arch/x86/lib/msr-reg.S
28013 +++ b/arch/x86/lib/msr-reg.S
28014 @@ -3,6 +3,7 @@
28015 #include <asm/dwarf2.h>
28016 #include <asm/asm.h>
28017 #include <asm/msr.h>
28018 +#include <asm/alternative-asm.h>
28019
28020 #ifdef CONFIG_X86_64
28021 /*
28022 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28023 CFI_STARTPROC
28024 pushq_cfi %rbx
28025 pushq_cfi %rbp
28026 - movq %rdi, %r10 /* Save pointer */
28027 + movq %rdi, %r9 /* Save pointer */
28028 xorl %r11d, %r11d /* Return value */
28029 movl (%rdi), %eax
28030 movl 4(%rdi), %ecx
28031 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28032 movl 28(%rdi), %edi
28033 CFI_REMEMBER_STATE
28034 1: \op
28035 -2: movl %eax, (%r10)
28036 +2: movl %eax, (%r9)
28037 movl %r11d, %eax /* Return value */
28038 - movl %ecx, 4(%r10)
28039 - movl %edx, 8(%r10)
28040 - movl %ebx, 12(%r10)
28041 - movl %ebp, 20(%r10)
28042 - movl %esi, 24(%r10)
28043 - movl %edi, 28(%r10)
28044 + movl %ecx, 4(%r9)
28045 + movl %edx, 8(%r9)
28046 + movl %ebx, 12(%r9)
28047 + movl %ebp, 20(%r9)
28048 + movl %esi, 24(%r9)
28049 + movl %edi, 28(%r9)
28050 popq_cfi %rbp
28051 popq_cfi %rbx
28052 + pax_force_retaddr
28053 ret
28054 3:
28055 CFI_RESTORE_STATE
28056 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28057 index fc6ba17..d4d989d 100644
28058 --- a/arch/x86/lib/putuser.S
28059 +++ b/arch/x86/lib/putuser.S
28060 @@ -16,7 +16,9 @@
28061 #include <asm/errno.h>
28062 #include <asm/asm.h>
28063 #include <asm/smap.h>
28064 -
28065 +#include <asm/segment.h>
28066 +#include <asm/pgtable.h>
28067 +#include <asm/alternative-asm.h>
28068
28069 /*
28070 * __put_user_X
28071 @@ -30,57 +32,125 @@
28072 * as they get called from within inline assembly.
28073 */
28074
28075 -#define ENTER CFI_STARTPROC ; \
28076 - GET_THREAD_INFO(%_ASM_BX)
28077 -#define EXIT ASM_CLAC ; \
28078 - ret ; \
28079 +#define ENTER CFI_STARTPROC
28080 +#define EXIT ASM_CLAC ; \
28081 + pax_force_retaddr ; \
28082 + ret ; \
28083 CFI_ENDPROC
28084
28085 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28086 +#define _DEST %_ASM_CX,%_ASM_BX
28087 +#else
28088 +#define _DEST %_ASM_CX
28089 +#endif
28090 +
28091 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28092 +#define __copyuser_seg gs;
28093 +#else
28094 +#define __copyuser_seg
28095 +#endif
28096 +
28097 .text
28098 ENTRY(__put_user_1)
28099 ENTER
28100 +
28101 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28102 + GET_THREAD_INFO(%_ASM_BX)
28103 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28104 jae bad_put_user
28105 ASM_STAC
28106 -1: movb %al,(%_ASM_CX)
28107 +
28108 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28109 + mov pax_user_shadow_base,%_ASM_BX
28110 + cmp %_ASM_BX,%_ASM_CX
28111 + jb 1234f
28112 + xor %ebx,%ebx
28113 +1234:
28114 +#endif
28115 +
28116 +#endif
28117 +
28118 +1: __copyuser_seg movb %al,(_DEST)
28119 xor %eax,%eax
28120 EXIT
28121 ENDPROC(__put_user_1)
28122
28123 ENTRY(__put_user_2)
28124 ENTER
28125 +
28126 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28127 + GET_THREAD_INFO(%_ASM_BX)
28128 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28129 sub $1,%_ASM_BX
28130 cmp %_ASM_BX,%_ASM_CX
28131 jae bad_put_user
28132 ASM_STAC
28133 -2: movw %ax,(%_ASM_CX)
28134 +
28135 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28136 + mov pax_user_shadow_base,%_ASM_BX
28137 + cmp %_ASM_BX,%_ASM_CX
28138 + jb 1234f
28139 + xor %ebx,%ebx
28140 +1234:
28141 +#endif
28142 +
28143 +#endif
28144 +
28145 +2: __copyuser_seg movw %ax,(_DEST)
28146 xor %eax,%eax
28147 EXIT
28148 ENDPROC(__put_user_2)
28149
28150 ENTRY(__put_user_4)
28151 ENTER
28152 +
28153 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28154 + GET_THREAD_INFO(%_ASM_BX)
28155 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28156 sub $3,%_ASM_BX
28157 cmp %_ASM_BX,%_ASM_CX
28158 jae bad_put_user
28159 ASM_STAC
28160 -3: movl %eax,(%_ASM_CX)
28161 +
28162 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28163 + mov pax_user_shadow_base,%_ASM_BX
28164 + cmp %_ASM_BX,%_ASM_CX
28165 + jb 1234f
28166 + xor %ebx,%ebx
28167 +1234:
28168 +#endif
28169 +
28170 +#endif
28171 +
28172 +3: __copyuser_seg movl %eax,(_DEST)
28173 xor %eax,%eax
28174 EXIT
28175 ENDPROC(__put_user_4)
28176
28177 ENTRY(__put_user_8)
28178 ENTER
28179 +
28180 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28181 + GET_THREAD_INFO(%_ASM_BX)
28182 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28183 sub $7,%_ASM_BX
28184 cmp %_ASM_BX,%_ASM_CX
28185 jae bad_put_user
28186 ASM_STAC
28187 -4: mov %_ASM_AX,(%_ASM_CX)
28188 +
28189 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28190 + mov pax_user_shadow_base,%_ASM_BX
28191 + cmp %_ASM_BX,%_ASM_CX
28192 + jb 1234f
28193 + xor %ebx,%ebx
28194 +1234:
28195 +#endif
28196 +
28197 +#endif
28198 +
28199 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
28200 #ifdef CONFIG_X86_32
28201 -5: movl %edx,4(%_ASM_CX)
28202 +5: __copyuser_seg movl %edx,4(_DEST)
28203 #endif
28204 xor %eax,%eax
28205 EXIT
28206 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
28207 index 1cad221..de671ee 100644
28208 --- a/arch/x86/lib/rwlock.S
28209 +++ b/arch/x86/lib/rwlock.S
28210 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
28211 FRAME
28212 0: LOCK_PREFIX
28213 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
28214 +
28215 +#ifdef CONFIG_PAX_REFCOUNT
28216 + jno 1234f
28217 + LOCK_PREFIX
28218 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
28219 + int $4
28220 +1234:
28221 + _ASM_EXTABLE(1234b, 1234b)
28222 +#endif
28223 +
28224 1: rep; nop
28225 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
28226 jne 1b
28227 LOCK_PREFIX
28228 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
28229 +
28230 +#ifdef CONFIG_PAX_REFCOUNT
28231 + jno 1234f
28232 + LOCK_PREFIX
28233 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
28234 + int $4
28235 +1234:
28236 + _ASM_EXTABLE(1234b, 1234b)
28237 +#endif
28238 +
28239 jnz 0b
28240 ENDFRAME
28241 + pax_force_retaddr
28242 ret
28243 CFI_ENDPROC
28244 END(__write_lock_failed)
28245 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
28246 FRAME
28247 0: LOCK_PREFIX
28248 READ_LOCK_SIZE(inc) (%__lock_ptr)
28249 +
28250 +#ifdef CONFIG_PAX_REFCOUNT
28251 + jno 1234f
28252 + LOCK_PREFIX
28253 + READ_LOCK_SIZE(dec) (%__lock_ptr)
28254 + int $4
28255 +1234:
28256 + _ASM_EXTABLE(1234b, 1234b)
28257 +#endif
28258 +
28259 1: rep; nop
28260 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
28261 js 1b
28262 LOCK_PREFIX
28263 READ_LOCK_SIZE(dec) (%__lock_ptr)
28264 +
28265 +#ifdef CONFIG_PAX_REFCOUNT
28266 + jno 1234f
28267 + LOCK_PREFIX
28268 + READ_LOCK_SIZE(inc) (%__lock_ptr)
28269 + int $4
28270 +1234:
28271 + _ASM_EXTABLE(1234b, 1234b)
28272 +#endif
28273 +
28274 js 0b
28275 ENDFRAME
28276 + pax_force_retaddr
28277 ret
28278 CFI_ENDPROC
28279 END(__read_lock_failed)
28280 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
28281 index 5dff5f0..cadebf4 100644
28282 --- a/arch/x86/lib/rwsem.S
28283 +++ b/arch/x86/lib/rwsem.S
28284 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
28285 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
28286 CFI_RESTORE __ASM_REG(dx)
28287 restore_common_regs
28288 + pax_force_retaddr
28289 ret
28290 CFI_ENDPROC
28291 ENDPROC(call_rwsem_down_read_failed)
28292 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
28293 movq %rax,%rdi
28294 call rwsem_down_write_failed
28295 restore_common_regs
28296 + pax_force_retaddr
28297 ret
28298 CFI_ENDPROC
28299 ENDPROC(call_rwsem_down_write_failed)
28300 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
28301 movq %rax,%rdi
28302 call rwsem_wake
28303 restore_common_regs
28304 -1: ret
28305 +1: pax_force_retaddr
28306 + ret
28307 CFI_ENDPROC
28308 ENDPROC(call_rwsem_wake)
28309
28310 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
28311 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
28312 CFI_RESTORE __ASM_REG(dx)
28313 restore_common_regs
28314 + pax_force_retaddr
28315 ret
28316 CFI_ENDPROC
28317 ENDPROC(call_rwsem_downgrade_wake)
28318 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
28319 index a63efd6..ccecad8 100644
28320 --- a/arch/x86/lib/thunk_64.S
28321 +++ b/arch/x86/lib/thunk_64.S
28322 @@ -8,6 +8,7 @@
28323 #include <linux/linkage.h>
28324 #include <asm/dwarf2.h>
28325 #include <asm/calling.h>
28326 +#include <asm/alternative-asm.h>
28327
28328 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
28329 .macro THUNK name, func, put_ret_addr_in_rdi=0
28330 @@ -41,5 +42,6 @@
28331 SAVE_ARGS
28332 restore:
28333 RESTORE_ARGS
28334 + pax_force_retaddr
28335 ret
28336 CFI_ENDPROC
28337 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
28338 index 3eb18ac..6890bc3 100644
28339 --- a/arch/x86/lib/usercopy_32.c
28340 +++ b/arch/x86/lib/usercopy_32.c
28341 @@ -42,11 +42,13 @@ do { \
28342 int __d0; \
28343 might_fault(); \
28344 __asm__ __volatile__( \
28345 + __COPYUSER_SET_ES \
28346 ASM_STAC "\n" \
28347 "0: rep; stosl\n" \
28348 " movl %2,%0\n" \
28349 "1: rep; stosb\n" \
28350 "2: " ASM_CLAC "\n" \
28351 + __COPYUSER_RESTORE_ES \
28352 ".section .fixup,\"ax\"\n" \
28353 "3: lea 0(%2,%0,4),%0\n" \
28354 " jmp 2b\n" \
28355 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
28356
28357 #ifdef CONFIG_X86_INTEL_USERCOPY
28358 static unsigned long
28359 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
28360 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
28361 {
28362 int d0, d1;
28363 __asm__ __volatile__(
28364 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
28365 " .align 2,0x90\n"
28366 "3: movl 0(%4), %%eax\n"
28367 "4: movl 4(%4), %%edx\n"
28368 - "5: movl %%eax, 0(%3)\n"
28369 - "6: movl %%edx, 4(%3)\n"
28370 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
28371 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
28372 "7: movl 8(%4), %%eax\n"
28373 "8: movl 12(%4),%%edx\n"
28374 - "9: movl %%eax, 8(%3)\n"
28375 - "10: movl %%edx, 12(%3)\n"
28376 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
28377 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
28378 "11: movl 16(%4), %%eax\n"
28379 "12: movl 20(%4), %%edx\n"
28380 - "13: movl %%eax, 16(%3)\n"
28381 - "14: movl %%edx, 20(%3)\n"
28382 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
28383 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
28384 "15: movl 24(%4), %%eax\n"
28385 "16: movl 28(%4), %%edx\n"
28386 - "17: movl %%eax, 24(%3)\n"
28387 - "18: movl %%edx, 28(%3)\n"
28388 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
28389 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
28390 "19: movl 32(%4), %%eax\n"
28391 "20: movl 36(%4), %%edx\n"
28392 - "21: movl %%eax, 32(%3)\n"
28393 - "22: movl %%edx, 36(%3)\n"
28394 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
28395 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
28396 "23: movl 40(%4), %%eax\n"
28397 "24: movl 44(%4), %%edx\n"
28398 - "25: movl %%eax, 40(%3)\n"
28399 - "26: movl %%edx, 44(%3)\n"
28400 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
28401 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
28402 "27: movl 48(%4), %%eax\n"
28403 "28: movl 52(%4), %%edx\n"
28404 - "29: movl %%eax, 48(%3)\n"
28405 - "30: movl %%edx, 52(%3)\n"
28406 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
28407 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
28408 "31: movl 56(%4), %%eax\n"
28409 "32: movl 60(%4), %%edx\n"
28410 - "33: movl %%eax, 56(%3)\n"
28411 - "34: movl %%edx, 60(%3)\n"
28412 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
28413 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
28414 " addl $-64, %0\n"
28415 " addl $64, %4\n"
28416 " addl $64, %3\n"
28417 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
28418 " shrl $2, %0\n"
28419 " andl $3, %%eax\n"
28420 " cld\n"
28421 + __COPYUSER_SET_ES
28422 "99: rep; movsl\n"
28423 "36: movl %%eax, %0\n"
28424 "37: rep; movsb\n"
28425 "100:\n"
28426 + __COPYUSER_RESTORE_ES
28427 ".section .fixup,\"ax\"\n"
28428 "101: lea 0(%%eax,%0,4),%0\n"
28429 " jmp 100b\n"
28430 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
28431 }
28432
28433 static unsigned long
28434 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
28435 +{
28436 + int d0, d1;
28437 + __asm__ __volatile__(
28438 + " .align 2,0x90\n"
28439 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
28440 + " cmpl $67, %0\n"
28441 + " jbe 3f\n"
28442 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
28443 + " .align 2,0x90\n"
28444 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
28445 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
28446 + "5: movl %%eax, 0(%3)\n"
28447 + "6: movl %%edx, 4(%3)\n"
28448 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
28449 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
28450 + "9: movl %%eax, 8(%3)\n"
28451 + "10: movl %%edx, 12(%3)\n"
28452 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
28453 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
28454 + "13: movl %%eax, 16(%3)\n"
28455 + "14: movl %%edx, 20(%3)\n"
28456 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
28457 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
28458 + "17: movl %%eax, 24(%3)\n"
28459 + "18: movl %%edx, 28(%3)\n"
28460 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
28461 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
28462 + "21: movl %%eax, 32(%3)\n"
28463 + "22: movl %%edx, 36(%3)\n"
28464 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
28465 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
28466 + "25: movl %%eax, 40(%3)\n"
28467 + "26: movl %%edx, 44(%3)\n"
28468 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
28469 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
28470 + "29: movl %%eax, 48(%3)\n"
28471 + "30: movl %%edx, 52(%3)\n"
28472 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
28473 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
28474 + "33: movl %%eax, 56(%3)\n"
28475 + "34: movl %%edx, 60(%3)\n"
28476 + " addl $-64, %0\n"
28477 + " addl $64, %4\n"
28478 + " addl $64, %3\n"
28479 + " cmpl $63, %0\n"
28480 + " ja 1b\n"
28481 + "35: movl %0, %%eax\n"
28482 + " shrl $2, %0\n"
28483 + " andl $3, %%eax\n"
28484 + " cld\n"
28485 + "99: rep; "__copyuser_seg" movsl\n"
28486 + "36: movl %%eax, %0\n"
28487 + "37: rep; "__copyuser_seg" movsb\n"
28488 + "100:\n"
28489 + ".section .fixup,\"ax\"\n"
28490 + "101: lea 0(%%eax,%0,4),%0\n"
28491 + " jmp 100b\n"
28492 + ".previous\n"
28493 + _ASM_EXTABLE(1b,100b)
28494 + _ASM_EXTABLE(2b,100b)
28495 + _ASM_EXTABLE(3b,100b)
28496 + _ASM_EXTABLE(4b,100b)
28497 + _ASM_EXTABLE(5b,100b)
28498 + _ASM_EXTABLE(6b,100b)
28499 + _ASM_EXTABLE(7b,100b)
28500 + _ASM_EXTABLE(8b,100b)
28501 + _ASM_EXTABLE(9b,100b)
28502 + _ASM_EXTABLE(10b,100b)
28503 + _ASM_EXTABLE(11b,100b)
28504 + _ASM_EXTABLE(12b,100b)
28505 + _ASM_EXTABLE(13b,100b)
28506 + _ASM_EXTABLE(14b,100b)
28507 + _ASM_EXTABLE(15b,100b)
28508 + _ASM_EXTABLE(16b,100b)
28509 + _ASM_EXTABLE(17b,100b)
28510 + _ASM_EXTABLE(18b,100b)
28511 + _ASM_EXTABLE(19b,100b)
28512 + _ASM_EXTABLE(20b,100b)
28513 + _ASM_EXTABLE(21b,100b)
28514 + _ASM_EXTABLE(22b,100b)
28515 + _ASM_EXTABLE(23b,100b)
28516 + _ASM_EXTABLE(24b,100b)
28517 + _ASM_EXTABLE(25b,100b)
28518 + _ASM_EXTABLE(26b,100b)
28519 + _ASM_EXTABLE(27b,100b)
28520 + _ASM_EXTABLE(28b,100b)
28521 + _ASM_EXTABLE(29b,100b)
28522 + _ASM_EXTABLE(30b,100b)
28523 + _ASM_EXTABLE(31b,100b)
28524 + _ASM_EXTABLE(32b,100b)
28525 + _ASM_EXTABLE(33b,100b)
28526 + _ASM_EXTABLE(34b,100b)
28527 + _ASM_EXTABLE(35b,100b)
28528 + _ASM_EXTABLE(36b,100b)
28529 + _ASM_EXTABLE(37b,100b)
28530 + _ASM_EXTABLE(99b,101b)
28531 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
28532 + : "1"(to), "2"(from), "0"(size)
28533 + : "eax", "edx", "memory");
28534 + return size;
28535 +}
28536 +
28537 +static unsigned long __size_overflow(3)
28538 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
28539 {
28540 int d0, d1;
28541 __asm__ __volatile__(
28542 " .align 2,0x90\n"
28543 - "0: movl 32(%4), %%eax\n"
28544 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
28545 " cmpl $67, %0\n"
28546 " jbe 2f\n"
28547 - "1: movl 64(%4), %%eax\n"
28548 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
28549 " .align 2,0x90\n"
28550 - "2: movl 0(%4), %%eax\n"
28551 - "21: movl 4(%4), %%edx\n"
28552 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
28553 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
28554 " movl %%eax, 0(%3)\n"
28555 " movl %%edx, 4(%3)\n"
28556 - "3: movl 8(%4), %%eax\n"
28557 - "31: movl 12(%4),%%edx\n"
28558 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
28559 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
28560 " movl %%eax, 8(%3)\n"
28561 " movl %%edx, 12(%3)\n"
28562 - "4: movl 16(%4), %%eax\n"
28563 - "41: movl 20(%4), %%edx\n"
28564 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
28565 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
28566 " movl %%eax, 16(%3)\n"
28567 " movl %%edx, 20(%3)\n"
28568 - "10: movl 24(%4), %%eax\n"
28569 - "51: movl 28(%4), %%edx\n"
28570 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
28571 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
28572 " movl %%eax, 24(%3)\n"
28573 " movl %%edx, 28(%3)\n"
28574 - "11: movl 32(%4), %%eax\n"
28575 - "61: movl 36(%4), %%edx\n"
28576 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
28577 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
28578 " movl %%eax, 32(%3)\n"
28579 " movl %%edx, 36(%3)\n"
28580 - "12: movl 40(%4), %%eax\n"
28581 - "71: movl 44(%4), %%edx\n"
28582 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
28583 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
28584 " movl %%eax, 40(%3)\n"
28585 " movl %%edx, 44(%3)\n"
28586 - "13: movl 48(%4), %%eax\n"
28587 - "81: movl 52(%4), %%edx\n"
28588 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
28589 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
28590 " movl %%eax, 48(%3)\n"
28591 " movl %%edx, 52(%3)\n"
28592 - "14: movl 56(%4), %%eax\n"
28593 - "91: movl 60(%4), %%edx\n"
28594 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
28595 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
28596 " movl %%eax, 56(%3)\n"
28597 " movl %%edx, 60(%3)\n"
28598 " addl $-64, %0\n"
28599 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
28600 " shrl $2, %0\n"
28601 " andl $3, %%eax\n"
28602 " cld\n"
28603 - "6: rep; movsl\n"
28604 + "6: rep; "__copyuser_seg" movsl\n"
28605 " movl %%eax,%0\n"
28606 - "7: rep; movsb\n"
28607 + "7: rep; "__copyuser_seg" movsb\n"
28608 "8:\n"
28609 ".section .fixup,\"ax\"\n"
28610 "9: lea 0(%%eax,%0,4),%0\n"
28611 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
28612 * hyoshiok@miraclelinux.com
28613 */
28614
28615 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
28616 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
28617 const void __user *from, unsigned long size)
28618 {
28619 int d0, d1;
28620
28621 __asm__ __volatile__(
28622 " .align 2,0x90\n"
28623 - "0: movl 32(%4), %%eax\n"
28624 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
28625 " cmpl $67, %0\n"
28626 " jbe 2f\n"
28627 - "1: movl 64(%4), %%eax\n"
28628 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
28629 " .align 2,0x90\n"
28630 - "2: movl 0(%4), %%eax\n"
28631 - "21: movl 4(%4), %%edx\n"
28632 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
28633 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
28634 " movnti %%eax, 0(%3)\n"
28635 " movnti %%edx, 4(%3)\n"
28636 - "3: movl 8(%4), %%eax\n"
28637 - "31: movl 12(%4),%%edx\n"
28638 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
28639 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
28640 " movnti %%eax, 8(%3)\n"
28641 " movnti %%edx, 12(%3)\n"
28642 - "4: movl 16(%4), %%eax\n"
28643 - "41: movl 20(%4), %%edx\n"
28644 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
28645 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
28646 " movnti %%eax, 16(%3)\n"
28647 " movnti %%edx, 20(%3)\n"
28648 - "10: movl 24(%4), %%eax\n"
28649 - "51: movl 28(%4), %%edx\n"
28650 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
28651 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
28652 " movnti %%eax, 24(%3)\n"
28653 " movnti %%edx, 28(%3)\n"
28654 - "11: movl 32(%4), %%eax\n"
28655 - "61: movl 36(%4), %%edx\n"
28656 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
28657 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
28658 " movnti %%eax, 32(%3)\n"
28659 " movnti %%edx, 36(%3)\n"
28660 - "12: movl 40(%4), %%eax\n"
28661 - "71: movl 44(%4), %%edx\n"
28662 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
28663 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
28664 " movnti %%eax, 40(%3)\n"
28665 " movnti %%edx, 44(%3)\n"
28666 - "13: movl 48(%4), %%eax\n"
28667 - "81: movl 52(%4), %%edx\n"
28668 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
28669 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
28670 " movnti %%eax, 48(%3)\n"
28671 " movnti %%edx, 52(%3)\n"
28672 - "14: movl 56(%4), %%eax\n"
28673 - "91: movl 60(%4), %%edx\n"
28674 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
28675 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
28676 " movnti %%eax, 56(%3)\n"
28677 " movnti %%edx, 60(%3)\n"
28678 " addl $-64, %0\n"
28679 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
28680 " shrl $2, %0\n"
28681 " andl $3, %%eax\n"
28682 " cld\n"
28683 - "6: rep; movsl\n"
28684 + "6: rep; "__copyuser_seg" movsl\n"
28685 " movl %%eax,%0\n"
28686 - "7: rep; movsb\n"
28687 + "7: rep; "__copyuser_seg" movsb\n"
28688 "8:\n"
28689 ".section .fixup,\"ax\"\n"
28690 "9: lea 0(%%eax,%0,4),%0\n"
28691 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
28692 return size;
28693 }
28694
28695 -static unsigned long __copy_user_intel_nocache(void *to,
28696 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
28697 const void __user *from, unsigned long size)
28698 {
28699 int d0, d1;
28700
28701 __asm__ __volatile__(
28702 " .align 2,0x90\n"
28703 - "0: movl 32(%4), %%eax\n"
28704 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
28705 " cmpl $67, %0\n"
28706 " jbe 2f\n"
28707 - "1: movl 64(%4), %%eax\n"
28708 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
28709 " .align 2,0x90\n"
28710 - "2: movl 0(%4), %%eax\n"
28711 - "21: movl 4(%4), %%edx\n"
28712 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
28713 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
28714 " movnti %%eax, 0(%3)\n"
28715 " movnti %%edx, 4(%3)\n"
28716 - "3: movl 8(%4), %%eax\n"
28717 - "31: movl 12(%4),%%edx\n"
28718 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
28719 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
28720 " movnti %%eax, 8(%3)\n"
28721 " movnti %%edx, 12(%3)\n"
28722 - "4: movl 16(%4), %%eax\n"
28723 - "41: movl 20(%4), %%edx\n"
28724 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
28725 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
28726 " movnti %%eax, 16(%3)\n"
28727 " movnti %%edx, 20(%3)\n"
28728 - "10: movl 24(%4), %%eax\n"
28729 - "51: movl 28(%4), %%edx\n"
28730 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
28731 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
28732 " movnti %%eax, 24(%3)\n"
28733 " movnti %%edx, 28(%3)\n"
28734 - "11: movl 32(%4), %%eax\n"
28735 - "61: movl 36(%4), %%edx\n"
28736 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
28737 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
28738 " movnti %%eax, 32(%3)\n"
28739 " movnti %%edx, 36(%3)\n"
28740 - "12: movl 40(%4), %%eax\n"
28741 - "71: movl 44(%4), %%edx\n"
28742 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
28743 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
28744 " movnti %%eax, 40(%3)\n"
28745 " movnti %%edx, 44(%3)\n"
28746 - "13: movl 48(%4), %%eax\n"
28747 - "81: movl 52(%4), %%edx\n"
28748 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
28749 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
28750 " movnti %%eax, 48(%3)\n"
28751 " movnti %%edx, 52(%3)\n"
28752 - "14: movl 56(%4), %%eax\n"
28753 - "91: movl 60(%4), %%edx\n"
28754 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
28755 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
28756 " movnti %%eax, 56(%3)\n"
28757 " movnti %%edx, 60(%3)\n"
28758 " addl $-64, %0\n"
28759 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
28760 " shrl $2, %0\n"
28761 " andl $3, %%eax\n"
28762 " cld\n"
28763 - "6: rep; movsl\n"
28764 + "6: rep; "__copyuser_seg" movsl\n"
28765 " movl %%eax,%0\n"
28766 - "7: rep; movsb\n"
28767 + "7: rep; "__copyuser_seg" movsb\n"
28768 "8:\n"
28769 ".section .fixup,\"ax\"\n"
28770 "9: lea 0(%%eax,%0,4),%0\n"
28771 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
28772 */
28773 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
28774 unsigned long size);
28775 -unsigned long __copy_user_intel(void __user *to, const void *from,
28776 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
28777 + unsigned long size);
28778 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
28779 unsigned long size);
28780 unsigned long __copy_user_zeroing_intel_nocache(void *to,
28781 const void __user *from, unsigned long size);
28782 #endif /* CONFIG_X86_INTEL_USERCOPY */
28783
28784 /* Generic arbitrary sized copy. */
28785 -#define __copy_user(to, from, size) \
28786 +#define __copy_user(to, from, size, prefix, set, restore) \
28787 do { \
28788 int __d0, __d1, __d2; \
28789 __asm__ __volatile__( \
28790 + set \
28791 " cmp $7,%0\n" \
28792 " jbe 1f\n" \
28793 " movl %1,%0\n" \
28794 " negl %0\n" \
28795 " andl $7,%0\n" \
28796 " subl %0,%3\n" \
28797 - "4: rep; movsb\n" \
28798 + "4: rep; "prefix"movsb\n" \
28799 " movl %3,%0\n" \
28800 " shrl $2,%0\n" \
28801 " andl $3,%3\n" \
28802 " .align 2,0x90\n" \
28803 - "0: rep; movsl\n" \
28804 + "0: rep; "prefix"movsl\n" \
28805 " movl %3,%0\n" \
28806 - "1: rep; movsb\n" \
28807 + "1: rep; "prefix"movsb\n" \
28808 "2:\n" \
28809 + restore \
28810 ".section .fixup,\"ax\"\n" \
28811 "5: addl %3,%0\n" \
28812 " jmp 2b\n" \
28813 @@ -538,14 +650,14 @@ do { \
28814 " negl %0\n" \
28815 " andl $7,%0\n" \
28816 " subl %0,%3\n" \
28817 - "4: rep; movsb\n" \
28818 + "4: rep; "__copyuser_seg"movsb\n" \
28819 " movl %3,%0\n" \
28820 " shrl $2,%0\n" \
28821 " andl $3,%3\n" \
28822 " .align 2,0x90\n" \
28823 - "0: rep; movsl\n" \
28824 + "0: rep; "__copyuser_seg"movsl\n" \
28825 " movl %3,%0\n" \
28826 - "1: rep; movsb\n" \
28827 + "1: rep; "__copyuser_seg"movsb\n" \
28828 "2:\n" \
28829 ".section .fixup,\"ax\"\n" \
28830 "5: addl %3,%0\n" \
28831 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
28832 {
28833 stac();
28834 if (movsl_is_ok(to, from, n))
28835 - __copy_user(to, from, n);
28836 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
28837 else
28838 - n = __copy_user_intel(to, from, n);
28839 + n = __generic_copy_to_user_intel(to, from, n);
28840 clac();
28841 return n;
28842 }
28843 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
28844 {
28845 stac();
28846 if (movsl_is_ok(to, from, n))
28847 - __copy_user(to, from, n);
28848 + __copy_user(to, from, n, __copyuser_seg, "", "");
28849 else
28850 - n = __copy_user_intel((void __user *)to,
28851 - (const void *)from, n);
28852 + n = __generic_copy_from_user_intel(to, from, n);
28853 clac();
28854 return n;
28855 }
28856 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
28857 if (n > 64 && cpu_has_xmm2)
28858 n = __copy_user_intel_nocache(to, from, n);
28859 else
28860 - __copy_user(to, from, n);
28861 + __copy_user(to, from, n, __copyuser_seg, "", "");
28862 #else
28863 - __copy_user(to, from, n);
28864 + __copy_user(to, from, n, __copyuser_seg, "", "");
28865 #endif
28866 clac();
28867 return n;
28868 }
28869 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
28870
28871 -/**
28872 - * copy_to_user: - Copy a block of data into user space.
28873 - * @to: Destination address, in user space.
28874 - * @from: Source address, in kernel space.
28875 - * @n: Number of bytes to copy.
28876 - *
28877 - * Context: User context only. This function may sleep.
28878 - *
28879 - * Copy data from kernel space to user space.
28880 - *
28881 - * Returns number of bytes that could not be copied.
28882 - * On success, this will be zero.
28883 - */
28884 -unsigned long
28885 -copy_to_user(void __user *to, const void *from, unsigned long n)
28886 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28887 +void __set_fs(mm_segment_t x)
28888 {
28889 - if (access_ok(VERIFY_WRITE, to, n))
28890 - n = __copy_to_user(to, from, n);
28891 - return n;
28892 + switch (x.seg) {
28893 + case 0:
28894 + loadsegment(gs, 0);
28895 + break;
28896 + case TASK_SIZE_MAX:
28897 + loadsegment(gs, __USER_DS);
28898 + break;
28899 + case -1UL:
28900 + loadsegment(gs, __KERNEL_DS);
28901 + break;
28902 + default:
28903 + BUG();
28904 + }
28905 }
28906 -EXPORT_SYMBOL(copy_to_user);
28907 +EXPORT_SYMBOL(__set_fs);
28908
28909 -/**
28910 - * copy_from_user: - Copy a block of data from user space.
28911 - * @to: Destination address, in kernel space.
28912 - * @from: Source address, in user space.
28913 - * @n: Number of bytes to copy.
28914 - *
28915 - * Context: User context only. This function may sleep.
28916 - *
28917 - * Copy data from user space to kernel space.
28918 - *
28919 - * Returns number of bytes that could not be copied.
28920 - * On success, this will be zero.
28921 - *
28922 - * If some data could not be copied, this function will pad the copied
28923 - * data to the requested size using zero bytes.
28924 - */
28925 -unsigned long
28926 -_copy_from_user(void *to, const void __user *from, unsigned long n)
28927 +void set_fs(mm_segment_t x)
28928 {
28929 - if (access_ok(VERIFY_READ, from, n))
28930 - n = __copy_from_user(to, from, n);
28931 - else
28932 - memset(to, 0, n);
28933 - return n;
28934 + current_thread_info()->addr_limit = x;
28935 + __set_fs(x);
28936 }
28937 -EXPORT_SYMBOL(_copy_from_user);
28938 +EXPORT_SYMBOL(set_fs);
28939 +#endif
28940 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
28941 index 906fea3..0194a18 100644
28942 --- a/arch/x86/lib/usercopy_64.c
28943 +++ b/arch/x86/lib/usercopy_64.c
28944 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
28945 might_fault();
28946 /* no memory constraint because it doesn't change any memory gcc knows
28947 about */
28948 + pax_open_userland();
28949 stac();
28950 asm volatile(
28951 " testq %[size8],%[size8]\n"
28952 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
28953 _ASM_EXTABLE(0b,3b)
28954 _ASM_EXTABLE(1b,2b)
28955 : [size8] "=&c"(size), [dst] "=&D" (__d0)
28956 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
28957 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
28958 [zero] "r" (0UL), [eight] "r" (8UL));
28959 clac();
28960 + pax_close_userland();
28961 return size;
28962 }
28963 EXPORT_SYMBOL(__clear_user);
28964 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
28965 }
28966 EXPORT_SYMBOL(clear_user);
28967
28968 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
28969 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
28970 {
28971 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
28972 - return copy_user_generic((__force void *)to, (__force void *)from, len);
28973 - }
28974 - return len;
28975 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
28976 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
28977 + return len;
28978 }
28979 EXPORT_SYMBOL(copy_in_user);
28980
28981 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
28982 * it is not necessary to optimize tail handling.
28983 */
28984 unsigned long
28985 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
28986 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
28987 {
28988 char c;
28989 unsigned zero_len;
28990
28991 + clac();
28992 + pax_close_userland();
28993 for (; len; --len, to++) {
28994 if (__get_user_nocheck(c, from++, sizeof(char)))
28995 break;
28996 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
28997 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
28998 if (__put_user_nocheck(c, to++, sizeof(char)))
28999 break;
29000 - clac();
29001 return len;
29002 }
29003 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29004 index 23d8e5f..9ccc13a 100644
29005 --- a/arch/x86/mm/Makefile
29006 +++ b/arch/x86/mm/Makefile
29007 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29008 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29009
29010 obj-$(CONFIG_MEMTEST) += memtest.o
29011 +
29012 +quote:="
29013 +obj-$(CONFIG_X86_64) += uderef_64.o
29014 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29015 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29016 index 903ec1e..c4166b2 100644
29017 --- a/arch/x86/mm/extable.c
29018 +++ b/arch/x86/mm/extable.c
29019 @@ -6,12 +6,24 @@
29020 static inline unsigned long
29021 ex_insn_addr(const struct exception_table_entry *x)
29022 {
29023 - return (unsigned long)&x->insn + x->insn;
29024 + unsigned long reloc = 0;
29025 +
29026 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29027 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29028 +#endif
29029 +
29030 + return (unsigned long)&x->insn + x->insn + reloc;
29031 }
29032 static inline unsigned long
29033 ex_fixup_addr(const struct exception_table_entry *x)
29034 {
29035 - return (unsigned long)&x->fixup + x->fixup;
29036 + unsigned long reloc = 0;
29037 +
29038 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29039 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29040 +#endif
29041 +
29042 + return (unsigned long)&x->fixup + x->fixup + reloc;
29043 }
29044
29045 int fixup_exception(struct pt_regs *regs)
29046 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29047 unsigned long new_ip;
29048
29049 #ifdef CONFIG_PNPBIOS
29050 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29051 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29052 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29053 extern u32 pnp_bios_is_utter_crap;
29054 pnp_bios_is_utter_crap = 1;
29055 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29056 i += 4;
29057 p->fixup -= i;
29058 i += 4;
29059 +
29060 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29061 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29062 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29063 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29064 +#endif
29065 +
29066 }
29067 }
29068
29069 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29070 index 654be4a..a4a3da1 100644
29071 --- a/arch/x86/mm/fault.c
29072 +++ b/arch/x86/mm/fault.c
29073 @@ -14,11 +14,18 @@
29074 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29075 #include <linux/prefetch.h> /* prefetchw */
29076 #include <linux/context_tracking.h> /* exception_enter(), ... */
29077 +#include <linux/unistd.h>
29078 +#include <linux/compiler.h>
29079
29080 #include <asm/traps.h> /* dotraplinkage, ... */
29081 #include <asm/pgalloc.h> /* pgd_*(), ... */
29082 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29083 #include <asm/fixmap.h> /* VSYSCALL_START */
29084 +#include <asm/tlbflush.h>
29085 +
29086 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29087 +#include <asm/stacktrace.h>
29088 +#endif
29089
29090 /*
29091 * Page fault error code bits:
29092 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29093 int ret = 0;
29094
29095 /* kprobe_running() needs smp_processor_id() */
29096 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29097 + if (kprobes_built_in() && !user_mode(regs)) {
29098 preempt_disable();
29099 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29100 ret = 1;
29101 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29102 return !instr_lo || (instr_lo>>1) == 1;
29103 case 0x00:
29104 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29105 - if (probe_kernel_address(instr, opcode))
29106 + if (user_mode(regs)) {
29107 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29108 + return 0;
29109 + } else if (probe_kernel_address(instr, opcode))
29110 return 0;
29111
29112 *prefetch = (instr_lo == 0xF) &&
29113 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29114 while (instr < max_instr) {
29115 unsigned char opcode;
29116
29117 - if (probe_kernel_address(instr, opcode))
29118 + if (user_mode(regs)) {
29119 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29120 + break;
29121 + } else if (probe_kernel_address(instr, opcode))
29122 break;
29123
29124 instr++;
29125 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29126 force_sig_info(si_signo, &info, tsk);
29127 }
29128
29129 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29130 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29131 +#endif
29132 +
29133 +#ifdef CONFIG_PAX_EMUTRAMP
29134 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29135 +#endif
29136 +
29137 +#ifdef CONFIG_PAX_PAGEEXEC
29138 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29139 +{
29140 + pgd_t *pgd;
29141 + pud_t *pud;
29142 + pmd_t *pmd;
29143 +
29144 + pgd = pgd_offset(mm, address);
29145 + if (!pgd_present(*pgd))
29146 + return NULL;
29147 + pud = pud_offset(pgd, address);
29148 + if (!pud_present(*pud))
29149 + return NULL;
29150 + pmd = pmd_offset(pud, address);
29151 + if (!pmd_present(*pmd))
29152 + return NULL;
29153 + return pmd;
29154 +}
29155 +#endif
29156 +
29157 DEFINE_SPINLOCK(pgd_lock);
29158 LIST_HEAD(pgd_list);
29159
29160 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29161 for (address = VMALLOC_START & PMD_MASK;
29162 address >= TASK_SIZE && address < FIXADDR_TOP;
29163 address += PMD_SIZE) {
29164 +
29165 +#ifdef CONFIG_PAX_PER_CPU_PGD
29166 + unsigned long cpu;
29167 +#else
29168 struct page *page;
29169 +#endif
29170
29171 spin_lock(&pgd_lock);
29172 +
29173 +#ifdef CONFIG_PAX_PER_CPU_PGD
29174 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29175 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29176 + pmd_t *ret;
29177 +
29178 + ret = vmalloc_sync_one(pgd, address);
29179 + if (!ret)
29180 + break;
29181 + pgd = get_cpu_pgd(cpu, kernel);
29182 +#else
29183 list_for_each_entry(page, &pgd_list, lru) {
29184 + pgd_t *pgd;
29185 spinlock_t *pgt_lock;
29186 pmd_t *ret;
29187
29188 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29189 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29190
29191 spin_lock(pgt_lock);
29192 - ret = vmalloc_sync_one(page_address(page), address);
29193 + pgd = page_address(page);
29194 +#endif
29195 +
29196 + ret = vmalloc_sync_one(pgd, address);
29197 +
29198 +#ifndef CONFIG_PAX_PER_CPU_PGD
29199 spin_unlock(pgt_lock);
29200 +#endif
29201
29202 if (!ret)
29203 break;
29204 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29205 * an interrupt in the middle of a task switch..
29206 */
29207 pgd_paddr = read_cr3();
29208 +
29209 +#ifdef CONFIG_PAX_PER_CPU_PGD
29210 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
29211 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
29212 +#endif
29213 +
29214 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
29215 if (!pmd_k)
29216 return -1;
29217 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29218 * happen within a race in page table update. In the later
29219 * case just flush:
29220 */
29221 - pgd = pgd_offset(current->active_mm, address);
29222 +
29223 pgd_ref = pgd_offset_k(address);
29224 if (pgd_none(*pgd_ref))
29225 return -1;
29226
29227 +#ifdef CONFIG_PAX_PER_CPU_PGD
29228 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
29229 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
29230 + if (pgd_none(*pgd)) {
29231 + set_pgd(pgd, *pgd_ref);
29232 + arch_flush_lazy_mmu_mode();
29233 + } else {
29234 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
29235 + }
29236 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
29237 +#else
29238 + pgd = pgd_offset(current->active_mm, address);
29239 +#endif
29240 +
29241 if (pgd_none(*pgd)) {
29242 set_pgd(pgd, *pgd_ref);
29243 arch_flush_lazy_mmu_mode();
29244 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
29245 static int is_errata100(struct pt_regs *regs, unsigned long address)
29246 {
29247 #ifdef CONFIG_X86_64
29248 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
29249 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
29250 return 1;
29251 #endif
29252 return 0;
29253 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
29254 }
29255
29256 static const char nx_warning[] = KERN_CRIT
29257 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
29258 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
29259
29260 static void
29261 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
29262 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
29263 if (!oops_may_print())
29264 return;
29265
29266 - if (error_code & PF_INSTR) {
29267 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
29268 unsigned int level;
29269
29270 pte_t *pte = lookup_address(address, &level);
29271
29272 if (pte && pte_present(*pte) && !pte_exec(*pte))
29273 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
29274 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
29275 }
29276
29277 +#ifdef CONFIG_PAX_KERNEXEC
29278 + if (init_mm.start_code <= address && address < init_mm.end_code) {
29279 + if (current->signal->curr_ip)
29280 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
29281 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
29282 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
29283 + else
29284 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
29285 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
29286 + }
29287 +#endif
29288 +
29289 printk(KERN_ALERT "BUG: unable to handle kernel ");
29290 if (address < PAGE_SIZE)
29291 printk(KERN_CONT "NULL pointer dereference");
29292 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
29293 return;
29294 }
29295 #endif
29296 +
29297 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29298 + if (pax_is_fetch_fault(regs, error_code, address)) {
29299 +
29300 +#ifdef CONFIG_PAX_EMUTRAMP
29301 + switch (pax_handle_fetch_fault(regs)) {
29302 + case 2:
29303 + return;
29304 + }
29305 +#endif
29306 +
29307 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
29308 + do_group_exit(SIGKILL);
29309 + }
29310 +#endif
29311 +
29312 /* Kernel addresses are always protection faults: */
29313 if (address >= TASK_SIZE)
29314 error_code |= PF_PROT;
29315 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
29316 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
29317 printk(KERN_ERR
29318 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
29319 - tsk->comm, tsk->pid, address);
29320 + tsk->comm, task_pid_nr(tsk), address);
29321 code = BUS_MCEERR_AR;
29322 }
29323 #endif
29324 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
29325 return 1;
29326 }
29327
29328 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
29329 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
29330 +{
29331 + pte_t *pte;
29332 + pmd_t *pmd;
29333 + spinlock_t *ptl;
29334 + unsigned char pte_mask;
29335 +
29336 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
29337 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
29338 + return 0;
29339 +
29340 + /* PaX: it's our fault, let's handle it if we can */
29341 +
29342 + /* PaX: take a look at read faults before acquiring any locks */
29343 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
29344 + /* instruction fetch attempt from a protected page in user mode */
29345 + up_read(&mm->mmap_sem);
29346 +
29347 +#ifdef CONFIG_PAX_EMUTRAMP
29348 + switch (pax_handle_fetch_fault(regs)) {
29349 + case 2:
29350 + return 1;
29351 + }
29352 +#endif
29353 +
29354 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
29355 + do_group_exit(SIGKILL);
29356 + }
29357 +
29358 + pmd = pax_get_pmd(mm, address);
29359 + if (unlikely(!pmd))
29360 + return 0;
29361 +
29362 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
29363 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
29364 + pte_unmap_unlock(pte, ptl);
29365 + return 0;
29366 + }
29367 +
29368 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
29369 + /* write attempt to a protected page in user mode */
29370 + pte_unmap_unlock(pte, ptl);
29371 + return 0;
29372 + }
29373 +
29374 +#ifdef CONFIG_SMP
29375 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
29376 +#else
29377 + if (likely(address > get_limit(regs->cs)))
29378 +#endif
29379 + {
29380 + set_pte(pte, pte_mkread(*pte));
29381 + __flush_tlb_one(address);
29382 + pte_unmap_unlock(pte, ptl);
29383 + up_read(&mm->mmap_sem);
29384 + return 1;
29385 + }
29386 +
29387 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
29388 +
29389 + /*
29390 + * PaX: fill DTLB with user rights and retry
29391 + */
29392 + __asm__ __volatile__ (
29393 + "orb %2,(%1)\n"
29394 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
29395 +/*
29396 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
29397 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
29398 + * page fault when examined during a TLB load attempt. this is true not only
29399 + * for PTEs holding a non-present entry but also present entries that will
29400 + * raise a page fault (such as those set up by PaX, or the copy-on-write
29401 + * mechanism). in effect it means that we do *not* need to flush the TLBs
29402 + * for our target pages since their PTEs are simply not in the TLBs at all.
29403 +
29404 + * the best thing in omitting it is that we gain around 15-20% speed in the
29405 + * fast path of the page fault handler and can get rid of tracing since we
29406 + * can no longer flush unintended entries.
29407 + */
29408 + "invlpg (%0)\n"
29409 +#endif
29410 + __copyuser_seg"testb $0,(%0)\n"
29411 + "xorb %3,(%1)\n"
29412 + :
29413 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
29414 + : "memory", "cc");
29415 + pte_unmap_unlock(pte, ptl);
29416 + up_read(&mm->mmap_sem);
29417 + return 1;
29418 +}
29419 +#endif
29420 +
29421 /*
29422 * Handle a spurious fault caused by a stale TLB entry.
29423 *
29424 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
29425 static inline int
29426 access_error(unsigned long error_code, struct vm_area_struct *vma)
29427 {
29428 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
29429 + return 1;
29430 +
29431 if (error_code & PF_WRITE) {
29432 /* write, present and write, not present: */
29433 if (unlikely(!(vma->vm_flags & VM_WRITE)))
29434 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
29435 if (error_code & PF_USER)
29436 return false;
29437
29438 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
29439 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
29440 return false;
29441
29442 return true;
29443 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
29444 {
29445 struct vm_area_struct *vma;
29446 struct task_struct *tsk;
29447 - unsigned long address;
29448 struct mm_struct *mm;
29449 int fault;
29450 int write = error_code & PF_WRITE;
29451 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
29452 (write ? FAULT_FLAG_WRITE : 0);
29453
29454 - tsk = current;
29455 - mm = tsk->mm;
29456 -
29457 /* Get the faulting address: */
29458 - address = read_cr2();
29459 + unsigned long address = read_cr2();
29460 +
29461 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29462 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
29463 + if (!search_exception_tables(regs->ip)) {
29464 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
29465 + bad_area_nosemaphore(regs, error_code, address);
29466 + return;
29467 + }
29468 + if (address < pax_user_shadow_base) {
29469 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
29470 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
29471 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
29472 + } else
29473 + address -= pax_user_shadow_base;
29474 + }
29475 +#endif
29476 +
29477 + tsk = current;
29478 + mm = tsk->mm;
29479
29480 /*
29481 * Detect and handle instructions that would cause a page fault for
29482 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
29483 * User-mode registers count as a user access even for any
29484 * potential system fault or CPU buglet:
29485 */
29486 - if (user_mode_vm(regs)) {
29487 + if (user_mode(regs)) {
29488 local_irq_enable();
29489 error_code |= PF_USER;
29490 } else {
29491 @@ -1142,6 +1365,11 @@ retry:
29492 might_sleep();
29493 }
29494
29495 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
29496 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
29497 + return;
29498 +#endif
29499 +
29500 vma = find_vma(mm, address);
29501 if (unlikely(!vma)) {
29502 bad_area(regs, error_code, address);
29503 @@ -1153,18 +1381,24 @@ retry:
29504 bad_area(regs, error_code, address);
29505 return;
29506 }
29507 - if (error_code & PF_USER) {
29508 - /*
29509 - * Accessing the stack below %sp is always a bug.
29510 - * The large cushion allows instructions like enter
29511 - * and pusha to work. ("enter $65535, $31" pushes
29512 - * 32 pointers and then decrements %sp by 65535.)
29513 - */
29514 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
29515 - bad_area(regs, error_code, address);
29516 - return;
29517 - }
29518 + /*
29519 + * Accessing the stack below %sp is always a bug.
29520 + * The large cushion allows instructions like enter
29521 + * and pusha to work. ("enter $65535, $31" pushes
29522 + * 32 pointers and then decrements %sp by 65535.)
29523 + */
29524 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
29525 + bad_area(regs, error_code, address);
29526 + return;
29527 }
29528 +
29529 +#ifdef CONFIG_PAX_SEGMEXEC
29530 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
29531 + bad_area(regs, error_code, address);
29532 + return;
29533 + }
29534 +#endif
29535 +
29536 if (unlikely(expand_stack(vma, address))) {
29537 bad_area(regs, error_code, address);
29538 return;
29539 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
29540 __do_page_fault(regs, error_code);
29541 exception_exit(prev_state);
29542 }
29543 +
29544 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29545 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
29546 +{
29547 + struct mm_struct *mm = current->mm;
29548 + unsigned long ip = regs->ip;
29549 +
29550 + if (v8086_mode(regs))
29551 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
29552 +
29553 +#ifdef CONFIG_PAX_PAGEEXEC
29554 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
29555 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
29556 + return true;
29557 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
29558 + return true;
29559 + return false;
29560 + }
29561 +#endif
29562 +
29563 +#ifdef CONFIG_PAX_SEGMEXEC
29564 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
29565 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
29566 + return true;
29567 + return false;
29568 + }
29569 +#endif
29570 +
29571 + return false;
29572 +}
29573 +#endif
29574 +
29575 +#ifdef CONFIG_PAX_EMUTRAMP
29576 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
29577 +{
29578 + int err;
29579 +
29580 + do { /* PaX: libffi trampoline emulation */
29581 + unsigned char mov, jmp;
29582 + unsigned int addr1, addr2;
29583 +
29584 +#ifdef CONFIG_X86_64
29585 + if ((regs->ip + 9) >> 32)
29586 + break;
29587 +#endif
29588 +
29589 + err = get_user(mov, (unsigned char __user *)regs->ip);
29590 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
29591 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
29592 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
29593 +
29594 + if (err)
29595 + break;
29596 +
29597 + if (mov == 0xB8 && jmp == 0xE9) {
29598 + regs->ax = addr1;
29599 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
29600 + return 2;
29601 + }
29602 + } while (0);
29603 +
29604 + do { /* PaX: gcc trampoline emulation #1 */
29605 + unsigned char mov1, mov2;
29606 + unsigned short jmp;
29607 + unsigned int addr1, addr2;
29608 +
29609 +#ifdef CONFIG_X86_64
29610 + if ((regs->ip + 11) >> 32)
29611 + break;
29612 +#endif
29613 +
29614 + err = get_user(mov1, (unsigned char __user *)regs->ip);
29615 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
29616 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
29617 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
29618 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
29619 +
29620 + if (err)
29621 + break;
29622 +
29623 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
29624 + regs->cx = addr1;
29625 + regs->ax = addr2;
29626 + regs->ip = addr2;
29627 + return 2;
29628 + }
29629 + } while (0);
29630 +
29631 + do { /* PaX: gcc trampoline emulation #2 */
29632 + unsigned char mov, jmp;
29633 + unsigned int addr1, addr2;
29634 +
29635 +#ifdef CONFIG_X86_64
29636 + if ((regs->ip + 9) >> 32)
29637 + break;
29638 +#endif
29639 +
29640 + err = get_user(mov, (unsigned char __user *)regs->ip);
29641 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
29642 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
29643 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
29644 +
29645 + if (err)
29646 + break;
29647 +
29648 + if (mov == 0xB9 && jmp == 0xE9) {
29649 + regs->cx = addr1;
29650 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
29651 + return 2;
29652 + }
29653 + } while (0);
29654 +
29655 + return 1; /* PaX in action */
29656 +}
29657 +
29658 +#ifdef CONFIG_X86_64
29659 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
29660 +{
29661 + int err;
29662 +
29663 + do { /* PaX: libffi trampoline emulation */
29664 + unsigned short mov1, mov2, jmp1;
29665 + unsigned char stcclc, jmp2;
29666 + unsigned long addr1, addr2;
29667 +
29668 + err = get_user(mov1, (unsigned short __user *)regs->ip);
29669 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
29670 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
29671 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
29672 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
29673 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
29674 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
29675 +
29676 + if (err)
29677 + break;
29678 +
29679 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
29680 + regs->r11 = addr1;
29681 + regs->r10 = addr2;
29682 + if (stcclc == 0xF8)
29683 + regs->flags &= ~X86_EFLAGS_CF;
29684 + else
29685 + regs->flags |= X86_EFLAGS_CF;
29686 + regs->ip = addr1;
29687 + return 2;
29688 + }
29689 + } while (0);
29690 +
29691 + do { /* PaX: gcc trampoline emulation #1 */
29692 + unsigned short mov1, mov2, jmp1;
29693 + unsigned char jmp2;
29694 + unsigned int addr1;
29695 + unsigned long addr2;
29696 +
29697 + err = get_user(mov1, (unsigned short __user *)regs->ip);
29698 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
29699 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
29700 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
29701 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
29702 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
29703 +
29704 + if (err)
29705 + break;
29706 +
29707 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
29708 + regs->r11 = addr1;
29709 + regs->r10 = addr2;
29710 + regs->ip = addr1;
29711 + return 2;
29712 + }
29713 + } while (0);
29714 +
29715 + do { /* PaX: gcc trampoline emulation #2 */
29716 + unsigned short mov1, mov2, jmp1;
29717 + unsigned char jmp2;
29718 + unsigned long addr1, addr2;
29719 +
29720 + err = get_user(mov1, (unsigned short __user *)regs->ip);
29721 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
29722 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
29723 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
29724 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
29725 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
29726 +
29727 + if (err)
29728 + break;
29729 +
29730 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
29731 + regs->r11 = addr1;
29732 + regs->r10 = addr2;
29733 + regs->ip = addr1;
29734 + return 2;
29735 + }
29736 + } while (0);
29737 +
29738 + return 1; /* PaX in action */
29739 +}
29740 +#endif
29741 +
29742 +/*
29743 + * PaX: decide what to do with offenders (regs->ip = fault address)
29744 + *
29745 + * returns 1 when task should be killed
29746 + * 2 when gcc trampoline was detected
29747 + */
29748 +static int pax_handle_fetch_fault(struct pt_regs *regs)
29749 +{
29750 + if (v8086_mode(regs))
29751 + return 1;
29752 +
29753 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
29754 + return 1;
29755 +
29756 +#ifdef CONFIG_X86_32
29757 + return pax_handle_fetch_fault_32(regs);
29758 +#else
29759 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
29760 + return pax_handle_fetch_fault_32(regs);
29761 + else
29762 + return pax_handle_fetch_fault_64(regs);
29763 +#endif
29764 +}
29765 +#endif
29766 +
29767 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29768 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
29769 +{
29770 + long i;
29771 +
29772 + printk(KERN_ERR "PAX: bytes at PC: ");
29773 + for (i = 0; i < 20; i++) {
29774 + unsigned char c;
29775 + if (get_user(c, (unsigned char __force_user *)pc+i))
29776 + printk(KERN_CONT "?? ");
29777 + else
29778 + printk(KERN_CONT "%02x ", c);
29779 + }
29780 + printk("\n");
29781 +
29782 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
29783 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
29784 + unsigned long c;
29785 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
29786 +#ifdef CONFIG_X86_32
29787 + printk(KERN_CONT "???????? ");
29788 +#else
29789 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
29790 + printk(KERN_CONT "???????? ???????? ");
29791 + else
29792 + printk(KERN_CONT "???????????????? ");
29793 +#endif
29794 + } else {
29795 +#ifdef CONFIG_X86_64
29796 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
29797 + printk(KERN_CONT "%08x ", (unsigned int)c);
29798 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
29799 + } else
29800 +#endif
29801 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
29802 + }
29803 + }
29804 + printk("\n");
29805 +}
29806 +#endif
29807 +
29808 +/**
29809 + * probe_kernel_write(): safely attempt to write to a location
29810 + * @dst: address to write to
29811 + * @src: pointer to the data that shall be written
29812 + * @size: size of the data chunk
29813 + *
29814 + * Safely write to address @dst from the buffer at @src. If a kernel fault
29815 + * happens, handle that and return -EFAULT.
29816 + */
29817 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
29818 +{
29819 + long ret;
29820 + mm_segment_t old_fs = get_fs();
29821 +
29822 + set_fs(KERNEL_DS);
29823 + pagefault_disable();
29824 + pax_open_kernel();
29825 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
29826 + pax_close_kernel();
29827 + pagefault_enable();
29828 + set_fs(old_fs);
29829 +
29830 + return ret ? -EFAULT : 0;
29831 +}
29832 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
29833 index dd74e46..7d26398 100644
29834 --- a/arch/x86/mm/gup.c
29835 +++ b/arch/x86/mm/gup.c
29836 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
29837 addr = start;
29838 len = (unsigned long) nr_pages << PAGE_SHIFT;
29839 end = start + len;
29840 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
29841 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
29842 (void __user *)start, len)))
29843 return 0;
29844
29845 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
29846 index 252b8f5..4dcfdc1 100644
29847 --- a/arch/x86/mm/highmem_32.c
29848 +++ b/arch/x86/mm/highmem_32.c
29849 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
29850 idx = type + KM_TYPE_NR*smp_processor_id();
29851 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
29852 BUG_ON(!pte_none(*(kmap_pte-idx)));
29853 +
29854 + pax_open_kernel();
29855 set_pte(kmap_pte-idx, mk_pte(page, prot));
29856 + pax_close_kernel();
29857 +
29858 arch_flush_lazy_mmu_mode();
29859
29860 return (void *)vaddr;
29861 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
29862 index ae1aa71..d9bea75 100644
29863 --- a/arch/x86/mm/hugetlbpage.c
29864 +++ b/arch/x86/mm/hugetlbpage.c
29865 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
29866 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
29867 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
29868 unsigned long addr, unsigned long len,
29869 - unsigned long pgoff, unsigned long flags)
29870 + unsigned long pgoff, unsigned long flags, unsigned long offset)
29871 {
29872 struct hstate *h = hstate_file(file);
29873 struct vm_unmapped_area_info info;
29874 -
29875 +
29876 info.flags = 0;
29877 info.length = len;
29878 info.low_limit = TASK_UNMAPPED_BASE;
29879 +
29880 +#ifdef CONFIG_PAX_RANDMMAP
29881 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
29882 + info.low_limit += current->mm->delta_mmap;
29883 +#endif
29884 +
29885 info.high_limit = TASK_SIZE;
29886 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
29887 info.align_offset = 0;
29888 + info.threadstack_offset = offset;
29889 return vm_unmapped_area(&info);
29890 }
29891
29892 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
29893 unsigned long addr0, unsigned long len,
29894 - unsigned long pgoff, unsigned long flags)
29895 + unsigned long pgoff, unsigned long flags, unsigned long offset)
29896 {
29897 struct hstate *h = hstate_file(file);
29898 struct vm_unmapped_area_info info;
29899 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
29900 info.high_limit = current->mm->mmap_base;
29901 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
29902 info.align_offset = 0;
29903 + info.threadstack_offset = offset;
29904 addr = vm_unmapped_area(&info);
29905
29906 /*
29907 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
29908 VM_BUG_ON(addr != -ENOMEM);
29909 info.flags = 0;
29910 info.low_limit = TASK_UNMAPPED_BASE;
29911 +
29912 +#ifdef CONFIG_PAX_RANDMMAP
29913 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
29914 + info.low_limit += current->mm->delta_mmap;
29915 +#endif
29916 +
29917 info.high_limit = TASK_SIZE;
29918 addr = vm_unmapped_area(&info);
29919 }
29920 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
29921 struct hstate *h = hstate_file(file);
29922 struct mm_struct *mm = current->mm;
29923 struct vm_area_struct *vma;
29924 + unsigned long pax_task_size = TASK_SIZE;
29925 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
29926
29927 if (len & ~huge_page_mask(h))
29928 return -EINVAL;
29929 - if (len > TASK_SIZE)
29930 +
29931 +#ifdef CONFIG_PAX_SEGMEXEC
29932 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29933 + pax_task_size = SEGMEXEC_TASK_SIZE;
29934 +#endif
29935 +
29936 + pax_task_size -= PAGE_SIZE;
29937 +
29938 + if (len > pax_task_size)
29939 return -ENOMEM;
29940
29941 if (flags & MAP_FIXED) {
29942 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
29943 return addr;
29944 }
29945
29946 +#ifdef CONFIG_PAX_RANDMMAP
29947 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
29948 +#endif
29949 +
29950 if (addr) {
29951 addr = ALIGN(addr, huge_page_size(h));
29952 vma = find_vma(mm, addr);
29953 - if (TASK_SIZE - len >= addr &&
29954 - (!vma || addr + len <= vma->vm_start))
29955 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
29956 return addr;
29957 }
29958 if (mm->get_unmapped_area == arch_get_unmapped_area)
29959 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
29960 - pgoff, flags);
29961 + pgoff, flags, offset);
29962 else
29963 return hugetlb_get_unmapped_area_topdown(file, addr, len,
29964 - pgoff, flags);
29965 + pgoff, flags, offset);
29966 }
29967
29968 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
29969 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
29970 index 1f34e92..c97b98f 100644
29971 --- a/arch/x86/mm/init.c
29972 +++ b/arch/x86/mm/init.c
29973 @@ -4,6 +4,7 @@
29974 #include <linux/swap.h>
29975 #include <linux/memblock.h>
29976 #include <linux/bootmem.h> /* for max_low_pfn */
29977 +#include <linux/tboot.h>
29978
29979 #include <asm/cacheflush.h>
29980 #include <asm/e820.h>
29981 @@ -17,6 +18,8 @@
29982 #include <asm/proto.h>
29983 #include <asm/dma.h> /* for MAX_DMA_PFN */
29984 #include <asm/microcode.h>
29985 +#include <asm/desc.h>
29986 +#include <asm/bios_ebda.h>
29987
29988 #include "mm_internal.h"
29989
29990 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
29991 early_ioremap_page_table_range_init();
29992 #endif
29993
29994 +#ifdef CONFIG_PAX_PER_CPU_PGD
29995 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
29996 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
29997 + KERNEL_PGD_PTRS);
29998 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
29999 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30000 + KERNEL_PGD_PTRS);
30001 + load_cr3(get_cpu_pgd(0, kernel));
30002 +#else
30003 load_cr3(swapper_pg_dir);
30004 +#endif
30005 +
30006 __flush_tlb_all();
30007
30008 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30009 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30010 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30011 * mmio resources as well as potential bios/acpi data regions.
30012 */
30013 +
30014 +#ifdef CONFIG_GRKERNSEC_KMEM
30015 +static unsigned int ebda_start __read_only;
30016 +static unsigned int ebda_end __read_only;
30017 +#endif
30018 +
30019 int devmem_is_allowed(unsigned long pagenr)
30020 {
30021 - if (pagenr < 256)
30022 +#ifdef CONFIG_GRKERNSEC_KMEM
30023 + /* allow BDA */
30024 + if (!pagenr)
30025 return 1;
30026 + /* allow EBDA */
30027 + if (pagenr >= ebda_start && pagenr < ebda_end)
30028 + return 1;
30029 + /* if tboot is in use, allow access to its hardcoded serial log range */
30030 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30031 + return 1;
30032 +#else
30033 + if (!pagenr)
30034 + return 1;
30035 +#ifdef CONFIG_VM86
30036 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30037 + return 1;
30038 +#endif
30039 +#endif
30040 +
30041 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30042 + return 1;
30043 +#ifdef CONFIG_GRKERNSEC_KMEM
30044 + /* throw out everything else below 1MB */
30045 + if (pagenr <= 256)
30046 + return 0;
30047 +#endif
30048 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30049 return 0;
30050 if (!page_is_ram(pagenr))
30051 @@ -538,8 +582,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30052 #endif
30053 }
30054
30055 +#ifdef CONFIG_GRKERNSEC_KMEM
30056 +static inline void gr_init_ebda(void)
30057 +{
30058 + unsigned int ebda_addr;
30059 + unsigned int ebda_size = 0;
30060 +
30061 + ebda_addr = get_bios_ebda();
30062 + if (ebda_addr) {
30063 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30064 + ebda_size <<= 10;
30065 + }
30066 + if (ebda_addr && ebda_size) {
30067 + ebda_start = ebda_addr >> PAGE_SHIFT;
30068 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30069 + } else {
30070 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30071 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30072 + }
30073 +}
30074 +#else
30075 +static inline void gr_init_ebda(void) { }
30076 +#endif
30077 +
30078 void free_initmem(void)
30079 {
30080 +#ifdef CONFIG_PAX_KERNEXEC
30081 +#ifdef CONFIG_X86_32
30082 + /* PaX: limit KERNEL_CS to actual size */
30083 + unsigned long addr, limit;
30084 + struct desc_struct d;
30085 + int cpu;
30086 +#else
30087 + pgd_t *pgd;
30088 + pud_t *pud;
30089 + pmd_t *pmd;
30090 + unsigned long addr, end;
30091 +#endif
30092 +#endif
30093 +
30094 + gr_init_ebda();
30095 +
30096 +#ifdef CONFIG_PAX_KERNEXEC
30097 +#ifdef CONFIG_X86_32
30098 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30099 + limit = (limit - 1UL) >> PAGE_SHIFT;
30100 +
30101 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30102 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30103 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30104 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30105 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30106 + }
30107 +
30108 + /* PaX: make KERNEL_CS read-only */
30109 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30110 + if (!paravirt_enabled())
30111 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30112 +/*
30113 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30114 + pgd = pgd_offset_k(addr);
30115 + pud = pud_offset(pgd, addr);
30116 + pmd = pmd_offset(pud, addr);
30117 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30118 + }
30119 +*/
30120 +#ifdef CONFIG_X86_PAE
30121 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30122 +/*
30123 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30124 + pgd = pgd_offset_k(addr);
30125 + pud = pud_offset(pgd, addr);
30126 + pmd = pmd_offset(pud, addr);
30127 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30128 + }
30129 +*/
30130 +#endif
30131 +
30132 +#ifdef CONFIG_MODULES
30133 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30134 +#endif
30135 +
30136 +#else
30137 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30138 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30139 + pgd = pgd_offset_k(addr);
30140 + pud = pud_offset(pgd, addr);
30141 + pmd = pmd_offset(pud, addr);
30142 + if (!pmd_present(*pmd))
30143 + continue;
30144 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30145 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30146 + else
30147 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30148 + }
30149 +
30150 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30151 + end = addr + KERNEL_IMAGE_SIZE;
30152 + for (; addr < end; addr += PMD_SIZE) {
30153 + pgd = pgd_offset_k(addr);
30154 + pud = pud_offset(pgd, addr);
30155 + pmd = pmd_offset(pud, addr);
30156 + if (!pmd_present(*pmd))
30157 + continue;
30158 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30159 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30160 + }
30161 +#endif
30162 +
30163 + flush_tlb_all();
30164 +#endif
30165 +
30166 free_init_pages("unused kernel memory",
30167 (unsigned long)(&__init_begin),
30168 (unsigned long)(&__init_end));
30169 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30170 index 3ac7e31..89611b7 100644
30171 --- a/arch/x86/mm/init_32.c
30172 +++ b/arch/x86/mm/init_32.c
30173 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30174 bool __read_mostly __vmalloc_start_set = false;
30175
30176 /*
30177 - * Creates a middle page table and puts a pointer to it in the
30178 - * given global directory entry. This only returns the gd entry
30179 - * in non-PAE compilation mode, since the middle layer is folded.
30180 - */
30181 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30182 -{
30183 - pud_t *pud;
30184 - pmd_t *pmd_table;
30185 -
30186 -#ifdef CONFIG_X86_PAE
30187 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30188 - pmd_table = (pmd_t *)alloc_low_page();
30189 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30190 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30191 - pud = pud_offset(pgd, 0);
30192 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30193 -
30194 - return pmd_table;
30195 - }
30196 -#endif
30197 - pud = pud_offset(pgd, 0);
30198 - pmd_table = pmd_offset(pud, 0);
30199 -
30200 - return pmd_table;
30201 -}
30202 -
30203 -/*
30204 * Create a page table and place a pointer to it in a middle page
30205 * directory entry:
30206 */
30207 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30208 pte_t *page_table = (pte_t *)alloc_low_page();
30209
30210 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
30211 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30212 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
30213 +#else
30214 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
30215 +#endif
30216 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
30217 }
30218
30219 return pte_offset_kernel(pmd, 0);
30220 }
30221
30222 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
30223 +{
30224 + pud_t *pud;
30225 + pmd_t *pmd_table;
30226 +
30227 + pud = pud_offset(pgd, 0);
30228 + pmd_table = pmd_offset(pud, 0);
30229 +
30230 + return pmd_table;
30231 +}
30232 +
30233 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
30234 {
30235 int pgd_idx = pgd_index(vaddr);
30236 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
30237 int pgd_idx, pmd_idx;
30238 unsigned long vaddr;
30239 pgd_t *pgd;
30240 + pud_t *pud;
30241 pmd_t *pmd;
30242 pte_t *pte = NULL;
30243 unsigned long count = page_table_range_init_count(start, end);
30244 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
30245 pgd = pgd_base + pgd_idx;
30246
30247 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
30248 - pmd = one_md_table_init(pgd);
30249 - pmd = pmd + pmd_index(vaddr);
30250 + pud = pud_offset(pgd, vaddr);
30251 + pmd = pmd_offset(pud, vaddr);
30252 +
30253 +#ifdef CONFIG_X86_PAE
30254 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
30255 +#endif
30256 +
30257 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
30258 pmd++, pmd_idx++) {
30259 pte = page_table_kmap_check(one_page_table_init(pmd),
30260 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
30261 }
30262 }
30263
30264 -static inline int is_kernel_text(unsigned long addr)
30265 +static inline int is_kernel_text(unsigned long start, unsigned long end)
30266 {
30267 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
30268 - return 1;
30269 - return 0;
30270 + if ((start > ktla_ktva((unsigned long)_etext) ||
30271 + end <= ktla_ktva((unsigned long)_stext)) &&
30272 + (start > ktla_ktva((unsigned long)_einittext) ||
30273 + end <= ktla_ktva((unsigned long)_sinittext)) &&
30274 +
30275 +#ifdef CONFIG_ACPI_SLEEP
30276 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
30277 +#endif
30278 +
30279 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
30280 + return 0;
30281 + return 1;
30282 }
30283
30284 /*
30285 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
30286 unsigned long last_map_addr = end;
30287 unsigned long start_pfn, end_pfn;
30288 pgd_t *pgd_base = swapper_pg_dir;
30289 - int pgd_idx, pmd_idx, pte_ofs;
30290 + unsigned int pgd_idx, pmd_idx, pte_ofs;
30291 unsigned long pfn;
30292 pgd_t *pgd;
30293 + pud_t *pud;
30294 pmd_t *pmd;
30295 pte_t *pte;
30296 unsigned pages_2m, pages_4k;
30297 @@ -291,8 +295,13 @@ repeat:
30298 pfn = start_pfn;
30299 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
30300 pgd = pgd_base + pgd_idx;
30301 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
30302 - pmd = one_md_table_init(pgd);
30303 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
30304 + pud = pud_offset(pgd, 0);
30305 + pmd = pmd_offset(pud, 0);
30306 +
30307 +#ifdef CONFIG_X86_PAE
30308 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
30309 +#endif
30310
30311 if (pfn >= end_pfn)
30312 continue;
30313 @@ -304,14 +313,13 @@ repeat:
30314 #endif
30315 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
30316 pmd++, pmd_idx++) {
30317 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
30318 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
30319
30320 /*
30321 * Map with big pages if possible, otherwise
30322 * create normal page tables:
30323 */
30324 if (use_pse) {
30325 - unsigned int addr2;
30326 pgprot_t prot = PAGE_KERNEL_LARGE;
30327 /*
30328 * first pass will use the same initial
30329 @@ -322,11 +330,7 @@ repeat:
30330 _PAGE_PSE);
30331
30332 pfn &= PMD_MASK >> PAGE_SHIFT;
30333 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
30334 - PAGE_OFFSET + PAGE_SIZE-1;
30335 -
30336 - if (is_kernel_text(addr) ||
30337 - is_kernel_text(addr2))
30338 + if (is_kernel_text(address, address + PMD_SIZE))
30339 prot = PAGE_KERNEL_LARGE_EXEC;
30340
30341 pages_2m++;
30342 @@ -343,7 +347,7 @@ repeat:
30343 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
30344 pte += pte_ofs;
30345 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
30346 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
30347 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
30348 pgprot_t prot = PAGE_KERNEL;
30349 /*
30350 * first pass will use the same initial
30351 @@ -351,7 +355,7 @@ repeat:
30352 */
30353 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
30354
30355 - if (is_kernel_text(addr))
30356 + if (is_kernel_text(address, address + PAGE_SIZE))
30357 prot = PAGE_KERNEL_EXEC;
30358
30359 pages_4k++;
30360 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
30361
30362 pud = pud_offset(pgd, va);
30363 pmd = pmd_offset(pud, va);
30364 - if (!pmd_present(*pmd))
30365 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
30366 break;
30367
30368 /* should not be large page here */
30369 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
30370
30371 static void __init pagetable_init(void)
30372 {
30373 - pgd_t *pgd_base = swapper_pg_dir;
30374 -
30375 - permanent_kmaps_init(pgd_base);
30376 + permanent_kmaps_init(swapper_pg_dir);
30377 }
30378
30379 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
30380 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
30381 EXPORT_SYMBOL_GPL(__supported_pte_mask);
30382
30383 /* user-defined highmem size */
30384 @@ -772,7 +774,7 @@ void __init mem_init(void)
30385 after_bootmem = 1;
30386
30387 codesize = (unsigned long) &_etext - (unsigned long) &_text;
30388 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
30389 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
30390 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
30391
30392 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
30393 @@ -813,10 +815,10 @@ void __init mem_init(void)
30394 ((unsigned long)&__init_end -
30395 (unsigned long)&__init_begin) >> 10,
30396
30397 - (unsigned long)&_etext, (unsigned long)&_edata,
30398 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
30399 + (unsigned long)&_sdata, (unsigned long)&_edata,
30400 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
30401
30402 - (unsigned long)&_text, (unsigned long)&_etext,
30403 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
30404 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
30405
30406 /*
30407 @@ -906,6 +908,7 @@ void set_kernel_text_rw(void)
30408 if (!kernel_set_to_readonly)
30409 return;
30410
30411 + start = ktla_ktva(start);
30412 pr_debug("Set kernel text: %lx - %lx for read write\n",
30413 start, start+size);
30414
30415 @@ -920,6 +923,7 @@ void set_kernel_text_ro(void)
30416 if (!kernel_set_to_readonly)
30417 return;
30418
30419 + start = ktla_ktva(start);
30420 pr_debug("Set kernel text: %lx - %lx for read only\n",
30421 start, start+size);
30422
30423 @@ -948,6 +952,7 @@ void mark_rodata_ro(void)
30424 unsigned long start = PFN_ALIGN(_text);
30425 unsigned long size = PFN_ALIGN(_etext) - start;
30426
30427 + start = ktla_ktva(start);
30428 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
30429 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
30430 size >> 10);
30431 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
30432 index bb00c46..bf91a67 100644
30433 --- a/arch/x86/mm/init_64.c
30434 +++ b/arch/x86/mm/init_64.c
30435 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
30436 * around without checking the pgd every time.
30437 */
30438
30439 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
30440 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
30441 EXPORT_SYMBOL_GPL(__supported_pte_mask);
30442
30443 int force_personality32;
30444 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
30445
30446 for (address = start; address <= end; address += PGDIR_SIZE) {
30447 const pgd_t *pgd_ref = pgd_offset_k(address);
30448 +
30449 +#ifdef CONFIG_PAX_PER_CPU_PGD
30450 + unsigned long cpu;
30451 +#else
30452 struct page *page;
30453 +#endif
30454
30455 if (pgd_none(*pgd_ref))
30456 continue;
30457
30458 spin_lock(&pgd_lock);
30459 +
30460 +#ifdef CONFIG_PAX_PER_CPU_PGD
30461 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
30462 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
30463 +
30464 + if (pgd_none(*pgd))
30465 + set_pgd(pgd, *pgd_ref);
30466 + else
30467 + BUG_ON(pgd_page_vaddr(*pgd)
30468 + != pgd_page_vaddr(*pgd_ref));
30469 + pgd = pgd_offset_cpu(cpu, kernel, address);
30470 +#else
30471 list_for_each_entry(page, &pgd_list, lru) {
30472 pgd_t *pgd;
30473 spinlock_t *pgt_lock;
30474 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
30475 /* the pgt_lock only for Xen */
30476 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
30477 spin_lock(pgt_lock);
30478 +#endif
30479
30480 if (pgd_none(*pgd))
30481 set_pgd(pgd, *pgd_ref);
30482 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
30483 BUG_ON(pgd_page_vaddr(*pgd)
30484 != pgd_page_vaddr(*pgd_ref));
30485
30486 +#ifndef CONFIG_PAX_PER_CPU_PGD
30487 spin_unlock(pgt_lock);
30488 +#endif
30489 +
30490 }
30491 spin_unlock(&pgd_lock);
30492 }
30493 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
30494 {
30495 if (pgd_none(*pgd)) {
30496 pud_t *pud = (pud_t *)spp_getpage();
30497 - pgd_populate(&init_mm, pgd, pud);
30498 + pgd_populate_kernel(&init_mm, pgd, pud);
30499 if (pud != pud_offset(pgd, 0))
30500 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
30501 pud, pud_offset(pgd, 0));
30502 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
30503 {
30504 if (pud_none(*pud)) {
30505 pmd_t *pmd = (pmd_t *) spp_getpage();
30506 - pud_populate(&init_mm, pud, pmd);
30507 + pud_populate_kernel(&init_mm, pud, pmd);
30508 if (pmd != pmd_offset(pud, 0))
30509 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
30510 pmd, pmd_offset(pud, 0));
30511 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
30512 pmd = fill_pmd(pud, vaddr);
30513 pte = fill_pte(pmd, vaddr);
30514
30515 + pax_open_kernel();
30516 set_pte(pte, new_pte);
30517 + pax_close_kernel();
30518
30519 /*
30520 * It's enough to flush this one mapping.
30521 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
30522 pgd = pgd_offset_k((unsigned long)__va(phys));
30523 if (pgd_none(*pgd)) {
30524 pud = (pud_t *) spp_getpage();
30525 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
30526 - _PAGE_USER));
30527 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
30528 }
30529 pud = pud_offset(pgd, (unsigned long)__va(phys));
30530 if (pud_none(*pud)) {
30531 pmd = (pmd_t *) spp_getpage();
30532 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
30533 - _PAGE_USER));
30534 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
30535 }
30536 pmd = pmd_offset(pud, phys);
30537 BUG_ON(!pmd_none(*pmd));
30538 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
30539 prot);
30540
30541 spin_lock(&init_mm.page_table_lock);
30542 - pud_populate(&init_mm, pud, pmd);
30543 + pud_populate_kernel(&init_mm, pud, pmd);
30544 spin_unlock(&init_mm.page_table_lock);
30545 }
30546 __flush_tlb_all();
30547 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
30548 page_size_mask);
30549
30550 spin_lock(&init_mm.page_table_lock);
30551 - pgd_populate(&init_mm, pgd, pud);
30552 + pgd_populate_kernel(&init_mm, pgd, pud);
30553 spin_unlock(&init_mm.page_table_lock);
30554 pgd_changed = true;
30555 }
30556 @@ -1221,8 +1242,8 @@ int kern_addr_valid(unsigned long addr)
30557 static struct vm_area_struct gate_vma = {
30558 .vm_start = VSYSCALL_START,
30559 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
30560 - .vm_page_prot = PAGE_READONLY_EXEC,
30561 - .vm_flags = VM_READ | VM_EXEC
30562 + .vm_page_prot = PAGE_READONLY,
30563 + .vm_flags = VM_READ
30564 };
30565
30566 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
30567 @@ -1256,7 +1277,7 @@ int in_gate_area_no_mm(unsigned long addr)
30568
30569 const char *arch_vma_name(struct vm_area_struct *vma)
30570 {
30571 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
30572 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
30573 return "[vdso]";
30574 if (vma == &gate_vma)
30575 return "[vsyscall]";
30576 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
30577 index 7b179b4..6bd17777 100644
30578 --- a/arch/x86/mm/iomap_32.c
30579 +++ b/arch/x86/mm/iomap_32.c
30580 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
30581 type = kmap_atomic_idx_push();
30582 idx = type + KM_TYPE_NR * smp_processor_id();
30583 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30584 +
30585 + pax_open_kernel();
30586 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
30587 + pax_close_kernel();
30588 +
30589 arch_flush_lazy_mmu_mode();
30590
30591 return (void *)vaddr;
30592 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
30593 index 9a1e658..da003f3 100644
30594 --- a/arch/x86/mm/ioremap.c
30595 +++ b/arch/x86/mm/ioremap.c
30596 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
30597 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
30598 int is_ram = page_is_ram(pfn);
30599
30600 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
30601 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
30602 return NULL;
30603 WARN_ON_ONCE(is_ram);
30604 }
30605 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
30606 *
30607 * Caller must ensure there is only one unmapping for the same pointer.
30608 */
30609 -void iounmap(volatile void __iomem *addr)
30610 +void iounmap(const volatile void __iomem *addr)
30611 {
30612 struct vm_struct *p, *o;
30613
30614 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
30615
30616 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
30617 if (page_is_ram(start >> PAGE_SHIFT))
30618 +#ifdef CONFIG_HIGHMEM
30619 + if ((start >> PAGE_SHIFT) < max_low_pfn)
30620 +#endif
30621 return __va(phys);
30622
30623 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
30624 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
30625 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
30626 {
30627 if (page_is_ram(phys >> PAGE_SHIFT))
30628 +#ifdef CONFIG_HIGHMEM
30629 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
30630 +#endif
30631 return;
30632
30633 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
30634 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
30635 early_param("early_ioremap_debug", early_ioremap_debug_setup);
30636
30637 static __initdata int after_paging_init;
30638 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
30639 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
30640
30641 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
30642 {
30643 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
30644 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
30645
30646 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
30647 - memset(bm_pte, 0, sizeof(bm_pte));
30648 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
30649 + pmd_populate_user(&init_mm, pmd, bm_pte);
30650
30651 /*
30652 * The boot-ioremap range spans multiple pmds, for which
30653 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
30654 index d87dd6d..bf3fa66 100644
30655 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
30656 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
30657 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
30658 * memory (e.g. tracked pages)? For now, we need this to avoid
30659 * invoking kmemcheck for PnP BIOS calls.
30660 */
30661 - if (regs->flags & X86_VM_MASK)
30662 + if (v8086_mode(regs))
30663 return false;
30664 - if (regs->cs != __KERNEL_CS)
30665 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
30666 return false;
30667
30668 pte = kmemcheck_pte_lookup(address);
30669 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
30670 index 845df68..1d8d29f 100644
30671 --- a/arch/x86/mm/mmap.c
30672 +++ b/arch/x86/mm/mmap.c
30673 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
30674 * Leave an at least ~128 MB hole with possible stack randomization.
30675 */
30676 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
30677 -#define MAX_GAP (TASK_SIZE/6*5)
30678 +#define MAX_GAP (pax_task_size/6*5)
30679
30680 static int mmap_is_legacy(void)
30681 {
30682 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
30683 return rnd << PAGE_SHIFT;
30684 }
30685
30686 -static unsigned long mmap_base(void)
30687 +static unsigned long mmap_base(struct mm_struct *mm)
30688 {
30689 unsigned long gap = rlimit(RLIMIT_STACK);
30690 + unsigned long pax_task_size = TASK_SIZE;
30691 +
30692 +#ifdef CONFIG_PAX_SEGMEXEC
30693 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30694 + pax_task_size = SEGMEXEC_TASK_SIZE;
30695 +#endif
30696
30697 if (gap < MIN_GAP)
30698 gap = MIN_GAP;
30699 else if (gap > MAX_GAP)
30700 gap = MAX_GAP;
30701
30702 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
30703 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
30704 }
30705
30706 /*
30707 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
30708 * does, but not when emulating X86_32
30709 */
30710 -static unsigned long mmap_legacy_base(void)
30711 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
30712 {
30713 - if (mmap_is_ia32())
30714 + if (mmap_is_ia32()) {
30715 +
30716 +#ifdef CONFIG_PAX_SEGMEXEC
30717 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30718 + return SEGMEXEC_TASK_UNMAPPED_BASE;
30719 + else
30720 +#endif
30721 +
30722 return TASK_UNMAPPED_BASE;
30723 - else
30724 + } else
30725 return TASK_UNMAPPED_BASE + mmap_rnd();
30726 }
30727
30728 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
30729 void arch_pick_mmap_layout(struct mm_struct *mm)
30730 {
30731 if (mmap_is_legacy()) {
30732 - mm->mmap_base = mmap_legacy_base();
30733 + mm->mmap_base = mmap_legacy_base(mm);
30734 +
30735 +#ifdef CONFIG_PAX_RANDMMAP
30736 + if (mm->pax_flags & MF_PAX_RANDMMAP)
30737 + mm->mmap_base += mm->delta_mmap;
30738 +#endif
30739 +
30740 mm->get_unmapped_area = arch_get_unmapped_area;
30741 mm->unmap_area = arch_unmap_area;
30742 } else {
30743 - mm->mmap_base = mmap_base();
30744 + mm->mmap_base = mmap_base(mm);
30745 +
30746 +#ifdef CONFIG_PAX_RANDMMAP
30747 + if (mm->pax_flags & MF_PAX_RANDMMAP)
30748 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
30749 +#endif
30750 +
30751 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
30752 mm->unmap_area = arch_unmap_area_topdown;
30753 }
30754 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
30755 index dc0b727..f612039 100644
30756 --- a/arch/x86/mm/mmio-mod.c
30757 +++ b/arch/x86/mm/mmio-mod.c
30758 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
30759 break;
30760 default:
30761 {
30762 - unsigned char *ip = (unsigned char *)instptr;
30763 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
30764 my_trace->opcode = MMIO_UNKNOWN_OP;
30765 my_trace->width = 0;
30766 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
30767 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
30768 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
30769 void __iomem *addr)
30770 {
30771 - static atomic_t next_id;
30772 + static atomic_unchecked_t next_id;
30773 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
30774 /* These are page-unaligned. */
30775 struct mmiotrace_map map = {
30776 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
30777 .private = trace
30778 },
30779 .phys = offset,
30780 - .id = atomic_inc_return(&next_id)
30781 + .id = atomic_inc_return_unchecked(&next_id)
30782 };
30783 map.map_id = trace->id;
30784
30785 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
30786 ioremap_trace_core(offset, size, addr);
30787 }
30788
30789 -static void iounmap_trace_core(volatile void __iomem *addr)
30790 +static void iounmap_trace_core(const volatile void __iomem *addr)
30791 {
30792 struct mmiotrace_map map = {
30793 .phys = 0,
30794 @@ -328,7 +328,7 @@ not_enabled:
30795 }
30796 }
30797
30798 -void mmiotrace_iounmap(volatile void __iomem *addr)
30799 +void mmiotrace_iounmap(const volatile void __iomem *addr)
30800 {
30801 might_sleep();
30802 if (is_enabled()) /* recheck and proper locking in *_core() */
30803 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
30804 index a71c4e2..301ae44 100644
30805 --- a/arch/x86/mm/numa.c
30806 +++ b/arch/x86/mm/numa.c
30807 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
30808 return true;
30809 }
30810
30811 -static int __init numa_register_memblks(struct numa_meminfo *mi)
30812 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
30813 {
30814 unsigned long uninitialized_var(pfn_align);
30815 int i, nid;
30816 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
30817 index d0b1773..4c3327c 100644
30818 --- a/arch/x86/mm/pageattr-test.c
30819 +++ b/arch/x86/mm/pageattr-test.c
30820 @@ -36,7 +36,7 @@ enum {
30821
30822 static int pte_testbit(pte_t pte)
30823 {
30824 - return pte_flags(pte) & _PAGE_UNUSED1;
30825 + return pte_flags(pte) & _PAGE_CPA_TEST;
30826 }
30827
30828 struct split_state {
30829 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
30830 index bb32480..75f2f5e 100644
30831 --- a/arch/x86/mm/pageattr.c
30832 +++ b/arch/x86/mm/pageattr.c
30833 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
30834 */
30835 #ifdef CONFIG_PCI_BIOS
30836 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
30837 - pgprot_val(forbidden) |= _PAGE_NX;
30838 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
30839 #endif
30840
30841 /*
30842 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
30843 * Does not cover __inittext since that is gone later on. On
30844 * 64bit we do not enforce !NX on the low mapping
30845 */
30846 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
30847 - pgprot_val(forbidden) |= _PAGE_NX;
30848 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
30849 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
30850
30851 +#ifdef CONFIG_DEBUG_RODATA
30852 /*
30853 * The .rodata section needs to be read-only. Using the pfn
30854 * catches all aliases.
30855 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
30856 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
30857 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
30858 pgprot_val(forbidden) |= _PAGE_RW;
30859 +#endif
30860
30861 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
30862 /*
30863 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
30864 }
30865 #endif
30866
30867 +#ifdef CONFIG_PAX_KERNEXEC
30868 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
30869 + pgprot_val(forbidden) |= _PAGE_RW;
30870 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
30871 + }
30872 +#endif
30873 +
30874 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
30875
30876 return prot;
30877 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
30878 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
30879 {
30880 /* change init_mm */
30881 + pax_open_kernel();
30882 set_pte_atomic(kpte, pte);
30883 +
30884 #ifdef CONFIG_X86_32
30885 if (!SHARED_KERNEL_PMD) {
30886 +
30887 +#ifdef CONFIG_PAX_PER_CPU_PGD
30888 + unsigned long cpu;
30889 +#else
30890 struct page *page;
30891 +#endif
30892
30893 +#ifdef CONFIG_PAX_PER_CPU_PGD
30894 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
30895 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
30896 +#else
30897 list_for_each_entry(page, &pgd_list, lru) {
30898 - pgd_t *pgd;
30899 + pgd_t *pgd = (pgd_t *)page_address(page);
30900 +#endif
30901 +
30902 pud_t *pud;
30903 pmd_t *pmd;
30904
30905 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
30906 + pgd += pgd_index(address);
30907 pud = pud_offset(pgd, address);
30908 pmd = pmd_offset(pud, address);
30909 set_pte_atomic((pte_t *)pmd, pte);
30910 }
30911 }
30912 #endif
30913 + pax_close_kernel();
30914 }
30915
30916 static int
30917 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
30918 index 6574388..87e9bef 100644
30919 --- a/arch/x86/mm/pat.c
30920 +++ b/arch/x86/mm/pat.c
30921 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
30922
30923 if (!entry) {
30924 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
30925 - current->comm, current->pid, start, end - 1);
30926 + current->comm, task_pid_nr(current), start, end - 1);
30927 return -EINVAL;
30928 }
30929
30930 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
30931
30932 while (cursor < to) {
30933 if (!devmem_is_allowed(pfn)) {
30934 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
30935 - current->comm, from, to - 1);
30936 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
30937 + current->comm, from, to - 1, cursor);
30938 return 0;
30939 }
30940 cursor += PAGE_SIZE;
30941 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
30942 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
30943 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
30944 "for [mem %#010Lx-%#010Lx]\n",
30945 - current->comm, current->pid,
30946 + current->comm, task_pid_nr(current),
30947 cattr_name(flags),
30948 base, (unsigned long long)(base + size-1));
30949 return -EINVAL;
30950 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
30951 flags = lookup_memtype(paddr);
30952 if (want_flags != flags) {
30953 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
30954 - current->comm, current->pid,
30955 + current->comm, task_pid_nr(current),
30956 cattr_name(want_flags),
30957 (unsigned long long)paddr,
30958 (unsigned long long)(paddr + size - 1),
30959 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
30960 free_memtype(paddr, paddr + size);
30961 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
30962 " for [mem %#010Lx-%#010Lx], got %s\n",
30963 - current->comm, current->pid,
30964 + current->comm, task_pid_nr(current),
30965 cattr_name(want_flags),
30966 (unsigned long long)paddr,
30967 (unsigned long long)(paddr + size - 1),
30968 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
30969 index 415f6c4..d319983 100644
30970 --- a/arch/x86/mm/pat_rbtree.c
30971 +++ b/arch/x86/mm/pat_rbtree.c
30972 @@ -160,7 +160,7 @@ success:
30973
30974 failure:
30975 printk(KERN_INFO "%s:%d conflicting memory types "
30976 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
30977 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
30978 end, cattr_name(found_type), cattr_name(match->type));
30979 return -EBUSY;
30980 }
30981 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
30982 index 9f0614d..92ae64a 100644
30983 --- a/arch/x86/mm/pf_in.c
30984 +++ b/arch/x86/mm/pf_in.c
30985 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
30986 int i;
30987 enum reason_type rv = OTHERS;
30988
30989 - p = (unsigned char *)ins_addr;
30990 + p = (unsigned char *)ktla_ktva(ins_addr);
30991 p += skip_prefix(p, &prf);
30992 p += get_opcode(p, &opcode);
30993
30994 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
30995 struct prefix_bits prf;
30996 int i;
30997
30998 - p = (unsigned char *)ins_addr;
30999 + p = (unsigned char *)ktla_ktva(ins_addr);
31000 p += skip_prefix(p, &prf);
31001 p += get_opcode(p, &opcode);
31002
31003 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31004 struct prefix_bits prf;
31005 int i;
31006
31007 - p = (unsigned char *)ins_addr;
31008 + p = (unsigned char *)ktla_ktva(ins_addr);
31009 p += skip_prefix(p, &prf);
31010 p += get_opcode(p, &opcode);
31011
31012 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31013 struct prefix_bits prf;
31014 int i;
31015
31016 - p = (unsigned char *)ins_addr;
31017 + p = (unsigned char *)ktla_ktva(ins_addr);
31018 p += skip_prefix(p, &prf);
31019 p += get_opcode(p, &opcode);
31020 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31021 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31022 struct prefix_bits prf;
31023 int i;
31024
31025 - p = (unsigned char *)ins_addr;
31026 + p = (unsigned char *)ktla_ktva(ins_addr);
31027 p += skip_prefix(p, &prf);
31028 p += get_opcode(p, &opcode);
31029 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31030 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31031 index 17fda6a..f7d54a0 100644
31032 --- a/arch/x86/mm/pgtable.c
31033 +++ b/arch/x86/mm/pgtable.c
31034 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31035 list_del(&page->lru);
31036 }
31037
31038 -#define UNSHARED_PTRS_PER_PGD \
31039 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31040 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31041 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31042
31043 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31044 +{
31045 + unsigned int count = USER_PGD_PTRS;
31046
31047 + if (!pax_user_shadow_base)
31048 + return;
31049 +
31050 + while (count--)
31051 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31052 +}
31053 +#endif
31054 +
31055 +#ifdef CONFIG_PAX_PER_CPU_PGD
31056 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31057 +{
31058 + unsigned int count = USER_PGD_PTRS;
31059 +
31060 + while (count--) {
31061 + pgd_t pgd;
31062 +
31063 +#ifdef CONFIG_X86_64
31064 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31065 +#else
31066 + pgd = *src++;
31067 +#endif
31068 +
31069 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31070 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31071 +#endif
31072 +
31073 + *dst++ = pgd;
31074 + }
31075 +
31076 +}
31077 +#endif
31078 +
31079 +#ifdef CONFIG_X86_64
31080 +#define pxd_t pud_t
31081 +#define pyd_t pgd_t
31082 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31083 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31084 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31085 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31086 +#define PYD_SIZE PGDIR_SIZE
31087 +#else
31088 +#define pxd_t pmd_t
31089 +#define pyd_t pud_t
31090 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31091 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31092 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31093 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31094 +#define PYD_SIZE PUD_SIZE
31095 +#endif
31096 +
31097 +#ifdef CONFIG_PAX_PER_CPU_PGD
31098 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31099 +static inline void pgd_dtor(pgd_t *pgd) {}
31100 +#else
31101 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31102 {
31103 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31104 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31105 pgd_list_del(pgd);
31106 spin_unlock(&pgd_lock);
31107 }
31108 +#endif
31109
31110 /*
31111 * List of all pgd's needed for non-PAE so it can invalidate entries
31112 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31113 * -- nyc
31114 */
31115
31116 -#ifdef CONFIG_X86_PAE
31117 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31118 /*
31119 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31120 * updating the top-level pagetable entries to guarantee the
31121 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31122 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31123 * and initialize the kernel pmds here.
31124 */
31125 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31126 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31127
31128 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31129 {
31130 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31131 */
31132 flush_tlb_mm(mm);
31133 }
31134 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31135 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31136 #else /* !CONFIG_X86_PAE */
31137
31138 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31139 -#define PREALLOCATED_PMDS 0
31140 +#define PREALLOCATED_PXDS 0
31141
31142 #endif /* CONFIG_X86_PAE */
31143
31144 -static void free_pmds(pmd_t *pmds[])
31145 +static void free_pxds(pxd_t *pxds[])
31146 {
31147 int i;
31148
31149 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31150 - if (pmds[i])
31151 - free_page((unsigned long)pmds[i]);
31152 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31153 + if (pxds[i])
31154 + free_page((unsigned long)pxds[i]);
31155 }
31156
31157 -static int preallocate_pmds(pmd_t *pmds[])
31158 +static int preallocate_pxds(pxd_t *pxds[])
31159 {
31160 int i;
31161 bool failed = false;
31162
31163 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31164 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31165 - if (pmd == NULL)
31166 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31167 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31168 + if (pxd == NULL)
31169 failed = true;
31170 - pmds[i] = pmd;
31171 + pxds[i] = pxd;
31172 }
31173
31174 if (failed) {
31175 - free_pmds(pmds);
31176 + free_pxds(pxds);
31177 return -ENOMEM;
31178 }
31179
31180 @@ -219,51 +279,55 @@ static int preallocate_pmds(pmd_t *pmds[])
31181 * preallocate which never got a corresponding vma will need to be
31182 * freed manually.
31183 */
31184 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31185 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31186 {
31187 int i;
31188
31189 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31190 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31191 pgd_t pgd = pgdp[i];
31192
31193 if (pgd_val(pgd) != 0) {
31194 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31195 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31196
31197 - pgdp[i] = native_make_pgd(0);
31198 + set_pgd(pgdp + i, native_make_pgd(0));
31199
31200 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31201 - pmd_free(mm, pmd);
31202 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31203 + pxd_free(mm, pxd);
31204 }
31205 }
31206 }
31207
31208 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31209 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31210 {
31211 - pud_t *pud;
31212 + pyd_t *pyd;
31213 unsigned long addr;
31214 int i;
31215
31216 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31217 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31218 return;
31219
31220 - pud = pud_offset(pgd, 0);
31221 +#ifdef CONFIG_X86_64
31222 + pyd = pyd_offset(mm, 0L);
31223 +#else
31224 + pyd = pyd_offset(pgd, 0L);
31225 +#endif
31226
31227 - for (addr = i = 0; i < PREALLOCATED_PMDS;
31228 - i++, pud++, addr += PUD_SIZE) {
31229 - pmd_t *pmd = pmds[i];
31230 + for (addr = i = 0; i < PREALLOCATED_PXDS;
31231 + i++, pyd++, addr += PYD_SIZE) {
31232 + pxd_t *pxd = pxds[i];
31233
31234 if (i >= KERNEL_PGD_BOUNDARY)
31235 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31236 - sizeof(pmd_t) * PTRS_PER_PMD);
31237 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31238 + sizeof(pxd_t) * PTRS_PER_PMD);
31239
31240 - pud_populate(mm, pud, pmd);
31241 + pyd_populate(mm, pyd, pxd);
31242 }
31243 }
31244
31245 pgd_t *pgd_alloc(struct mm_struct *mm)
31246 {
31247 pgd_t *pgd;
31248 - pmd_t *pmds[PREALLOCATED_PMDS];
31249 + pxd_t *pxds[PREALLOCATED_PXDS];
31250
31251 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
31252
31253 @@ -272,11 +336,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
31254
31255 mm->pgd = pgd;
31256
31257 - if (preallocate_pmds(pmds) != 0)
31258 + if (preallocate_pxds(pxds) != 0)
31259 goto out_free_pgd;
31260
31261 if (paravirt_pgd_alloc(mm) != 0)
31262 - goto out_free_pmds;
31263 + goto out_free_pxds;
31264
31265 /*
31266 * Make sure that pre-populating the pmds is atomic with
31267 @@ -286,14 +350,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
31268 spin_lock(&pgd_lock);
31269
31270 pgd_ctor(mm, pgd);
31271 - pgd_prepopulate_pmd(mm, pgd, pmds);
31272 + pgd_prepopulate_pxd(mm, pgd, pxds);
31273
31274 spin_unlock(&pgd_lock);
31275
31276 return pgd;
31277
31278 -out_free_pmds:
31279 - free_pmds(pmds);
31280 +out_free_pxds:
31281 + free_pxds(pxds);
31282 out_free_pgd:
31283 free_page((unsigned long)pgd);
31284 out:
31285 @@ -302,7 +366,7 @@ out:
31286
31287 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
31288 {
31289 - pgd_mop_up_pmds(mm, pgd);
31290 + pgd_mop_up_pxds(mm, pgd);
31291 pgd_dtor(pgd);
31292 paravirt_pgd_free(mm, pgd);
31293 free_page((unsigned long)pgd);
31294 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
31295 index a69bcb8..19068ab 100644
31296 --- a/arch/x86/mm/pgtable_32.c
31297 +++ b/arch/x86/mm/pgtable_32.c
31298 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
31299 return;
31300 }
31301 pte = pte_offset_kernel(pmd, vaddr);
31302 +
31303 + pax_open_kernel();
31304 if (pte_val(pteval))
31305 set_pte_at(&init_mm, vaddr, pte, pteval);
31306 else
31307 pte_clear(&init_mm, vaddr, pte);
31308 + pax_close_kernel();
31309
31310 /*
31311 * It's enough to flush this one mapping.
31312 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
31313 index e666cbb..61788c45 100644
31314 --- a/arch/x86/mm/physaddr.c
31315 +++ b/arch/x86/mm/physaddr.c
31316 @@ -10,7 +10,7 @@
31317 #ifdef CONFIG_X86_64
31318
31319 #ifdef CONFIG_DEBUG_VIRTUAL
31320 -unsigned long __phys_addr(unsigned long x)
31321 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
31322 {
31323 unsigned long y = x - __START_KERNEL_map;
31324
31325 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
31326 #else
31327
31328 #ifdef CONFIG_DEBUG_VIRTUAL
31329 -unsigned long __phys_addr(unsigned long x)
31330 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
31331 {
31332 unsigned long phys_addr = x - PAGE_OFFSET;
31333 /* VMALLOC_* aren't constants */
31334 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
31335 index 410531d..0f16030 100644
31336 --- a/arch/x86/mm/setup_nx.c
31337 +++ b/arch/x86/mm/setup_nx.c
31338 @@ -5,8 +5,10 @@
31339 #include <asm/pgtable.h>
31340 #include <asm/proto.h>
31341
31342 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31343 static int disable_nx __cpuinitdata;
31344
31345 +#ifndef CONFIG_PAX_PAGEEXEC
31346 /*
31347 * noexec = on|off
31348 *
31349 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
31350 return 0;
31351 }
31352 early_param("noexec", noexec_setup);
31353 +#endif
31354 +
31355 +#endif
31356
31357 void __cpuinit x86_configure_nx(void)
31358 {
31359 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31360 if (cpu_has_nx && !disable_nx)
31361 __supported_pte_mask |= _PAGE_NX;
31362 else
31363 +#endif
31364 __supported_pte_mask &= ~_PAGE_NX;
31365 }
31366
31367 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
31368 index 282375f..e03a98f 100644
31369 --- a/arch/x86/mm/tlb.c
31370 +++ b/arch/x86/mm/tlb.c
31371 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
31372 BUG();
31373 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
31374 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
31375 +
31376 +#ifndef CONFIG_PAX_PER_CPU_PGD
31377 load_cr3(swapper_pg_dir);
31378 +#endif
31379 +
31380 }
31381 }
31382 EXPORT_SYMBOL_GPL(leave_mm);
31383 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
31384 new file mode 100644
31385 index 0000000..dace51c
31386 --- /dev/null
31387 +++ b/arch/x86/mm/uderef_64.c
31388 @@ -0,0 +1,37 @@
31389 +#include <linux/mm.h>
31390 +#include <asm/pgtable.h>
31391 +#include <asm/uaccess.h>
31392 +
31393 +#ifdef CONFIG_PAX_MEMORY_UDEREF
31394 +/* PaX: due to the special call convention these functions must
31395 + * - remain leaf functions under all configurations,
31396 + * - never be called directly, only dereferenced from the wrappers.
31397 + */
31398 +void __pax_open_userland(void)
31399 +{
31400 + unsigned int cpu;
31401 +
31402 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
31403 + return;
31404 +
31405 + cpu = raw_get_cpu();
31406 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
31407 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
31408 + raw_put_cpu_no_resched();
31409 +}
31410 +EXPORT_SYMBOL(__pax_open_userland);
31411 +
31412 +void __pax_close_userland(void)
31413 +{
31414 + unsigned int cpu;
31415 +
31416 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
31417 + return;
31418 +
31419 + cpu = raw_get_cpu();
31420 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
31421 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
31422 + raw_put_cpu_no_resched();
31423 +}
31424 +EXPORT_SYMBOL(__pax_close_userland);
31425 +#endif
31426 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
31427 index 877b9a1..a8ecf42 100644
31428 --- a/arch/x86/net/bpf_jit.S
31429 +++ b/arch/x86/net/bpf_jit.S
31430 @@ -9,6 +9,7 @@
31431 */
31432 #include <linux/linkage.h>
31433 #include <asm/dwarf2.h>
31434 +#include <asm/alternative-asm.h>
31435
31436 /*
31437 * Calling convention :
31438 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
31439 jle bpf_slow_path_word
31440 mov (SKBDATA,%rsi),%eax
31441 bswap %eax /* ntohl() */
31442 + pax_force_retaddr
31443 ret
31444
31445 sk_load_half:
31446 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
31447 jle bpf_slow_path_half
31448 movzwl (SKBDATA,%rsi),%eax
31449 rol $8,%ax # ntohs()
31450 + pax_force_retaddr
31451 ret
31452
31453 sk_load_byte:
31454 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
31455 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
31456 jle bpf_slow_path_byte
31457 movzbl (SKBDATA,%rsi),%eax
31458 + pax_force_retaddr
31459 ret
31460
31461 /**
31462 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
31463 movzbl (SKBDATA,%rsi),%ebx
31464 and $15,%bl
31465 shl $2,%bl
31466 + pax_force_retaddr
31467 ret
31468
31469 /* rsi contains offset and can be scratched */
31470 @@ -109,6 +114,7 @@ bpf_slow_path_word:
31471 js bpf_error
31472 mov -12(%rbp),%eax
31473 bswap %eax
31474 + pax_force_retaddr
31475 ret
31476
31477 bpf_slow_path_half:
31478 @@ -117,12 +123,14 @@ bpf_slow_path_half:
31479 mov -12(%rbp),%ax
31480 rol $8,%ax
31481 movzwl %ax,%eax
31482 + pax_force_retaddr
31483 ret
31484
31485 bpf_slow_path_byte:
31486 bpf_slow_path_common(1)
31487 js bpf_error
31488 movzbl -12(%rbp),%eax
31489 + pax_force_retaddr
31490 ret
31491
31492 bpf_slow_path_byte_msh:
31493 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
31494 and $15,%al
31495 shl $2,%al
31496 xchg %eax,%ebx
31497 + pax_force_retaddr
31498 ret
31499
31500 #define sk_negative_common(SIZE) \
31501 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
31502 sk_negative_common(4)
31503 mov (%rax), %eax
31504 bswap %eax
31505 + pax_force_retaddr
31506 ret
31507
31508 bpf_slow_path_half_neg:
31509 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
31510 mov (%rax),%ax
31511 rol $8,%ax
31512 movzwl %ax,%eax
31513 + pax_force_retaddr
31514 ret
31515
31516 bpf_slow_path_byte_neg:
31517 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
31518 .globl sk_load_byte_negative_offset
31519 sk_negative_common(1)
31520 movzbl (%rax), %eax
31521 + pax_force_retaddr
31522 ret
31523
31524 bpf_slow_path_byte_msh_neg:
31525 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
31526 and $15,%al
31527 shl $2,%al
31528 xchg %eax,%ebx
31529 + pax_force_retaddr
31530 ret
31531
31532 bpf_error:
31533 @@ -197,4 +210,5 @@ bpf_error:
31534 xor %eax,%eax
31535 mov -8(%rbp),%rbx
31536 leaveq
31537 + pax_force_retaddr
31538 ret
31539 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
31540 index f66b540..3e88dfb 100644
31541 --- a/arch/x86/net/bpf_jit_comp.c
31542 +++ b/arch/x86/net/bpf_jit_comp.c
31543 @@ -12,6 +12,7 @@
31544 #include <linux/netdevice.h>
31545 #include <linux/filter.h>
31546 #include <linux/if_vlan.h>
31547 +#include <linux/random.h>
31548
31549 /*
31550 * Conventions :
31551 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
31552 return ptr + len;
31553 }
31554
31555 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31556 +#define MAX_INSTR_CODE_SIZE 96
31557 +#else
31558 +#define MAX_INSTR_CODE_SIZE 64
31559 +#endif
31560 +
31561 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
31562
31563 #define EMIT1(b1) EMIT(b1, 1)
31564 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
31565 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
31566 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
31567 +
31568 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31569 +/* original constant will appear in ecx */
31570 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
31571 +do { \
31572 + /* mov ecx, randkey */ \
31573 + EMIT1(0xb9); \
31574 + EMIT(_key, 4); \
31575 + /* xor ecx, randkey ^ off */ \
31576 + EMIT2(0x81, 0xf1); \
31577 + EMIT((_key) ^ (_off), 4); \
31578 +} while (0)
31579 +
31580 +#define EMIT1_off32(b1, _off) \
31581 +do { \
31582 + switch (b1) { \
31583 + case 0x05: /* add eax, imm32 */ \
31584 + case 0x2d: /* sub eax, imm32 */ \
31585 + case 0x25: /* and eax, imm32 */ \
31586 + case 0x0d: /* or eax, imm32 */ \
31587 + case 0xb8: /* mov eax, imm32 */ \
31588 + case 0x35: /* xor eax, imm32 */ \
31589 + case 0x3d: /* cmp eax, imm32 */ \
31590 + case 0xa9: /* test eax, imm32 */ \
31591 + DILUTE_CONST_SEQUENCE(_off, randkey); \
31592 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
31593 + break; \
31594 + case 0xbb: /* mov ebx, imm32 */ \
31595 + DILUTE_CONST_SEQUENCE(_off, randkey); \
31596 + /* mov ebx, ecx */ \
31597 + EMIT2(0x89, 0xcb); \
31598 + break; \
31599 + case 0xbe: /* mov esi, imm32 */ \
31600 + DILUTE_CONST_SEQUENCE(_off, randkey); \
31601 + /* mov esi, ecx */ \
31602 + EMIT2(0x89, 0xce); \
31603 + break; \
31604 + case 0xe8: /* call rel imm32, always to known funcs */ \
31605 + EMIT1(b1); \
31606 + EMIT(_off, 4); \
31607 + break; \
31608 + case 0xe9: /* jmp rel imm32 */ \
31609 + EMIT1(b1); \
31610 + EMIT(_off, 4); \
31611 + /* prevent fall-through, we're not called if off = 0 */ \
31612 + EMIT(0xcccccccc, 4); \
31613 + EMIT(0xcccccccc, 4); \
31614 + break; \
31615 + default: \
31616 + BUILD_BUG(); \
31617 + } \
31618 +} while (0)
31619 +
31620 +#define EMIT2_off32(b1, b2, _off) \
31621 +do { \
31622 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
31623 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
31624 + EMIT(randkey, 4); \
31625 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
31626 + EMIT((_off) - randkey, 4); \
31627 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
31628 + DILUTE_CONST_SEQUENCE(_off, randkey); \
31629 + /* imul eax, ecx */ \
31630 + EMIT3(0x0f, 0xaf, 0xc1); \
31631 + } else { \
31632 + BUILD_BUG(); \
31633 + } \
31634 +} while (0)
31635 +#else
31636 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
31637 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
31638 +#endif
31639
31640 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
31641 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
31642 @@ -90,6 +168,24 @@ do { \
31643 #define X86_JBE 0x76
31644 #define X86_JA 0x77
31645
31646 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31647 +#define APPEND_FLOW_VERIFY() \
31648 +do { \
31649 + /* mov ecx, randkey */ \
31650 + EMIT1(0xb9); \
31651 + EMIT(randkey, 4); \
31652 + /* cmp ecx, randkey */ \
31653 + EMIT2(0x81, 0xf9); \
31654 + EMIT(randkey, 4); \
31655 + /* jz after 8 int 3s */ \
31656 + EMIT2(0x74, 0x08); \
31657 + EMIT(0xcccccccc, 4); \
31658 + EMIT(0xcccccccc, 4); \
31659 +} while (0)
31660 +#else
31661 +#define APPEND_FLOW_VERIFY() do { } while (0)
31662 +#endif
31663 +
31664 #define EMIT_COND_JMP(op, offset) \
31665 do { \
31666 if (is_near(offset)) \
31667 @@ -97,6 +193,7 @@ do { \
31668 else { \
31669 EMIT2(0x0f, op + 0x10); \
31670 EMIT(offset, 4); /* jxx .+off32 */ \
31671 + APPEND_FLOW_VERIFY(); \
31672 } \
31673 } while (0)
31674
31675 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
31676 set_fs(old_fs);
31677 }
31678
31679 +struct bpf_jit_work {
31680 + struct work_struct work;
31681 + void *image;
31682 +};
31683 +
31684 #define CHOOSE_LOAD_FUNC(K, func) \
31685 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
31686
31687 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
31688
31689 void bpf_jit_compile(struct sk_filter *fp)
31690 {
31691 - u8 temp[64];
31692 + u8 temp[MAX_INSTR_CODE_SIZE];
31693 u8 *prog;
31694 unsigned int proglen, oldproglen = 0;
31695 int ilen, i;
31696 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
31697 unsigned int *addrs;
31698 const struct sock_filter *filter = fp->insns;
31699 int flen = fp->len;
31700 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31701 + unsigned int randkey;
31702 +#endif
31703
31704 if (!bpf_jit_enable)
31705 return;
31706 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
31707 if (addrs == NULL)
31708 return;
31709
31710 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
31711 + if (!fp->work)
31712 + goto out;
31713 +
31714 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31715 + randkey = get_random_int();
31716 +#endif
31717 +
31718 /* Before first pass, make a rough estimation of addrs[]
31719 - * each bpf instruction is translated to less than 64 bytes
31720 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
31721 */
31722 for (proglen = 0, i = 0; i < flen; i++) {
31723 - proglen += 64;
31724 + proglen += MAX_INSTR_CODE_SIZE;
31725 addrs[i] = proglen;
31726 }
31727 cleanup_addr = proglen; /* epilogue address */
31728 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
31729 case BPF_S_ALU_MUL_K: /* A *= K */
31730 if (is_imm8(K))
31731 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
31732 - else {
31733 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
31734 - EMIT(K, 4);
31735 - }
31736 + else
31737 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
31738 break;
31739 case BPF_S_ALU_DIV_X: /* A /= X; */
31740 seen |= SEEN_XREG;
31741 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
31742 break;
31743 case BPF_S_ALU_MOD_K: /* A %= K; */
31744 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
31745 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31746 + DILUTE_CONST_SEQUENCE(K, randkey);
31747 +#else
31748 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
31749 +#endif
31750 EMIT2(0xf7, 0xf1); /* div %ecx */
31751 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
31752 break;
31753 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
31754 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31755 + DILUTE_CONST_SEQUENCE(K, randkey);
31756 + // imul rax, rcx
31757 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
31758 +#else
31759 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
31760 EMIT(K, 4);
31761 +#endif
31762 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
31763 break;
31764 case BPF_S_ALU_AND_X:
31765 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
31766 if (is_imm8(K)) {
31767 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
31768 } else {
31769 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
31770 - EMIT(K, 4);
31771 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
31772 }
31773 } else {
31774 EMIT2(0x89,0xde); /* mov %ebx,%esi */
31775 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
31776 break;
31777 default:
31778 /* hmm, too complex filter, give up with jit compiler */
31779 - goto out;
31780 + goto error;
31781 }
31782 ilen = prog - temp;
31783 if (image) {
31784 if (unlikely(proglen + ilen > oldproglen)) {
31785 pr_err("bpb_jit_compile fatal error\n");
31786 - kfree(addrs);
31787 - module_free(NULL, image);
31788 - return;
31789 + module_free_exec(NULL, image);
31790 + goto error;
31791 }
31792 + pax_open_kernel();
31793 memcpy(image + proglen, temp, ilen);
31794 + pax_close_kernel();
31795 }
31796 proglen += ilen;
31797 addrs[i] = proglen;
31798 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
31799 break;
31800 }
31801 if (proglen == oldproglen) {
31802 - image = module_alloc(max_t(unsigned int,
31803 - proglen,
31804 - sizeof(struct work_struct)));
31805 + image = module_alloc_exec(proglen);
31806 if (!image)
31807 - goto out;
31808 + goto error;
31809 }
31810 oldproglen = proglen;
31811 }
31812 @@ -732,7 +851,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
31813 if (image) {
31814 bpf_flush_icache(image, image + proglen);
31815 fp->bpf_func = (void *)image;
31816 - }
31817 + } else
31818 +error:
31819 + kfree(fp->work);
31820 +
31821 out:
31822 kfree(addrs);
31823 return;
31824 @@ -740,18 +862,20 @@ out:
31825
31826 static void jit_free_defer(struct work_struct *arg)
31827 {
31828 - module_free(NULL, arg);
31829 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
31830 + kfree(arg);
31831 }
31832
31833 /* run from softirq, we must use a work_struct to call
31834 - * module_free() from process context
31835 + * module_free_exec() from process context
31836 */
31837 void bpf_jit_free(struct sk_filter *fp)
31838 {
31839 if (fp->bpf_func != sk_run_filter) {
31840 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
31841 + struct work_struct *work = &fp->work->work;
31842
31843 INIT_WORK(work, jit_free_defer);
31844 + fp->work->image = fp->bpf_func;
31845 schedule_work(work);
31846 }
31847 }
31848 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
31849 index d6aa6e8..266395a 100644
31850 --- a/arch/x86/oprofile/backtrace.c
31851 +++ b/arch/x86/oprofile/backtrace.c
31852 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
31853 struct stack_frame_ia32 *fp;
31854 unsigned long bytes;
31855
31856 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
31857 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
31858 if (bytes != sizeof(bufhead))
31859 return NULL;
31860
31861 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
31862 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
31863
31864 oprofile_add_trace(bufhead[0].return_address);
31865
31866 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
31867 struct stack_frame bufhead[2];
31868 unsigned long bytes;
31869
31870 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
31871 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
31872 if (bytes != sizeof(bufhead))
31873 return NULL;
31874
31875 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
31876 {
31877 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
31878
31879 - if (!user_mode_vm(regs)) {
31880 + if (!user_mode(regs)) {
31881 unsigned long stack = kernel_stack_pointer(regs);
31882 if (depth)
31883 dump_trace(NULL, regs, (unsigned long *)stack, 0,
31884 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
31885 index 48768df..ba9143c 100644
31886 --- a/arch/x86/oprofile/nmi_int.c
31887 +++ b/arch/x86/oprofile/nmi_int.c
31888 @@ -23,6 +23,7 @@
31889 #include <asm/nmi.h>
31890 #include <asm/msr.h>
31891 #include <asm/apic.h>
31892 +#include <asm/pgtable.h>
31893
31894 #include "op_counter.h"
31895 #include "op_x86_model.h"
31896 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
31897 if (ret)
31898 return ret;
31899
31900 - if (!model->num_virt_counters)
31901 - model->num_virt_counters = model->num_counters;
31902 + if (!model->num_virt_counters) {
31903 + pax_open_kernel();
31904 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
31905 + pax_close_kernel();
31906 + }
31907
31908 mux_init(ops);
31909
31910 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
31911 index b2b9443..be58856 100644
31912 --- a/arch/x86/oprofile/op_model_amd.c
31913 +++ b/arch/x86/oprofile/op_model_amd.c
31914 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
31915 num_counters = AMD64_NUM_COUNTERS;
31916 }
31917
31918 - op_amd_spec.num_counters = num_counters;
31919 - op_amd_spec.num_controls = num_counters;
31920 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
31921 + pax_open_kernel();
31922 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
31923 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
31924 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
31925 + pax_close_kernel();
31926
31927 return 0;
31928 }
31929 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
31930 index d90528e..0127e2b 100644
31931 --- a/arch/x86/oprofile/op_model_ppro.c
31932 +++ b/arch/x86/oprofile/op_model_ppro.c
31933 @@ -19,6 +19,7 @@
31934 #include <asm/msr.h>
31935 #include <asm/apic.h>
31936 #include <asm/nmi.h>
31937 +#include <asm/pgtable.h>
31938
31939 #include "op_x86_model.h"
31940 #include "op_counter.h"
31941 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
31942
31943 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
31944
31945 - op_arch_perfmon_spec.num_counters = num_counters;
31946 - op_arch_perfmon_spec.num_controls = num_counters;
31947 + pax_open_kernel();
31948 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
31949 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
31950 + pax_close_kernel();
31951 }
31952
31953 static int arch_perfmon_init(struct oprofile_operations *ignore)
31954 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
31955 index 71e8a67..6a313bb 100644
31956 --- a/arch/x86/oprofile/op_x86_model.h
31957 +++ b/arch/x86/oprofile/op_x86_model.h
31958 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
31959 void (*switch_ctrl)(struct op_x86_model_spec const *model,
31960 struct op_msrs const * const msrs);
31961 #endif
31962 -};
31963 +} __do_const;
31964
31965 struct op_counter_config;
31966
31967 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
31968 index e9e6ed5..e47ae67 100644
31969 --- a/arch/x86/pci/amd_bus.c
31970 +++ b/arch/x86/pci/amd_bus.c
31971 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
31972 return NOTIFY_OK;
31973 }
31974
31975 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
31976 +static struct notifier_block amd_cpu_notifier = {
31977 .notifier_call = amd_cpu_notify,
31978 };
31979
31980 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
31981 index 372e9b8..e775a6c 100644
31982 --- a/arch/x86/pci/irq.c
31983 +++ b/arch/x86/pci/irq.c
31984 @@ -50,7 +50,7 @@ struct irq_router {
31985 struct irq_router_handler {
31986 u16 vendor;
31987 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
31988 -};
31989 +} __do_const;
31990
31991 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
31992 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
31993 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
31994 return 0;
31995 }
31996
31997 -static __initdata struct irq_router_handler pirq_routers[] = {
31998 +static __initconst const struct irq_router_handler pirq_routers[] = {
31999 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32000 { PCI_VENDOR_ID_AL, ali_router_probe },
32001 { PCI_VENDOR_ID_ITE, ite_router_probe },
32002 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32003 static void __init pirq_find_router(struct irq_router *r)
32004 {
32005 struct irq_routing_table *rt = pirq_table;
32006 - struct irq_router_handler *h;
32007 + const struct irq_router_handler *h;
32008
32009 #ifdef CONFIG_PCI_BIOS
32010 if (!rt->signature) {
32011 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32012 return 0;
32013 }
32014
32015 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32016 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32017 {
32018 .callback = fix_broken_hp_bios_irq9,
32019 .ident = "HP Pavilion N5400 Series Laptop",
32020 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32021 index 6eb18c4..20d83de 100644
32022 --- a/arch/x86/pci/mrst.c
32023 +++ b/arch/x86/pci/mrst.c
32024 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
32025 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
32026 pci_mmcfg_late_init();
32027 pcibios_enable_irq = mrst_pci_irq_enable;
32028 - pci_root_ops = pci_mrst_ops;
32029 + pax_open_kernel();
32030 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32031 + pax_close_kernel();
32032 pci_soc_mode = 1;
32033 /* Continue with standard init */
32034 return 1;
32035 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32036 index c77b24a..c979855 100644
32037 --- a/arch/x86/pci/pcbios.c
32038 +++ b/arch/x86/pci/pcbios.c
32039 @@ -79,7 +79,7 @@ union bios32 {
32040 static struct {
32041 unsigned long address;
32042 unsigned short segment;
32043 -} bios32_indirect = { 0, __KERNEL_CS };
32044 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32045
32046 /*
32047 * Returns the entry point for the given service, NULL on error
32048 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32049 unsigned long length; /* %ecx */
32050 unsigned long entry; /* %edx */
32051 unsigned long flags;
32052 + struct desc_struct d, *gdt;
32053
32054 local_irq_save(flags);
32055 - __asm__("lcall *(%%edi); cld"
32056 +
32057 + gdt = get_cpu_gdt_table(smp_processor_id());
32058 +
32059 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32060 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32061 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32062 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32063 +
32064 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32065 : "=a" (return_code),
32066 "=b" (address),
32067 "=c" (length),
32068 "=d" (entry)
32069 : "0" (service),
32070 "1" (0),
32071 - "D" (&bios32_indirect));
32072 + "D" (&bios32_indirect),
32073 + "r"(__PCIBIOS_DS)
32074 + : "memory");
32075 +
32076 + pax_open_kernel();
32077 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32078 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32079 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32080 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32081 + pax_close_kernel();
32082 +
32083 local_irq_restore(flags);
32084
32085 switch (return_code) {
32086 - case 0:
32087 - return address + entry;
32088 - case 0x80: /* Not present */
32089 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32090 - return 0;
32091 - default: /* Shouldn't happen */
32092 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32093 - service, return_code);
32094 + case 0: {
32095 + int cpu;
32096 + unsigned char flags;
32097 +
32098 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32099 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32100 + printk(KERN_WARNING "bios32_service: not valid\n");
32101 return 0;
32102 + }
32103 + address = address + PAGE_OFFSET;
32104 + length += 16UL; /* some BIOSs underreport this... */
32105 + flags = 4;
32106 + if (length >= 64*1024*1024) {
32107 + length >>= PAGE_SHIFT;
32108 + flags |= 8;
32109 + }
32110 +
32111 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32112 + gdt = get_cpu_gdt_table(cpu);
32113 + pack_descriptor(&d, address, length, 0x9b, flags);
32114 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32115 + pack_descriptor(&d, address, length, 0x93, flags);
32116 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32117 + }
32118 + return entry;
32119 + }
32120 + case 0x80: /* Not present */
32121 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32122 + return 0;
32123 + default: /* Shouldn't happen */
32124 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32125 + service, return_code);
32126 + return 0;
32127 }
32128 }
32129
32130 static struct {
32131 unsigned long address;
32132 unsigned short segment;
32133 -} pci_indirect = { 0, __KERNEL_CS };
32134 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32135
32136 -static int pci_bios_present;
32137 +static int pci_bios_present __read_only;
32138
32139 static int check_pcibios(void)
32140 {
32141 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32142 unsigned long flags, pcibios_entry;
32143
32144 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32145 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32146 + pci_indirect.address = pcibios_entry;
32147
32148 local_irq_save(flags);
32149 - __asm__(
32150 - "lcall *(%%edi); cld\n\t"
32151 + __asm__("movw %w6, %%ds\n\t"
32152 + "lcall *%%ss:(%%edi); cld\n\t"
32153 + "push %%ss\n\t"
32154 + "pop %%ds\n\t"
32155 "jc 1f\n\t"
32156 "xor %%ah, %%ah\n"
32157 "1:"
32158 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32159 "=b" (ebx),
32160 "=c" (ecx)
32161 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32162 - "D" (&pci_indirect)
32163 + "D" (&pci_indirect),
32164 + "r" (__PCIBIOS_DS)
32165 : "memory");
32166 local_irq_restore(flags);
32167
32168 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32169
32170 switch (len) {
32171 case 1:
32172 - __asm__("lcall *(%%esi); cld\n\t"
32173 + __asm__("movw %w6, %%ds\n\t"
32174 + "lcall *%%ss:(%%esi); cld\n\t"
32175 + "push %%ss\n\t"
32176 + "pop %%ds\n\t"
32177 "jc 1f\n\t"
32178 "xor %%ah, %%ah\n"
32179 "1:"
32180 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32181 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32182 "b" (bx),
32183 "D" ((long)reg),
32184 - "S" (&pci_indirect));
32185 + "S" (&pci_indirect),
32186 + "r" (__PCIBIOS_DS));
32187 /*
32188 * Zero-extend the result beyond 8 bits, do not trust the
32189 * BIOS having done it:
32190 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32191 *value &= 0xff;
32192 break;
32193 case 2:
32194 - __asm__("lcall *(%%esi); cld\n\t"
32195 + __asm__("movw %w6, %%ds\n\t"
32196 + "lcall *%%ss:(%%esi); cld\n\t"
32197 + "push %%ss\n\t"
32198 + "pop %%ds\n\t"
32199 "jc 1f\n\t"
32200 "xor %%ah, %%ah\n"
32201 "1:"
32202 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32203 : "1" (PCIBIOS_READ_CONFIG_WORD),
32204 "b" (bx),
32205 "D" ((long)reg),
32206 - "S" (&pci_indirect));
32207 + "S" (&pci_indirect),
32208 + "r" (__PCIBIOS_DS));
32209 /*
32210 * Zero-extend the result beyond 16 bits, do not trust the
32211 * BIOS having done it:
32212 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32213 *value &= 0xffff;
32214 break;
32215 case 4:
32216 - __asm__("lcall *(%%esi); cld\n\t"
32217 + __asm__("movw %w6, %%ds\n\t"
32218 + "lcall *%%ss:(%%esi); cld\n\t"
32219 + "push %%ss\n\t"
32220 + "pop %%ds\n\t"
32221 "jc 1f\n\t"
32222 "xor %%ah, %%ah\n"
32223 "1:"
32224 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32225 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32226 "b" (bx),
32227 "D" ((long)reg),
32228 - "S" (&pci_indirect));
32229 + "S" (&pci_indirect),
32230 + "r" (__PCIBIOS_DS));
32231 break;
32232 }
32233
32234 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32235
32236 switch (len) {
32237 case 1:
32238 - __asm__("lcall *(%%esi); cld\n\t"
32239 + __asm__("movw %w6, %%ds\n\t"
32240 + "lcall *%%ss:(%%esi); cld\n\t"
32241 + "push %%ss\n\t"
32242 + "pop %%ds\n\t"
32243 "jc 1f\n\t"
32244 "xor %%ah, %%ah\n"
32245 "1:"
32246 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32247 "c" (value),
32248 "b" (bx),
32249 "D" ((long)reg),
32250 - "S" (&pci_indirect));
32251 + "S" (&pci_indirect),
32252 + "r" (__PCIBIOS_DS));
32253 break;
32254 case 2:
32255 - __asm__("lcall *(%%esi); cld\n\t"
32256 + __asm__("movw %w6, %%ds\n\t"
32257 + "lcall *%%ss:(%%esi); cld\n\t"
32258 + "push %%ss\n\t"
32259 + "pop %%ds\n\t"
32260 "jc 1f\n\t"
32261 "xor %%ah, %%ah\n"
32262 "1:"
32263 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32264 "c" (value),
32265 "b" (bx),
32266 "D" ((long)reg),
32267 - "S" (&pci_indirect));
32268 + "S" (&pci_indirect),
32269 + "r" (__PCIBIOS_DS));
32270 break;
32271 case 4:
32272 - __asm__("lcall *(%%esi); cld\n\t"
32273 + __asm__("movw %w6, %%ds\n\t"
32274 + "lcall *%%ss:(%%esi); cld\n\t"
32275 + "push %%ss\n\t"
32276 + "pop %%ds\n\t"
32277 "jc 1f\n\t"
32278 "xor %%ah, %%ah\n"
32279 "1:"
32280 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32281 "c" (value),
32282 "b" (bx),
32283 "D" ((long)reg),
32284 - "S" (&pci_indirect));
32285 + "S" (&pci_indirect),
32286 + "r" (__PCIBIOS_DS));
32287 break;
32288 }
32289
32290 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
32291
32292 DBG("PCI: Fetching IRQ routing table... ");
32293 __asm__("push %%es\n\t"
32294 + "movw %w8, %%ds\n\t"
32295 "push %%ds\n\t"
32296 "pop %%es\n\t"
32297 - "lcall *(%%esi); cld\n\t"
32298 + "lcall *%%ss:(%%esi); cld\n\t"
32299 "pop %%es\n\t"
32300 + "push %%ss\n\t"
32301 + "pop %%ds\n"
32302 "jc 1f\n\t"
32303 "xor %%ah, %%ah\n"
32304 "1:"
32305 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
32306 "1" (0),
32307 "D" ((long) &opt),
32308 "S" (&pci_indirect),
32309 - "m" (opt)
32310 + "m" (opt),
32311 + "r" (__PCIBIOS_DS)
32312 : "memory");
32313 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
32314 if (ret & 0xff00)
32315 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
32316 {
32317 int ret;
32318
32319 - __asm__("lcall *(%%esi); cld\n\t"
32320 + __asm__("movw %w5, %%ds\n\t"
32321 + "lcall *%%ss:(%%esi); cld\n\t"
32322 + "push %%ss\n\t"
32323 + "pop %%ds\n"
32324 "jc 1f\n\t"
32325 "xor %%ah, %%ah\n"
32326 "1:"
32327 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
32328 : "0" (PCIBIOS_SET_PCI_HW_INT),
32329 "b" ((dev->bus->number << 8) | dev->devfn),
32330 "c" ((irq << 8) | (pin + 10)),
32331 - "S" (&pci_indirect));
32332 + "S" (&pci_indirect),
32333 + "r" (__PCIBIOS_DS));
32334 return !(ret & 0xff00);
32335 }
32336 EXPORT_SYMBOL(pcibios_set_irq_routing);
32337 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
32338 index 40e4469..d915bf9 100644
32339 --- a/arch/x86/platform/efi/efi_32.c
32340 +++ b/arch/x86/platform/efi/efi_32.c
32341 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
32342 {
32343 struct desc_ptr gdt_descr;
32344
32345 +#ifdef CONFIG_PAX_KERNEXEC
32346 + struct desc_struct d;
32347 +#endif
32348 +
32349 local_irq_save(efi_rt_eflags);
32350
32351 load_cr3(initial_page_table);
32352 __flush_tlb_all();
32353
32354 +#ifdef CONFIG_PAX_KERNEXEC
32355 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
32356 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
32357 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
32358 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
32359 +#endif
32360 +
32361 gdt_descr.address = __pa(get_cpu_gdt_table(0));
32362 gdt_descr.size = GDT_SIZE - 1;
32363 load_gdt(&gdt_descr);
32364 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
32365 {
32366 struct desc_ptr gdt_descr;
32367
32368 +#ifdef CONFIG_PAX_KERNEXEC
32369 + struct desc_struct d;
32370 +
32371 + memset(&d, 0, sizeof d);
32372 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
32373 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
32374 +#endif
32375 +
32376 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
32377 gdt_descr.size = GDT_SIZE - 1;
32378 load_gdt(&gdt_descr);
32379
32380 +#ifdef CONFIG_PAX_PER_CPU_PGD
32381 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
32382 +#else
32383 load_cr3(swapper_pg_dir);
32384 +#endif
32385 +
32386 __flush_tlb_all();
32387
32388 local_irq_restore(efi_rt_eflags);
32389 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
32390 index 39a0e7f1..872396e 100644
32391 --- a/arch/x86/platform/efi/efi_64.c
32392 +++ b/arch/x86/platform/efi/efi_64.c
32393 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
32394 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
32395 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
32396 }
32397 +
32398 +#ifdef CONFIG_PAX_PER_CPU_PGD
32399 + load_cr3(swapper_pg_dir);
32400 +#endif
32401 +
32402 __flush_tlb_all();
32403 }
32404
32405 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
32406 for (pgd = 0; pgd < n_pgds; pgd++)
32407 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
32408 kfree(save_pgd);
32409 +
32410 +#ifdef CONFIG_PAX_PER_CPU_PGD
32411 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
32412 +#endif
32413 +
32414 __flush_tlb_all();
32415 local_irq_restore(efi_flags);
32416 early_code_mapping_set_exec(0);
32417 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
32418 index fbe66e6..eae5e38 100644
32419 --- a/arch/x86/platform/efi/efi_stub_32.S
32420 +++ b/arch/x86/platform/efi/efi_stub_32.S
32421 @@ -6,7 +6,9 @@
32422 */
32423
32424 #include <linux/linkage.h>
32425 +#include <linux/init.h>
32426 #include <asm/page_types.h>
32427 +#include <asm/segment.h>
32428
32429 /*
32430 * efi_call_phys(void *, ...) is a function with variable parameters.
32431 @@ -20,7 +22,7 @@
32432 * service functions will comply with gcc calling convention, too.
32433 */
32434
32435 -.text
32436 +__INIT
32437 ENTRY(efi_call_phys)
32438 /*
32439 * 0. The function can only be called in Linux kernel. So CS has been
32440 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
32441 * The mapping of lower virtual memory has been created in prelog and
32442 * epilog.
32443 */
32444 - movl $1f, %edx
32445 - subl $__PAGE_OFFSET, %edx
32446 - jmp *%edx
32447 +#ifdef CONFIG_PAX_KERNEXEC
32448 + movl $(__KERNEXEC_EFI_DS), %edx
32449 + mov %edx, %ds
32450 + mov %edx, %es
32451 + mov %edx, %ss
32452 + addl $2f,(1f)
32453 + ljmp *(1f)
32454 +
32455 +__INITDATA
32456 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
32457 +.previous
32458 +
32459 +2:
32460 + subl $2b,(1b)
32461 +#else
32462 + jmp 1f-__PAGE_OFFSET
32463 1:
32464 +#endif
32465
32466 /*
32467 * 2. Now on the top of stack is the return
32468 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
32469 * parameter 2, ..., param n. To make things easy, we save the return
32470 * address of efi_call_phys in a global variable.
32471 */
32472 - popl %edx
32473 - movl %edx, saved_return_addr
32474 - /* get the function pointer into ECX*/
32475 - popl %ecx
32476 - movl %ecx, efi_rt_function_ptr
32477 - movl $2f, %edx
32478 - subl $__PAGE_OFFSET, %edx
32479 - pushl %edx
32480 + popl (saved_return_addr)
32481 + popl (efi_rt_function_ptr)
32482
32483 /*
32484 * 3. Clear PG bit in %CR0.
32485 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
32486 /*
32487 * 5. Call the physical function.
32488 */
32489 - jmp *%ecx
32490 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
32491
32492 -2:
32493 /*
32494 * 6. After EFI runtime service returns, control will return to
32495 * following instruction. We'd better readjust stack pointer first.
32496 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
32497 movl %cr0, %edx
32498 orl $0x80000000, %edx
32499 movl %edx, %cr0
32500 - jmp 1f
32501 -1:
32502 +
32503 /*
32504 * 8. Now restore the virtual mode from flat mode by
32505 * adding EIP with PAGE_OFFSET.
32506 */
32507 - movl $1f, %edx
32508 - jmp *%edx
32509 +#ifdef CONFIG_PAX_KERNEXEC
32510 + movl $(__KERNEL_DS), %edx
32511 + mov %edx, %ds
32512 + mov %edx, %es
32513 + mov %edx, %ss
32514 + ljmp $(__KERNEL_CS),$1f
32515 +#else
32516 + jmp 1f+__PAGE_OFFSET
32517 +#endif
32518 1:
32519
32520 /*
32521 * 9. Balance the stack. And because EAX contain the return value,
32522 * we'd better not clobber it.
32523 */
32524 - leal efi_rt_function_ptr, %edx
32525 - movl (%edx), %ecx
32526 - pushl %ecx
32527 + pushl (efi_rt_function_ptr)
32528
32529 /*
32530 - * 10. Push the saved return address onto the stack and return.
32531 + * 10. Return to the saved return address.
32532 */
32533 - leal saved_return_addr, %edx
32534 - movl (%edx), %ecx
32535 - pushl %ecx
32536 - ret
32537 + jmpl *(saved_return_addr)
32538 ENDPROC(efi_call_phys)
32539 .previous
32540
32541 -.data
32542 +__INITDATA
32543 saved_return_addr:
32544 .long 0
32545 efi_rt_function_ptr:
32546 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
32547 index 4c07cca..2c8427d 100644
32548 --- a/arch/x86/platform/efi/efi_stub_64.S
32549 +++ b/arch/x86/platform/efi/efi_stub_64.S
32550 @@ -7,6 +7,7 @@
32551 */
32552
32553 #include <linux/linkage.h>
32554 +#include <asm/alternative-asm.h>
32555
32556 #define SAVE_XMM \
32557 mov %rsp, %rax; \
32558 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
32559 call *%rdi
32560 addq $32, %rsp
32561 RESTORE_XMM
32562 + pax_force_retaddr 0, 1
32563 ret
32564 ENDPROC(efi_call0)
32565
32566 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
32567 call *%rdi
32568 addq $32, %rsp
32569 RESTORE_XMM
32570 + pax_force_retaddr 0, 1
32571 ret
32572 ENDPROC(efi_call1)
32573
32574 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
32575 call *%rdi
32576 addq $32, %rsp
32577 RESTORE_XMM
32578 + pax_force_retaddr 0, 1
32579 ret
32580 ENDPROC(efi_call2)
32581
32582 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
32583 call *%rdi
32584 addq $32, %rsp
32585 RESTORE_XMM
32586 + pax_force_retaddr 0, 1
32587 ret
32588 ENDPROC(efi_call3)
32589
32590 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
32591 call *%rdi
32592 addq $32, %rsp
32593 RESTORE_XMM
32594 + pax_force_retaddr 0, 1
32595 ret
32596 ENDPROC(efi_call4)
32597
32598 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
32599 call *%rdi
32600 addq $48, %rsp
32601 RESTORE_XMM
32602 + pax_force_retaddr 0, 1
32603 ret
32604 ENDPROC(efi_call5)
32605
32606 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
32607 call *%rdi
32608 addq $48, %rsp
32609 RESTORE_XMM
32610 + pax_force_retaddr 0, 1
32611 ret
32612 ENDPROC(efi_call6)
32613 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
32614 index a0a0a43..a48e233 100644
32615 --- a/arch/x86/platform/mrst/mrst.c
32616 +++ b/arch/x86/platform/mrst/mrst.c
32617 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
32618 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
32619 int sfi_mrtc_num;
32620
32621 -static void mrst_power_off(void)
32622 +static __noreturn void mrst_power_off(void)
32623 {
32624 + BUG();
32625 }
32626
32627 -static void mrst_reboot(void)
32628 +static __noreturn void mrst_reboot(void)
32629 {
32630 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
32631 + BUG();
32632 }
32633
32634 /* parse all the mtimer info to a static mtimer array */
32635 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
32636 index d6ee929..3637cb5 100644
32637 --- a/arch/x86/platform/olpc/olpc_dt.c
32638 +++ b/arch/x86/platform/olpc/olpc_dt.c
32639 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
32640 return res;
32641 }
32642
32643 -static struct of_pdt_ops prom_olpc_ops __initdata = {
32644 +static struct of_pdt_ops prom_olpc_ops __initconst = {
32645 .nextprop = olpc_dt_nextprop,
32646 .getproplen = olpc_dt_getproplen,
32647 .getproperty = olpc_dt_getproperty,
32648 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
32649 index 1cf5b30..fd45732 100644
32650 --- a/arch/x86/power/cpu.c
32651 +++ b/arch/x86/power/cpu.c
32652 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
32653 static void fix_processor_context(void)
32654 {
32655 int cpu = smp_processor_id();
32656 - struct tss_struct *t = &per_cpu(init_tss, cpu);
32657 -#ifdef CONFIG_X86_64
32658 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
32659 - tss_desc tss;
32660 -#endif
32661 + struct tss_struct *t = init_tss + cpu;
32662 +
32663 set_tss_desc(cpu, t); /*
32664 * This just modifies memory; should not be
32665 * necessary. But... This is necessary, because
32666 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
32667 */
32668
32669 #ifdef CONFIG_X86_64
32670 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
32671 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
32672 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
32673 -
32674 syscall_init(); /* This sets MSR_*STAR and related */
32675 #endif
32676 load_TR_desc(); /* This does ltr */
32677 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
32678 index a44f457..9140171 100644
32679 --- a/arch/x86/realmode/init.c
32680 +++ b/arch/x86/realmode/init.c
32681 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
32682 __va(real_mode_header->trampoline_header);
32683
32684 #ifdef CONFIG_X86_32
32685 - trampoline_header->start = __pa_symbol(startup_32_smp);
32686 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
32687 +
32688 +#ifdef CONFIG_PAX_KERNEXEC
32689 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
32690 +#endif
32691 +
32692 + trampoline_header->boot_cs = __BOOT_CS;
32693 trampoline_header->gdt_limit = __BOOT_DS + 7;
32694 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
32695 #else
32696 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
32697 *trampoline_cr4_features = read_cr4();
32698
32699 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
32700 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
32701 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
32702 trampoline_pgd[511] = init_level4_pgt[511].pgd;
32703 #endif
32704 }
32705 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
32706 index 8869287..d577672 100644
32707 --- a/arch/x86/realmode/rm/Makefile
32708 +++ b/arch/x86/realmode/rm/Makefile
32709 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
32710 $(call cc-option, -fno-unit-at-a-time)) \
32711 $(call cc-option, -fno-stack-protector) \
32712 $(call cc-option, -mpreferred-stack-boundary=2)
32713 +ifdef CONSTIFY_PLUGIN
32714 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
32715 +endif
32716 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
32717 GCOV_PROFILE := n
32718 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
32719 index a28221d..93c40f1 100644
32720 --- a/arch/x86/realmode/rm/header.S
32721 +++ b/arch/x86/realmode/rm/header.S
32722 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
32723 #endif
32724 /* APM/BIOS reboot */
32725 .long pa_machine_real_restart_asm
32726 -#ifdef CONFIG_X86_64
32727 +#ifdef CONFIG_X86_32
32728 + .long __KERNEL_CS
32729 +#else
32730 .long __KERNEL32_CS
32731 #endif
32732 END(real_mode_header)
32733 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
32734 index c1b2791..f9e31c7 100644
32735 --- a/arch/x86/realmode/rm/trampoline_32.S
32736 +++ b/arch/x86/realmode/rm/trampoline_32.S
32737 @@ -25,6 +25,12 @@
32738 #include <asm/page_types.h>
32739 #include "realmode.h"
32740
32741 +#ifdef CONFIG_PAX_KERNEXEC
32742 +#define ta(X) (X)
32743 +#else
32744 +#define ta(X) (pa_ ## X)
32745 +#endif
32746 +
32747 .text
32748 .code16
32749
32750 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
32751
32752 cli # We should be safe anyway
32753
32754 - movl tr_start, %eax # where we need to go
32755 -
32756 movl $0xA5A5A5A5, trampoline_status
32757 # write marker for master knows we're running
32758
32759 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
32760 movw $1, %dx # protected mode (PE) bit
32761 lmsw %dx # into protected mode
32762
32763 - ljmpl $__BOOT_CS, $pa_startup_32
32764 + ljmpl *(trampoline_header)
32765
32766 .section ".text32","ax"
32767 .code32
32768 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
32769 .balign 8
32770 GLOBAL(trampoline_header)
32771 tr_start: .space 4
32772 - tr_gdt_pad: .space 2
32773 + tr_boot_cs: .space 2
32774 tr_gdt: .space 6
32775 END(trampoline_header)
32776
32777 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
32778 index bb360dc..d0fd8f8 100644
32779 --- a/arch/x86/realmode/rm/trampoline_64.S
32780 +++ b/arch/x86/realmode/rm/trampoline_64.S
32781 @@ -94,6 +94,7 @@ ENTRY(startup_32)
32782 movl %edx, %gs
32783
32784 movl pa_tr_cr4, %eax
32785 + andl $~X86_CR4_PCIDE, %eax
32786 movl %eax, %cr4 # Enable PAE mode
32787
32788 # Setup trampoline 4 level pagetables
32789 @@ -107,7 +108,7 @@ ENTRY(startup_32)
32790 wrmsr
32791
32792 # Enable paging and in turn activate Long Mode
32793 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
32794 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
32795 movl %eax, %cr0
32796
32797 /*
32798 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
32799 index e812034..c747134 100644
32800 --- a/arch/x86/tools/Makefile
32801 +++ b/arch/x86/tools/Makefile
32802 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
32803
32804 $(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
32805
32806 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
32807 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
32808 hostprogs-y += relocs
32809 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
32810 relocs: $(obj)/relocs
32811 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
32812 index f7bab68..b6d9886 100644
32813 --- a/arch/x86/tools/relocs.c
32814 +++ b/arch/x86/tools/relocs.c
32815 @@ -1,5 +1,7 @@
32816 /* This is included from relocs_32/64.c */
32817
32818 +#include "../../../include/generated/autoconf.h"
32819 +
32820 #define ElfW(type) _ElfW(ELF_BITS, type)
32821 #define _ElfW(bits, type) __ElfW(bits, type)
32822 #define __ElfW(bits, type) Elf##bits##_##type
32823 @@ -11,6 +13,7 @@
32824 #define Elf_Sym ElfW(Sym)
32825
32826 static Elf_Ehdr ehdr;
32827 +static Elf_Phdr *phdr;
32828
32829 struct relocs {
32830 uint32_t *offset;
32831 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
32832 }
32833 }
32834
32835 +static void read_phdrs(FILE *fp)
32836 +{
32837 + unsigned int i;
32838 +
32839 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
32840 + if (!phdr) {
32841 + die("Unable to allocate %d program headers\n",
32842 + ehdr.e_phnum);
32843 + }
32844 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
32845 + die("Seek to %d failed: %s\n",
32846 + ehdr.e_phoff, strerror(errno));
32847 + }
32848 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
32849 + die("Cannot read ELF program headers: %s\n",
32850 + strerror(errno));
32851 + }
32852 + for(i = 0; i < ehdr.e_phnum; i++) {
32853 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
32854 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
32855 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
32856 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
32857 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
32858 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
32859 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
32860 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
32861 + }
32862 +
32863 +}
32864 +
32865 static void read_shdrs(FILE *fp)
32866 {
32867 - int i;
32868 + unsigned int i;
32869 Elf_Shdr shdr;
32870
32871 secs = calloc(ehdr.e_shnum, sizeof(struct section));
32872 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
32873
32874 static void read_strtabs(FILE *fp)
32875 {
32876 - int i;
32877 + unsigned int i;
32878 for (i = 0; i < ehdr.e_shnum; i++) {
32879 struct section *sec = &secs[i];
32880 if (sec->shdr.sh_type != SHT_STRTAB) {
32881 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
32882
32883 static void read_symtabs(FILE *fp)
32884 {
32885 - int i,j;
32886 + unsigned int i,j;
32887 for (i = 0; i < ehdr.e_shnum; i++) {
32888 struct section *sec = &secs[i];
32889 if (sec->shdr.sh_type != SHT_SYMTAB) {
32890 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
32891 }
32892
32893
32894 -static void read_relocs(FILE *fp)
32895 +static void read_relocs(FILE *fp, int use_real_mode)
32896 {
32897 - int i,j;
32898 + unsigned int i,j;
32899 + uint32_t base;
32900 +
32901 for (i = 0; i < ehdr.e_shnum; i++) {
32902 struct section *sec = &secs[i];
32903 if (sec->shdr.sh_type != SHT_REL_TYPE) {
32904 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
32905 die("Cannot read symbol table: %s\n",
32906 strerror(errno));
32907 }
32908 + base = 0;
32909 +
32910 +#ifdef CONFIG_X86_32
32911 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
32912 + if (phdr[j].p_type != PT_LOAD )
32913 + continue;
32914 + 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)
32915 + continue;
32916 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
32917 + break;
32918 + }
32919 +#endif
32920 +
32921 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
32922 Elf_Rel *rel = &sec->reltab[j];
32923 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
32924 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
32925 rel->r_info = elf_xword_to_cpu(rel->r_info);
32926 #if (SHT_REL_TYPE == SHT_RELA)
32927 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
32928 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
32929
32930 static void print_absolute_symbols(void)
32931 {
32932 - int i;
32933 + unsigned int i;
32934 const char *format;
32935
32936 if (ELF_BITS == 64)
32937 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
32938 for (i = 0; i < ehdr.e_shnum; i++) {
32939 struct section *sec = &secs[i];
32940 char *sym_strtab;
32941 - int j;
32942 + unsigned int j;
32943
32944 if (sec->shdr.sh_type != SHT_SYMTAB) {
32945 continue;
32946 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
32947
32948 static void print_absolute_relocs(void)
32949 {
32950 - int i, printed = 0;
32951 + unsigned int i, printed = 0;
32952 const char *format;
32953
32954 if (ELF_BITS == 64)
32955 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
32956 struct section *sec_applies, *sec_symtab;
32957 char *sym_strtab;
32958 Elf_Sym *sh_symtab;
32959 - int j;
32960 + unsigned int j;
32961 if (sec->shdr.sh_type != SHT_REL_TYPE) {
32962 continue;
32963 }
32964 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
32965 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
32966 Elf_Sym *sym, const char *symname))
32967 {
32968 - int i;
32969 + unsigned int i;
32970 /* Walk through the relocations */
32971 for (i = 0; i < ehdr.e_shnum; i++) {
32972 char *sym_strtab;
32973 Elf_Sym *sh_symtab;
32974 struct section *sec_applies, *sec_symtab;
32975 - int j;
32976 + unsigned int j;
32977 struct section *sec = &secs[i];
32978
32979 if (sec->shdr.sh_type != SHT_REL_TYPE) {
32980 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
32981 {
32982 unsigned r_type = ELF32_R_TYPE(rel->r_info);
32983 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
32984 + char *sym_strtab = sec->link->link->strtab;
32985 +
32986 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
32987 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
32988 + return 0;
32989 +
32990 +#ifdef CONFIG_PAX_KERNEXEC
32991 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
32992 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
32993 + return 0;
32994 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
32995 + return 0;
32996 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
32997 + return 0;
32998 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
32999 + return 0;
33000 +#endif
33001
33002 switch (r_type) {
33003 case R_386_NONE:
33004 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33005
33006 static void emit_relocs(int as_text, int use_real_mode)
33007 {
33008 - int i;
33009 + unsigned int i;
33010 int (*write_reloc)(uint32_t, FILE *) = write32;
33011 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33012 const char *symname);
33013 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33014 {
33015 regex_init(use_real_mode);
33016 read_ehdr(fp);
33017 + read_phdrs(fp);
33018 read_shdrs(fp);
33019 read_strtabs(fp);
33020 read_symtabs(fp);
33021 - read_relocs(fp);
33022 + read_relocs(fp, use_real_mode);
33023 if (ELF_BITS == 64)
33024 percpu_init();
33025 if (show_absolute_syms) {
33026 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33027 index 80ffa5b..a33bd15 100644
33028 --- a/arch/x86/um/tls_32.c
33029 +++ b/arch/x86/um/tls_32.c
33030 @@ -260,7 +260,7 @@ out:
33031 if (unlikely(task == current &&
33032 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33033 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33034 - "without flushed TLS.", current->pid);
33035 + "without flushed TLS.", task_pid_nr(current));
33036 }
33037
33038 return 0;
33039 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33040 index fd14be1..e3c79c0 100644
33041 --- a/arch/x86/vdso/Makefile
33042 +++ b/arch/x86/vdso/Makefile
33043 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33044 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33045 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33046
33047 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33048 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33049 GCOV_PROFILE := n
33050
33051 #
33052 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33053 index 0faad64..39ef157 100644
33054 --- a/arch/x86/vdso/vdso32-setup.c
33055 +++ b/arch/x86/vdso/vdso32-setup.c
33056 @@ -25,6 +25,7 @@
33057 #include <asm/tlbflush.h>
33058 #include <asm/vdso.h>
33059 #include <asm/proto.h>
33060 +#include <asm/mman.h>
33061
33062 enum {
33063 VDSO_DISABLED = 0,
33064 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33065 void enable_sep_cpu(void)
33066 {
33067 int cpu = get_cpu();
33068 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33069 + struct tss_struct *tss = init_tss + cpu;
33070
33071 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33072 put_cpu();
33073 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33074 gate_vma.vm_start = FIXADDR_USER_START;
33075 gate_vma.vm_end = FIXADDR_USER_END;
33076 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33077 - gate_vma.vm_page_prot = __P101;
33078 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33079
33080 return 0;
33081 }
33082 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33083 if (compat)
33084 addr = VDSO_HIGH_BASE;
33085 else {
33086 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33087 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33088 if (IS_ERR_VALUE(addr)) {
33089 ret = addr;
33090 goto up_fail;
33091 }
33092 }
33093
33094 - current->mm->context.vdso = (void *)addr;
33095 + current->mm->context.vdso = addr;
33096
33097 if (compat_uses_vma || !compat) {
33098 /*
33099 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33100 }
33101
33102 current_thread_info()->sysenter_return =
33103 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33104 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33105
33106 up_fail:
33107 if (ret)
33108 - current->mm->context.vdso = NULL;
33109 + current->mm->context.vdso = 0;
33110
33111 up_write(&mm->mmap_sem);
33112
33113 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33114
33115 const char *arch_vma_name(struct vm_area_struct *vma)
33116 {
33117 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33118 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33119 return "[vdso]";
33120 +
33121 +#ifdef CONFIG_PAX_SEGMEXEC
33122 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33123 + return "[vdso]";
33124 +#endif
33125 +
33126 return NULL;
33127 }
33128
33129 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33130 * Check to see if the corresponding task was created in compat vdso
33131 * mode.
33132 */
33133 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33134 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33135 return &gate_vma;
33136 return NULL;
33137 }
33138 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33139 index 431e875..cbb23f3 100644
33140 --- a/arch/x86/vdso/vma.c
33141 +++ b/arch/x86/vdso/vma.c
33142 @@ -16,8 +16,6 @@
33143 #include <asm/vdso.h>
33144 #include <asm/page.h>
33145
33146 -unsigned int __read_mostly vdso_enabled = 1;
33147 -
33148 extern char vdso_start[], vdso_end[];
33149 extern unsigned short vdso_sync_cpuid;
33150
33151 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33152 * unaligned here as a result of stack start randomization.
33153 */
33154 addr = PAGE_ALIGN(addr);
33155 - addr = align_vdso_addr(addr);
33156
33157 return addr;
33158 }
33159 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33160 unsigned size)
33161 {
33162 struct mm_struct *mm = current->mm;
33163 - unsigned long addr;
33164 + unsigned long addr = 0;
33165 int ret;
33166
33167 - if (!vdso_enabled)
33168 - return 0;
33169 -
33170 down_write(&mm->mmap_sem);
33171 +
33172 +#ifdef CONFIG_PAX_RANDMMAP
33173 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33174 +#endif
33175 +
33176 addr = vdso_addr(mm->start_stack, size);
33177 + addr = align_vdso_addr(addr);
33178 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33179 if (IS_ERR_VALUE(addr)) {
33180 ret = addr;
33181 goto up_fail;
33182 }
33183
33184 - current->mm->context.vdso = (void *)addr;
33185 + mm->context.vdso = addr;
33186
33187 ret = install_special_mapping(mm, addr, size,
33188 VM_READ|VM_EXEC|
33189 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33190 pages);
33191 - if (ret) {
33192 - current->mm->context.vdso = NULL;
33193 - goto up_fail;
33194 - }
33195 + if (ret)
33196 + mm->context.vdso = 0;
33197
33198 up_fail:
33199 up_write(&mm->mmap_sem);
33200 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33201 vdsox32_size);
33202 }
33203 #endif
33204 -
33205 -static __init int vdso_setup(char *s)
33206 -{
33207 - vdso_enabled = simple_strtoul(s, NULL, 0);
33208 - return 0;
33209 -}
33210 -__setup("vdso=", vdso_setup);
33211 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33212 index a492be2..08678da 100644
33213 --- a/arch/x86/xen/enlighten.c
33214 +++ b/arch/x86/xen/enlighten.c
33215 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33216
33217 struct shared_info xen_dummy_shared_info;
33218
33219 -void *xen_initial_gdt;
33220 -
33221 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33222 __read_mostly int xen_have_vector_callback;
33223 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33224 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33225 {
33226 unsigned long va = dtr->address;
33227 unsigned int size = dtr->size + 1;
33228 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33229 - unsigned long frames[pages];
33230 + unsigned long frames[65536 / PAGE_SIZE];
33231 int f;
33232
33233 /*
33234 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33235 {
33236 unsigned long va = dtr->address;
33237 unsigned int size = dtr->size + 1;
33238 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33239 - unsigned long frames[pages];
33240 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33241 int f;
33242
33243 /*
33244 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33245 * 8-byte entries, or 16 4k pages..
33246 */
33247
33248 - BUG_ON(size > 65536);
33249 + BUG_ON(size > GDT_SIZE);
33250 BUG_ON(va & ~PAGE_MASK);
33251
33252 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33253 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
33254 return 0;
33255 }
33256
33257 -static void set_xen_basic_apic_ops(void)
33258 +static void __init set_xen_basic_apic_ops(void)
33259 {
33260 apic->read = xen_apic_read;
33261 apic->write = xen_apic_write;
33262 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
33263 #endif
33264 };
33265
33266 -static void xen_reboot(int reason)
33267 +static __noreturn void xen_reboot(int reason)
33268 {
33269 struct sched_shutdown r = { .reason = reason };
33270
33271 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
33272 - BUG();
33273 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
33274 + BUG();
33275 }
33276
33277 -static void xen_restart(char *msg)
33278 +static __noreturn void xen_restart(char *msg)
33279 {
33280 xen_reboot(SHUTDOWN_reboot);
33281 }
33282
33283 -static void xen_emergency_restart(void)
33284 +static __noreturn void xen_emergency_restart(void)
33285 {
33286 xen_reboot(SHUTDOWN_reboot);
33287 }
33288
33289 -static void xen_machine_halt(void)
33290 +static __noreturn void xen_machine_halt(void)
33291 {
33292 xen_reboot(SHUTDOWN_poweroff);
33293 }
33294
33295 -static void xen_machine_power_off(void)
33296 +static __noreturn void xen_machine_power_off(void)
33297 {
33298 if (pm_power_off)
33299 pm_power_off();
33300 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
33301 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
33302
33303 /* Work out if we support NX */
33304 - x86_configure_nx();
33305 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
33306 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
33307 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
33308 + unsigned l, h;
33309 +
33310 + __supported_pte_mask |= _PAGE_NX;
33311 + rdmsr(MSR_EFER, l, h);
33312 + l |= EFER_NX;
33313 + wrmsr(MSR_EFER, l, h);
33314 + }
33315 +#endif
33316
33317 xen_setup_features();
33318
33319 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
33320
33321 machine_ops = xen_machine_ops;
33322
33323 - /*
33324 - * The only reliable way to retain the initial address of the
33325 - * percpu gdt_page is to remember it here, so we can go and
33326 - * mark it RW later, when the initial percpu area is freed.
33327 - */
33328 - xen_initial_gdt = &per_cpu(gdt_page, 0);
33329 -
33330 xen_smp_init();
33331
33332 #ifdef CONFIG_ACPI_NUMA
33333 @@ -1700,7 +1699,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
33334 return NOTIFY_OK;
33335 }
33336
33337 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
33338 +static struct notifier_block xen_hvm_cpu_notifier = {
33339 .notifier_call = xen_hvm_cpu_notify,
33340 };
33341
33342 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
33343 index fdc3ba2..3daee39 100644
33344 --- a/arch/x86/xen/mmu.c
33345 +++ b/arch/x86/xen/mmu.c
33346 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
33347 /* L3_k[510] -> level2_kernel_pgt
33348 * L3_i[511] -> level2_fixmap_pgt */
33349 convert_pfn_mfn(level3_kernel_pgt);
33350 + convert_pfn_mfn(level3_vmalloc_start_pgt);
33351 + convert_pfn_mfn(level3_vmalloc_end_pgt);
33352 + convert_pfn_mfn(level3_vmemmap_pgt);
33353
33354 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
33355 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
33356 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
33357 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
33358 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
33359 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
33360 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
33361 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
33362 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
33363 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
33364 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
33365 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
33366 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
33367 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
33368
33369 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
33370 pv_mmu_ops.set_pud = xen_set_pud;
33371 #if PAGETABLE_LEVELS == 4
33372 pv_mmu_ops.set_pgd = xen_set_pgd;
33373 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
33374 #endif
33375
33376 /* This will work as long as patching hasn't happened yet
33377 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
33378 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
33379 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
33380 .set_pgd = xen_set_pgd_hyper,
33381 + .set_pgd_batched = xen_set_pgd_hyper,
33382
33383 .alloc_pud = xen_alloc_pmd_init,
33384 .release_pud = xen_release_pmd_init,
33385 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
33386 index d99cae8..18401e1 100644
33387 --- a/arch/x86/xen/smp.c
33388 +++ b/arch/x86/xen/smp.c
33389 @@ -240,11 +240,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
33390 {
33391 BUG_ON(smp_processor_id() != 0);
33392 native_smp_prepare_boot_cpu();
33393 -
33394 - /* We've switched to the "real" per-cpu gdt, so make sure the
33395 - old memory can be recycled */
33396 - make_lowmem_page_readwrite(xen_initial_gdt);
33397 -
33398 xen_filter_cpu_maps();
33399 xen_setup_vcpu_info_placement();
33400 }
33401 @@ -314,7 +309,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
33402 ctxt->user_regs.ss = __KERNEL_DS;
33403 #ifdef CONFIG_X86_32
33404 ctxt->user_regs.fs = __KERNEL_PERCPU;
33405 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
33406 + savesegment(gs, ctxt->user_regs.gs);
33407 #else
33408 ctxt->gs_base_kernel = per_cpu_offset(cpu);
33409 #endif
33410 @@ -324,8 +319,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
33411
33412 {
33413 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
33414 - ctxt->user_regs.ds = __USER_DS;
33415 - ctxt->user_regs.es = __USER_DS;
33416 + ctxt->user_regs.ds = __KERNEL_DS;
33417 + ctxt->user_regs.es = __KERNEL_DS;
33418
33419 xen_copy_trap_info(ctxt->trap_ctxt);
33420
33421 @@ -370,13 +365,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
33422 int rc;
33423
33424 per_cpu(current_task, cpu) = idle;
33425 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
33426 #ifdef CONFIG_X86_32
33427 irq_ctx_init(cpu);
33428 #else
33429 clear_tsk_thread_flag(idle, TIF_FORK);
33430 - per_cpu(kernel_stack, cpu) =
33431 - (unsigned long)task_stack_page(idle) -
33432 - KERNEL_STACK_OFFSET + THREAD_SIZE;
33433 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
33434 #endif
33435 xen_setup_runstate_info(cpu);
33436 xen_setup_timer(cpu);
33437 @@ -651,7 +645,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
33438
33439 void __init xen_smp_init(void)
33440 {
33441 - smp_ops = xen_smp_ops;
33442 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
33443 xen_fill_possible_map();
33444 xen_init_spinlocks();
33445 }
33446 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
33447 index 33ca6e4..0ded929 100644
33448 --- a/arch/x86/xen/xen-asm_32.S
33449 +++ b/arch/x86/xen/xen-asm_32.S
33450 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
33451 ESP_OFFSET=4 # bytes pushed onto stack
33452
33453 /*
33454 - * Store vcpu_info pointer for easy access. Do it this way to
33455 - * avoid having to reload %fs
33456 + * Store vcpu_info pointer for easy access.
33457 */
33458 #ifdef CONFIG_SMP
33459 - GET_THREAD_INFO(%eax)
33460 - movl %ss:TI_cpu(%eax), %eax
33461 - movl %ss:__per_cpu_offset(,%eax,4), %eax
33462 - mov %ss:xen_vcpu(%eax), %eax
33463 + push %fs
33464 + mov $(__KERNEL_PERCPU), %eax
33465 + mov %eax, %fs
33466 + mov PER_CPU_VAR(xen_vcpu), %eax
33467 + pop %fs
33468 #else
33469 movl %ss:xen_vcpu, %eax
33470 #endif
33471 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
33472 index 7faed58..ba4427c 100644
33473 --- a/arch/x86/xen/xen-head.S
33474 +++ b/arch/x86/xen/xen-head.S
33475 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
33476 #ifdef CONFIG_X86_32
33477 mov %esi,xen_start_info
33478 mov $init_thread_union+THREAD_SIZE,%esp
33479 +#ifdef CONFIG_SMP
33480 + movl $cpu_gdt_table,%edi
33481 + movl $__per_cpu_load,%eax
33482 + movw %ax,__KERNEL_PERCPU + 2(%edi)
33483 + rorl $16,%eax
33484 + movb %al,__KERNEL_PERCPU + 4(%edi)
33485 + movb %ah,__KERNEL_PERCPU + 7(%edi)
33486 + movl $__per_cpu_end - 1,%eax
33487 + subl $__per_cpu_start,%eax
33488 + movw %ax,__KERNEL_PERCPU + 0(%edi)
33489 +#endif
33490 #else
33491 mov %rsi,xen_start_info
33492 mov $init_thread_union+THREAD_SIZE,%rsp
33493 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
33494 index a95b417..b6dbd0b 100644
33495 --- a/arch/x86/xen/xen-ops.h
33496 +++ b/arch/x86/xen/xen-ops.h
33497 @@ -10,8 +10,6 @@
33498 extern const char xen_hypervisor_callback[];
33499 extern const char xen_failsafe_callback[];
33500
33501 -extern void *xen_initial_gdt;
33502 -
33503 struct trap_info;
33504 void xen_copy_trap_info(struct trap_info *traps);
33505
33506 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
33507 index 525bd3d..ef888b1 100644
33508 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
33509 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
33510 @@ -119,9 +119,9 @@
33511 ----------------------------------------------------------------------*/
33512
33513 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
33514 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
33515 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
33516 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
33517 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
33518
33519 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
33520 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
33521 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
33522 index 2f33760..835e50a 100644
33523 --- a/arch/xtensa/variants/fsf/include/variant/core.h
33524 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
33525 @@ -11,6 +11,7 @@
33526 #ifndef _XTENSA_CORE_H
33527 #define _XTENSA_CORE_H
33528
33529 +#include <linux/const.h>
33530
33531 /****************************************************************************
33532 Parameters Useful for Any Code, USER or PRIVILEGED
33533 @@ -112,9 +113,9 @@
33534 ----------------------------------------------------------------------*/
33535
33536 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
33537 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
33538 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
33539 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
33540 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
33541
33542 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
33543 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
33544 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
33545 index af00795..2bb8105 100644
33546 --- a/arch/xtensa/variants/s6000/include/variant/core.h
33547 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
33548 @@ -11,6 +11,7 @@
33549 #ifndef _XTENSA_CORE_CONFIGURATION_H
33550 #define _XTENSA_CORE_CONFIGURATION_H
33551
33552 +#include <linux/const.h>
33553
33554 /****************************************************************************
33555 Parameters Useful for Any Code, USER or PRIVILEGED
33556 @@ -118,9 +119,9 @@
33557 ----------------------------------------------------------------------*/
33558
33559 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
33560 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
33561 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
33562 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
33563 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
33564
33565 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
33566 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
33567 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
33568 index 58916af..eb9dbcf6 100644
33569 --- a/block/blk-iopoll.c
33570 +++ b/block/blk-iopoll.c
33571 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
33572 }
33573 EXPORT_SYMBOL(blk_iopoll_complete);
33574
33575 -static void blk_iopoll_softirq(struct softirq_action *h)
33576 +static void blk_iopoll_softirq(void)
33577 {
33578 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
33579 int rearm = 0, budget = blk_iopoll_budget;
33580 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
33581 return NOTIFY_OK;
33582 }
33583
33584 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
33585 +static struct notifier_block blk_iopoll_cpu_notifier = {
33586 .notifier_call = blk_iopoll_cpu_notify,
33587 };
33588
33589 diff --git a/block/blk-map.c b/block/blk-map.c
33590 index 623e1cd..ca1e109 100644
33591 --- a/block/blk-map.c
33592 +++ b/block/blk-map.c
33593 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
33594 if (!len || !kbuf)
33595 return -EINVAL;
33596
33597 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
33598 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
33599 if (do_copy)
33600 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
33601 else
33602 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
33603 index 467c8de..f3628c5 100644
33604 --- a/block/blk-softirq.c
33605 +++ b/block/blk-softirq.c
33606 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
33607 * Softirq action handler - move entries to local list and loop over them
33608 * while passing them to the queue registered handler.
33609 */
33610 -static void blk_done_softirq(struct softirq_action *h)
33611 +static void blk_done_softirq(void)
33612 {
33613 struct list_head *cpu_list, local_list;
33614
33615 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
33616 return NOTIFY_OK;
33617 }
33618
33619 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
33620 +static struct notifier_block blk_cpu_notifier = {
33621 .notifier_call = blk_cpu_notify,
33622 };
33623
33624 diff --git a/block/bsg.c b/block/bsg.c
33625 index 420a5a9..23834aa 100644
33626 --- a/block/bsg.c
33627 +++ b/block/bsg.c
33628 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
33629 struct sg_io_v4 *hdr, struct bsg_device *bd,
33630 fmode_t has_write_perm)
33631 {
33632 + unsigned char tmpcmd[sizeof(rq->__cmd)];
33633 + unsigned char *cmdptr;
33634 +
33635 if (hdr->request_len > BLK_MAX_CDB) {
33636 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
33637 if (!rq->cmd)
33638 return -ENOMEM;
33639 - }
33640 + cmdptr = rq->cmd;
33641 + } else
33642 + cmdptr = tmpcmd;
33643
33644 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
33645 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
33646 hdr->request_len))
33647 return -EFAULT;
33648
33649 + if (cmdptr != rq->cmd)
33650 + memcpy(rq->cmd, cmdptr, hdr->request_len);
33651 +
33652 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
33653 if (blk_verify_command(rq->cmd, has_write_perm))
33654 return -EPERM;
33655 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
33656 index 7c668c8..db3521c 100644
33657 --- a/block/compat_ioctl.c
33658 +++ b/block/compat_ioctl.c
33659 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
33660 err |= __get_user(f->spec1, &uf->spec1);
33661 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
33662 err |= __get_user(name, &uf->name);
33663 - f->name = compat_ptr(name);
33664 + f->name = (void __force_kernel *)compat_ptr(name);
33665 if (err) {
33666 err = -EFAULT;
33667 goto out;
33668 diff --git a/block/genhd.c b/block/genhd.c
33669 index cdeb527..10aa34db 100644
33670 --- a/block/genhd.c
33671 +++ b/block/genhd.c
33672 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
33673
33674 /*
33675 * Register device numbers dev..(dev+range-1)
33676 - * range must be nonzero
33677 + * Noop if @range is zero.
33678 * The hash chain is sorted on range, so that subranges can override.
33679 */
33680 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
33681 struct kobject *(*probe)(dev_t, int *, void *),
33682 int (*lock)(dev_t, void *), void *data)
33683 {
33684 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
33685 + if (range)
33686 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
33687 }
33688
33689 EXPORT_SYMBOL(blk_register_region);
33690
33691 +/* undo blk_register_region(), noop if @range is zero */
33692 void blk_unregister_region(dev_t devt, unsigned long range)
33693 {
33694 - kobj_unmap(bdev_map, devt, range);
33695 + if (range)
33696 + kobj_unmap(bdev_map, devt, range);
33697 }
33698
33699 EXPORT_SYMBOL(blk_unregister_region);
33700 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
33701 index c85fc89..51e690b 100644
33702 --- a/block/partitions/efi.c
33703 +++ b/block/partitions/efi.c
33704 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
33705 if (!gpt)
33706 return NULL;
33707
33708 + if (!le32_to_cpu(gpt->num_partition_entries))
33709 + return NULL;
33710 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
33711 + if (!pte)
33712 + return NULL;
33713 +
33714 count = le32_to_cpu(gpt->num_partition_entries) *
33715 le32_to_cpu(gpt->sizeof_partition_entry);
33716 - if (!count)
33717 - return NULL;
33718 - pte = kmalloc(count, GFP_KERNEL);
33719 - if (!pte)
33720 - return NULL;
33721 -
33722 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
33723 (u8 *) pte,
33724 count) < count) {
33725 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
33726 index a5ffcc9..3cedc9c 100644
33727 --- a/block/scsi_ioctl.c
33728 +++ b/block/scsi_ioctl.c
33729 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
33730 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
33731 struct sg_io_hdr *hdr, fmode_t mode)
33732 {
33733 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
33734 + unsigned char tmpcmd[sizeof(rq->__cmd)];
33735 + unsigned char *cmdptr;
33736 +
33737 + if (rq->cmd != rq->__cmd)
33738 + cmdptr = rq->cmd;
33739 + else
33740 + cmdptr = tmpcmd;
33741 +
33742 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
33743 return -EFAULT;
33744 +
33745 + if (cmdptr != rq->cmd)
33746 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
33747 +
33748 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
33749 return -EPERM;
33750
33751 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
33752 int err;
33753 unsigned int in_len, out_len, bytes, opcode, cmdlen;
33754 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
33755 + unsigned char tmpcmd[sizeof(rq->__cmd)];
33756 + unsigned char *cmdptr;
33757
33758 if (!sic)
33759 return -EINVAL;
33760 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
33761 */
33762 err = -EFAULT;
33763 rq->cmd_len = cmdlen;
33764 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
33765 +
33766 + if (rq->cmd != rq->__cmd)
33767 + cmdptr = rq->cmd;
33768 + else
33769 + cmdptr = tmpcmd;
33770 +
33771 + if (copy_from_user(cmdptr, sic->data, cmdlen))
33772 goto error;
33773
33774 + if (rq->cmd != cmdptr)
33775 + memcpy(rq->cmd, cmdptr, cmdlen);
33776 +
33777 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
33778 goto error;
33779
33780 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
33781 index 7bdd61b..afec999 100644
33782 --- a/crypto/cryptd.c
33783 +++ b/crypto/cryptd.c
33784 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
33785
33786 struct cryptd_blkcipher_request_ctx {
33787 crypto_completion_t complete;
33788 -};
33789 +} __no_const;
33790
33791 struct cryptd_hash_ctx {
33792 struct crypto_shash *child;
33793 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
33794
33795 struct cryptd_aead_request_ctx {
33796 crypto_completion_t complete;
33797 -};
33798 +} __no_const;
33799
33800 static void cryptd_queue_worker(struct work_struct *work);
33801
33802 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
33803 index b2c99dc..476c9fb 100644
33804 --- a/crypto/pcrypt.c
33805 +++ b/crypto/pcrypt.c
33806 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
33807 int ret;
33808
33809 pinst->kobj.kset = pcrypt_kset;
33810 - ret = kobject_add(&pinst->kobj, NULL, name);
33811 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
33812 if (!ret)
33813 kobject_uevent(&pinst->kobj, KOBJ_ADD);
33814
33815 @@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
33816
33817 get_online_cpus();
33818
33819 - pcrypt->wq = alloc_workqueue(name,
33820 - WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
33821 + pcrypt->wq = alloc_workqueue("%s",
33822 + WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1, name);
33823 if (!pcrypt->wq)
33824 goto err;
33825
33826 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
33827 index f220d64..d359ad6 100644
33828 --- a/drivers/acpi/apei/apei-internal.h
33829 +++ b/drivers/acpi/apei/apei-internal.h
33830 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
33831 struct apei_exec_ins_type {
33832 u32 flags;
33833 apei_exec_ins_func_t run;
33834 -};
33835 +} __do_const;
33836
33837 struct apei_exec_context {
33838 u32 ip;
33839 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
33840 index 33dc6a0..4b24b47 100644
33841 --- a/drivers/acpi/apei/cper.c
33842 +++ b/drivers/acpi/apei/cper.c
33843 @@ -39,12 +39,12 @@
33844 */
33845 u64 cper_next_record_id(void)
33846 {
33847 - static atomic64_t seq;
33848 + static atomic64_unchecked_t seq;
33849
33850 - if (!atomic64_read(&seq))
33851 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
33852 + if (!atomic64_read_unchecked(&seq))
33853 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
33854
33855 - return atomic64_inc_return(&seq);
33856 + return atomic64_inc_return_unchecked(&seq);
33857 }
33858 EXPORT_SYMBOL_GPL(cper_next_record_id);
33859
33860 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
33861 index be60399..778b33e8 100644
33862 --- a/drivers/acpi/bgrt.c
33863 +++ b/drivers/acpi/bgrt.c
33864 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
33865 return -ENODEV;
33866
33867 sysfs_bin_attr_init(&image_attr);
33868 - image_attr.private = bgrt_image;
33869 - image_attr.size = bgrt_image_size;
33870 + pax_open_kernel();
33871 + *(void **)&image_attr.private = bgrt_image;
33872 + *(size_t *)&image_attr.size = bgrt_image_size;
33873 + pax_close_kernel();
33874
33875 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
33876 if (!bgrt_kobj)
33877 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
33878 index cb96296..b81293b 100644
33879 --- a/drivers/acpi/blacklist.c
33880 +++ b/drivers/acpi/blacklist.c
33881 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
33882 u32 is_critical_error;
33883 };
33884
33885 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
33886 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
33887
33888 /*
33889 * POLICY: If *anything* doesn't work, put it on the blacklist.
33890 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
33891 return 0;
33892 }
33893
33894 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
33895 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
33896 {
33897 .callback = dmi_disable_osi_vista,
33898 .ident = "Fujitsu Siemens",
33899 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
33900 index 7586544..636a2f0 100644
33901 --- a/drivers/acpi/ec_sys.c
33902 +++ b/drivers/acpi/ec_sys.c
33903 @@ -12,6 +12,7 @@
33904 #include <linux/acpi.h>
33905 #include <linux/debugfs.h>
33906 #include <linux/module.h>
33907 +#include <linux/uaccess.h>
33908 #include "internal.h"
33909
33910 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
33911 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
33912 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
33913 */
33914 unsigned int size = EC_SPACE_SIZE;
33915 - u8 *data = (u8 *) buf;
33916 + u8 data;
33917 loff_t init_off = *off;
33918 int err = 0;
33919
33920 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
33921 size = count;
33922
33923 while (size) {
33924 - err = ec_read(*off, &data[*off - init_off]);
33925 + err = ec_read(*off, &data);
33926 if (err)
33927 return err;
33928 + if (put_user(data, &buf[*off - init_off]))
33929 + return -EFAULT;
33930 *off += 1;
33931 size--;
33932 }
33933 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
33934
33935 unsigned int size = count;
33936 loff_t init_off = *off;
33937 - u8 *data = (u8 *) buf;
33938 int err = 0;
33939
33940 if (*off >= EC_SPACE_SIZE)
33941 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
33942 }
33943
33944 while (size) {
33945 - u8 byte_write = data[*off - init_off];
33946 + u8 byte_write;
33947 + if (get_user(byte_write, &buf[*off - init_off]))
33948 + return -EFAULT;
33949 err = ec_write(*off, byte_write);
33950 if (err)
33951 return err;
33952 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
33953 index eb133c7..f571552 100644
33954 --- a/drivers/acpi/processor_idle.c
33955 +++ b/drivers/acpi/processor_idle.c
33956 @@ -994,7 +994,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
33957 {
33958 int i, count = CPUIDLE_DRIVER_STATE_START;
33959 struct acpi_processor_cx *cx;
33960 - struct cpuidle_state *state;
33961 + cpuidle_state_no_const *state;
33962 struct cpuidle_driver *drv = &acpi_idle_driver;
33963
33964 if (!pr->flags.power_setup_done)
33965 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
33966 index fcae5fa..e9f71ea 100644
33967 --- a/drivers/acpi/sysfs.c
33968 +++ b/drivers/acpi/sysfs.c
33969 @@ -423,11 +423,11 @@ static u32 num_counters;
33970 static struct attribute **all_attrs;
33971 static u32 acpi_gpe_count;
33972
33973 -static struct attribute_group interrupt_stats_attr_group = {
33974 +static attribute_group_no_const interrupt_stats_attr_group = {
33975 .name = "interrupts",
33976 };
33977
33978 -static struct kobj_attribute *counter_attrs;
33979 +static kobj_attribute_no_const *counter_attrs;
33980
33981 static void delete_gpe_attr_array(void)
33982 {
33983 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
33984 index 7b9bdd8..37638ca 100644
33985 --- a/drivers/ata/libahci.c
33986 +++ b/drivers/ata/libahci.c
33987 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
33988 }
33989 EXPORT_SYMBOL_GPL(ahci_kick_engine);
33990
33991 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
33992 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
33993 struct ata_taskfile *tf, int is_cmd, u16 flags,
33994 unsigned long timeout_msec)
33995 {
33996 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
33997 index adf002a..39bb8f9 100644
33998 --- a/drivers/ata/libata-core.c
33999 +++ b/drivers/ata/libata-core.c
34000 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34001 struct ata_port *ap;
34002 unsigned int tag;
34003
34004 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34005 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34006 ap = qc->ap;
34007
34008 qc->flags = 0;
34009 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34010 struct ata_port *ap;
34011 struct ata_link *link;
34012
34013 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34014 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34015 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34016 ap = qc->ap;
34017 link = qc->dev->link;
34018 @@ -5926,6 +5926,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34019 return;
34020
34021 spin_lock(&lock);
34022 + pax_open_kernel();
34023
34024 for (cur = ops->inherits; cur; cur = cur->inherits) {
34025 void **inherit = (void **)cur;
34026 @@ -5939,8 +5940,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34027 if (IS_ERR(*pp))
34028 *pp = NULL;
34029
34030 - ops->inherits = NULL;
34031 + *(struct ata_port_operations **)&ops->inherits = NULL;
34032
34033 + pax_close_kernel();
34034 spin_unlock(&lock);
34035 }
34036
34037 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34038 index 7638121..357a965 100644
34039 --- a/drivers/ata/pata_arasan_cf.c
34040 +++ b/drivers/ata/pata_arasan_cf.c
34041 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34042 /* Handle platform specific quirks */
34043 if (quirk) {
34044 if (quirk & CF_BROKEN_PIO) {
34045 - ap->ops->set_piomode = NULL;
34046 + pax_open_kernel();
34047 + *(void **)&ap->ops->set_piomode = NULL;
34048 + pax_close_kernel();
34049 ap->pio_mask = 0;
34050 }
34051 if (quirk & CF_BROKEN_MWDMA)
34052 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34053 index f9b983a..887b9d8 100644
34054 --- a/drivers/atm/adummy.c
34055 +++ b/drivers/atm/adummy.c
34056 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34057 vcc->pop(vcc, skb);
34058 else
34059 dev_kfree_skb_any(skb);
34060 - atomic_inc(&vcc->stats->tx);
34061 + atomic_inc_unchecked(&vcc->stats->tx);
34062
34063 return 0;
34064 }
34065 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34066 index 77a7480d..05cde58 100644
34067 --- a/drivers/atm/ambassador.c
34068 +++ b/drivers/atm/ambassador.c
34069 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34070 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34071
34072 // VC layer stats
34073 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34074 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34075
34076 // free the descriptor
34077 kfree (tx_descr);
34078 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34079 dump_skb ("<<<", vc, skb);
34080
34081 // VC layer stats
34082 - atomic_inc(&atm_vcc->stats->rx);
34083 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34084 __net_timestamp(skb);
34085 // end of our responsibility
34086 atm_vcc->push (atm_vcc, skb);
34087 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34088 } else {
34089 PRINTK (KERN_INFO, "dropped over-size frame");
34090 // should we count this?
34091 - atomic_inc(&atm_vcc->stats->rx_drop);
34092 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34093 }
34094
34095 } else {
34096 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34097 }
34098
34099 if (check_area (skb->data, skb->len)) {
34100 - atomic_inc(&atm_vcc->stats->tx_err);
34101 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34102 return -ENOMEM; // ?
34103 }
34104
34105 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34106 index 0e3f8f9..765a7a5 100644
34107 --- a/drivers/atm/atmtcp.c
34108 +++ b/drivers/atm/atmtcp.c
34109 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34110 if (vcc->pop) vcc->pop(vcc,skb);
34111 else dev_kfree_skb(skb);
34112 if (dev_data) return 0;
34113 - atomic_inc(&vcc->stats->tx_err);
34114 + atomic_inc_unchecked(&vcc->stats->tx_err);
34115 return -ENOLINK;
34116 }
34117 size = skb->len+sizeof(struct atmtcp_hdr);
34118 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34119 if (!new_skb) {
34120 if (vcc->pop) vcc->pop(vcc,skb);
34121 else dev_kfree_skb(skb);
34122 - atomic_inc(&vcc->stats->tx_err);
34123 + atomic_inc_unchecked(&vcc->stats->tx_err);
34124 return -ENOBUFS;
34125 }
34126 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34127 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34128 if (vcc->pop) vcc->pop(vcc,skb);
34129 else dev_kfree_skb(skb);
34130 out_vcc->push(out_vcc,new_skb);
34131 - atomic_inc(&vcc->stats->tx);
34132 - atomic_inc(&out_vcc->stats->rx);
34133 + atomic_inc_unchecked(&vcc->stats->tx);
34134 + atomic_inc_unchecked(&out_vcc->stats->rx);
34135 return 0;
34136 }
34137
34138 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34139 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34140 read_unlock(&vcc_sklist_lock);
34141 if (!out_vcc) {
34142 - atomic_inc(&vcc->stats->tx_err);
34143 + atomic_inc_unchecked(&vcc->stats->tx_err);
34144 goto done;
34145 }
34146 skb_pull(skb,sizeof(struct atmtcp_hdr));
34147 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34148 __net_timestamp(new_skb);
34149 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34150 out_vcc->push(out_vcc,new_skb);
34151 - atomic_inc(&vcc->stats->tx);
34152 - atomic_inc(&out_vcc->stats->rx);
34153 + atomic_inc_unchecked(&vcc->stats->tx);
34154 + atomic_inc_unchecked(&out_vcc->stats->rx);
34155 done:
34156 if (vcc->pop) vcc->pop(vcc,skb);
34157 else dev_kfree_skb(skb);
34158 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34159 index b1955ba..b179940 100644
34160 --- a/drivers/atm/eni.c
34161 +++ b/drivers/atm/eni.c
34162 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34163 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34164 vcc->dev->number);
34165 length = 0;
34166 - atomic_inc(&vcc->stats->rx_err);
34167 + atomic_inc_unchecked(&vcc->stats->rx_err);
34168 }
34169 else {
34170 length = ATM_CELL_SIZE-1; /* no HEC */
34171 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34172 size);
34173 }
34174 eff = length = 0;
34175 - atomic_inc(&vcc->stats->rx_err);
34176 + atomic_inc_unchecked(&vcc->stats->rx_err);
34177 }
34178 else {
34179 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34180 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34181 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34182 vcc->dev->number,vcc->vci,length,size << 2,descr);
34183 length = eff = 0;
34184 - atomic_inc(&vcc->stats->rx_err);
34185 + atomic_inc_unchecked(&vcc->stats->rx_err);
34186 }
34187 }
34188 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34189 @@ -767,7 +767,7 @@ rx_dequeued++;
34190 vcc->push(vcc,skb);
34191 pushed++;
34192 }
34193 - atomic_inc(&vcc->stats->rx);
34194 + atomic_inc_unchecked(&vcc->stats->rx);
34195 }
34196 wake_up(&eni_dev->rx_wait);
34197 }
34198 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34199 PCI_DMA_TODEVICE);
34200 if (vcc->pop) vcc->pop(vcc,skb);
34201 else dev_kfree_skb_irq(skb);
34202 - atomic_inc(&vcc->stats->tx);
34203 + atomic_inc_unchecked(&vcc->stats->tx);
34204 wake_up(&eni_dev->tx_wait);
34205 dma_complete++;
34206 }
34207 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34208 index b41c948..a002b17 100644
34209 --- a/drivers/atm/firestream.c
34210 +++ b/drivers/atm/firestream.c
34211 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34212 }
34213 }
34214
34215 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34216 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34217
34218 fs_dprintk (FS_DEBUG_TXMEM, "i");
34219 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34220 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34221 #endif
34222 skb_put (skb, qe->p1 & 0xffff);
34223 ATM_SKB(skb)->vcc = atm_vcc;
34224 - atomic_inc(&atm_vcc->stats->rx);
34225 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34226 __net_timestamp(skb);
34227 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34228 atm_vcc->push (atm_vcc, skb);
34229 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34230 kfree (pe);
34231 }
34232 if (atm_vcc)
34233 - atomic_inc(&atm_vcc->stats->rx_drop);
34234 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34235 break;
34236 case 0x1f: /* Reassembly abort: no buffers. */
34237 /* Silently increment error counter. */
34238 if (atm_vcc)
34239 - atomic_inc(&atm_vcc->stats->rx_drop);
34240 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34241 break;
34242 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34243 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34244 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34245 index 204814e..cede831 100644
34246 --- a/drivers/atm/fore200e.c
34247 +++ b/drivers/atm/fore200e.c
34248 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
34249 #endif
34250 /* check error condition */
34251 if (*entry->status & STATUS_ERROR)
34252 - atomic_inc(&vcc->stats->tx_err);
34253 + atomic_inc_unchecked(&vcc->stats->tx_err);
34254 else
34255 - atomic_inc(&vcc->stats->tx);
34256 + atomic_inc_unchecked(&vcc->stats->tx);
34257 }
34258 }
34259
34260 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34261 if (skb == NULL) {
34262 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
34263
34264 - atomic_inc(&vcc->stats->rx_drop);
34265 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34266 return -ENOMEM;
34267 }
34268
34269 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34270
34271 dev_kfree_skb_any(skb);
34272
34273 - atomic_inc(&vcc->stats->rx_drop);
34274 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34275 return -ENOMEM;
34276 }
34277
34278 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
34279
34280 vcc->push(vcc, skb);
34281 - atomic_inc(&vcc->stats->rx);
34282 + atomic_inc_unchecked(&vcc->stats->rx);
34283
34284 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
34285
34286 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
34287 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
34288 fore200e->atm_dev->number,
34289 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
34290 - atomic_inc(&vcc->stats->rx_err);
34291 + atomic_inc_unchecked(&vcc->stats->rx_err);
34292 }
34293 }
34294
34295 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
34296 goto retry_here;
34297 }
34298
34299 - atomic_inc(&vcc->stats->tx_err);
34300 + atomic_inc_unchecked(&vcc->stats->tx_err);
34301
34302 fore200e->tx_sat++;
34303 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
34304 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
34305 index 507362a..a845e57 100644
34306 --- a/drivers/atm/he.c
34307 +++ b/drivers/atm/he.c
34308 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
34309
34310 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
34311 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
34312 - atomic_inc(&vcc->stats->rx_drop);
34313 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34314 goto return_host_buffers;
34315 }
34316
34317 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
34318 RBRQ_LEN_ERR(he_dev->rbrq_head)
34319 ? "LEN_ERR" : "",
34320 vcc->vpi, vcc->vci);
34321 - atomic_inc(&vcc->stats->rx_err);
34322 + atomic_inc_unchecked(&vcc->stats->rx_err);
34323 goto return_host_buffers;
34324 }
34325
34326 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
34327 vcc->push(vcc, skb);
34328 spin_lock(&he_dev->global_lock);
34329
34330 - atomic_inc(&vcc->stats->rx);
34331 + atomic_inc_unchecked(&vcc->stats->rx);
34332
34333 return_host_buffers:
34334 ++pdus_assembled;
34335 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
34336 tpd->vcc->pop(tpd->vcc, tpd->skb);
34337 else
34338 dev_kfree_skb_any(tpd->skb);
34339 - atomic_inc(&tpd->vcc->stats->tx_err);
34340 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
34341 }
34342 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
34343 return;
34344 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
34345 vcc->pop(vcc, skb);
34346 else
34347 dev_kfree_skb_any(skb);
34348 - atomic_inc(&vcc->stats->tx_err);
34349 + atomic_inc_unchecked(&vcc->stats->tx_err);
34350 return -EINVAL;
34351 }
34352
34353 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
34354 vcc->pop(vcc, skb);
34355 else
34356 dev_kfree_skb_any(skb);
34357 - atomic_inc(&vcc->stats->tx_err);
34358 + atomic_inc_unchecked(&vcc->stats->tx_err);
34359 return -EINVAL;
34360 }
34361 #endif
34362 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
34363 vcc->pop(vcc, skb);
34364 else
34365 dev_kfree_skb_any(skb);
34366 - atomic_inc(&vcc->stats->tx_err);
34367 + atomic_inc_unchecked(&vcc->stats->tx_err);
34368 spin_unlock_irqrestore(&he_dev->global_lock, flags);
34369 return -ENOMEM;
34370 }
34371 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
34372 vcc->pop(vcc, skb);
34373 else
34374 dev_kfree_skb_any(skb);
34375 - atomic_inc(&vcc->stats->tx_err);
34376 + atomic_inc_unchecked(&vcc->stats->tx_err);
34377 spin_unlock_irqrestore(&he_dev->global_lock, flags);
34378 return -ENOMEM;
34379 }
34380 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
34381 __enqueue_tpd(he_dev, tpd, cid);
34382 spin_unlock_irqrestore(&he_dev->global_lock, flags);
34383
34384 - atomic_inc(&vcc->stats->tx);
34385 + atomic_inc_unchecked(&vcc->stats->tx);
34386
34387 return 0;
34388 }
34389 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
34390 index 1dc0519..1aadaf7 100644
34391 --- a/drivers/atm/horizon.c
34392 +++ b/drivers/atm/horizon.c
34393 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
34394 {
34395 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
34396 // VC layer stats
34397 - atomic_inc(&vcc->stats->rx);
34398 + atomic_inc_unchecked(&vcc->stats->rx);
34399 __net_timestamp(skb);
34400 // end of our responsibility
34401 vcc->push (vcc, skb);
34402 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
34403 dev->tx_iovec = NULL;
34404
34405 // VC layer stats
34406 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34407 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34408
34409 // free the skb
34410 hrz_kfree_skb (skb);
34411 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
34412 index 272f009..a18ba55 100644
34413 --- a/drivers/atm/idt77252.c
34414 +++ b/drivers/atm/idt77252.c
34415 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
34416 else
34417 dev_kfree_skb(skb);
34418
34419 - atomic_inc(&vcc->stats->tx);
34420 + atomic_inc_unchecked(&vcc->stats->tx);
34421 }
34422
34423 atomic_dec(&scq->used);
34424 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34425 if ((sb = dev_alloc_skb(64)) == NULL) {
34426 printk("%s: Can't allocate buffers for aal0.\n",
34427 card->name);
34428 - atomic_add(i, &vcc->stats->rx_drop);
34429 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
34430 break;
34431 }
34432 if (!atm_charge(vcc, sb->truesize)) {
34433 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
34434 card->name);
34435 - atomic_add(i - 1, &vcc->stats->rx_drop);
34436 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
34437 dev_kfree_skb(sb);
34438 break;
34439 }
34440 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34441 ATM_SKB(sb)->vcc = vcc;
34442 __net_timestamp(sb);
34443 vcc->push(vcc, sb);
34444 - atomic_inc(&vcc->stats->rx);
34445 + atomic_inc_unchecked(&vcc->stats->rx);
34446
34447 cell += ATM_CELL_PAYLOAD;
34448 }
34449 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34450 "(CDC: %08x)\n",
34451 card->name, len, rpp->len, readl(SAR_REG_CDC));
34452 recycle_rx_pool_skb(card, rpp);
34453 - atomic_inc(&vcc->stats->rx_err);
34454 + atomic_inc_unchecked(&vcc->stats->rx_err);
34455 return;
34456 }
34457 if (stat & SAR_RSQE_CRC) {
34458 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
34459 recycle_rx_pool_skb(card, rpp);
34460 - atomic_inc(&vcc->stats->rx_err);
34461 + atomic_inc_unchecked(&vcc->stats->rx_err);
34462 return;
34463 }
34464 if (skb_queue_len(&rpp->queue) > 1) {
34465 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34466 RXPRINTK("%s: Can't alloc RX skb.\n",
34467 card->name);
34468 recycle_rx_pool_skb(card, rpp);
34469 - atomic_inc(&vcc->stats->rx_err);
34470 + atomic_inc_unchecked(&vcc->stats->rx_err);
34471 return;
34472 }
34473 if (!atm_charge(vcc, skb->truesize)) {
34474 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34475 __net_timestamp(skb);
34476
34477 vcc->push(vcc, skb);
34478 - atomic_inc(&vcc->stats->rx);
34479 + atomic_inc_unchecked(&vcc->stats->rx);
34480
34481 return;
34482 }
34483 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34484 __net_timestamp(skb);
34485
34486 vcc->push(vcc, skb);
34487 - atomic_inc(&vcc->stats->rx);
34488 + atomic_inc_unchecked(&vcc->stats->rx);
34489
34490 if (skb->truesize > SAR_FB_SIZE_3)
34491 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
34492 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
34493 if (vcc->qos.aal != ATM_AAL0) {
34494 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
34495 card->name, vpi, vci);
34496 - atomic_inc(&vcc->stats->rx_drop);
34497 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34498 goto drop;
34499 }
34500
34501 if ((sb = dev_alloc_skb(64)) == NULL) {
34502 printk("%s: Can't allocate buffers for AAL0.\n",
34503 card->name);
34504 - atomic_inc(&vcc->stats->rx_err);
34505 + atomic_inc_unchecked(&vcc->stats->rx_err);
34506 goto drop;
34507 }
34508
34509 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
34510 ATM_SKB(sb)->vcc = vcc;
34511 __net_timestamp(sb);
34512 vcc->push(vcc, sb);
34513 - atomic_inc(&vcc->stats->rx);
34514 + atomic_inc_unchecked(&vcc->stats->rx);
34515
34516 drop:
34517 skb_pull(queue, 64);
34518 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
34519
34520 if (vc == NULL) {
34521 printk("%s: NULL connection in send().\n", card->name);
34522 - atomic_inc(&vcc->stats->tx_err);
34523 + atomic_inc_unchecked(&vcc->stats->tx_err);
34524 dev_kfree_skb(skb);
34525 return -EINVAL;
34526 }
34527 if (!test_bit(VCF_TX, &vc->flags)) {
34528 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
34529 - atomic_inc(&vcc->stats->tx_err);
34530 + atomic_inc_unchecked(&vcc->stats->tx_err);
34531 dev_kfree_skb(skb);
34532 return -EINVAL;
34533 }
34534 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
34535 break;
34536 default:
34537 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
34538 - atomic_inc(&vcc->stats->tx_err);
34539 + atomic_inc_unchecked(&vcc->stats->tx_err);
34540 dev_kfree_skb(skb);
34541 return -EINVAL;
34542 }
34543
34544 if (skb_shinfo(skb)->nr_frags != 0) {
34545 printk("%s: No scatter-gather yet.\n", card->name);
34546 - atomic_inc(&vcc->stats->tx_err);
34547 + atomic_inc_unchecked(&vcc->stats->tx_err);
34548 dev_kfree_skb(skb);
34549 return -EINVAL;
34550 }
34551 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
34552
34553 err = queue_skb(card, vc, skb, oam);
34554 if (err) {
34555 - atomic_inc(&vcc->stats->tx_err);
34556 + atomic_inc_unchecked(&vcc->stats->tx_err);
34557 dev_kfree_skb(skb);
34558 return err;
34559 }
34560 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
34561 skb = dev_alloc_skb(64);
34562 if (!skb) {
34563 printk("%s: Out of memory in send_oam().\n", card->name);
34564 - atomic_inc(&vcc->stats->tx_err);
34565 + atomic_inc_unchecked(&vcc->stats->tx_err);
34566 return -ENOMEM;
34567 }
34568 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
34569 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
34570 index 4217f29..88f547a 100644
34571 --- a/drivers/atm/iphase.c
34572 +++ b/drivers/atm/iphase.c
34573 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
34574 status = (u_short) (buf_desc_ptr->desc_mode);
34575 if (status & (RX_CER | RX_PTE | RX_OFL))
34576 {
34577 - atomic_inc(&vcc->stats->rx_err);
34578 + atomic_inc_unchecked(&vcc->stats->rx_err);
34579 IF_ERR(printk("IA: bad packet, dropping it");)
34580 if (status & RX_CER) {
34581 IF_ERR(printk(" cause: packet CRC error\n");)
34582 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
34583 len = dma_addr - buf_addr;
34584 if (len > iadev->rx_buf_sz) {
34585 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
34586 - atomic_inc(&vcc->stats->rx_err);
34587 + atomic_inc_unchecked(&vcc->stats->rx_err);
34588 goto out_free_desc;
34589 }
34590
34591 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
34592 ia_vcc = INPH_IA_VCC(vcc);
34593 if (ia_vcc == NULL)
34594 {
34595 - atomic_inc(&vcc->stats->rx_err);
34596 + atomic_inc_unchecked(&vcc->stats->rx_err);
34597 atm_return(vcc, skb->truesize);
34598 dev_kfree_skb_any(skb);
34599 goto INCR_DLE;
34600 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
34601 if ((length > iadev->rx_buf_sz) || (length >
34602 (skb->len - sizeof(struct cpcs_trailer))))
34603 {
34604 - atomic_inc(&vcc->stats->rx_err);
34605 + atomic_inc_unchecked(&vcc->stats->rx_err);
34606 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
34607 length, skb->len);)
34608 atm_return(vcc, skb->truesize);
34609 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
34610
34611 IF_RX(printk("rx_dle_intr: skb push");)
34612 vcc->push(vcc,skb);
34613 - atomic_inc(&vcc->stats->rx);
34614 + atomic_inc_unchecked(&vcc->stats->rx);
34615 iadev->rx_pkt_cnt++;
34616 }
34617 INCR_DLE:
34618 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
34619 {
34620 struct k_sonet_stats *stats;
34621 stats = &PRIV(_ia_dev[board])->sonet_stats;
34622 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
34623 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
34624 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
34625 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
34626 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
34627 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
34628 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
34629 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
34630 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
34631 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
34632 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
34633 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
34634 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
34635 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
34636 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
34637 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
34638 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
34639 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
34640 }
34641 ia_cmds.status = 0;
34642 break;
34643 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
34644 if ((desc == 0) || (desc > iadev->num_tx_desc))
34645 {
34646 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
34647 - atomic_inc(&vcc->stats->tx);
34648 + atomic_inc_unchecked(&vcc->stats->tx);
34649 if (vcc->pop)
34650 vcc->pop(vcc, skb);
34651 else
34652 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
34653 ATM_DESC(skb) = vcc->vci;
34654 skb_queue_tail(&iadev->tx_dma_q, skb);
34655
34656 - atomic_inc(&vcc->stats->tx);
34657 + atomic_inc_unchecked(&vcc->stats->tx);
34658 iadev->tx_pkt_cnt++;
34659 /* Increment transaction counter */
34660 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
34661
34662 #if 0
34663 /* add flow control logic */
34664 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
34665 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
34666 if (iavcc->vc_desc_cnt > 10) {
34667 vcc->tx_quota = vcc->tx_quota * 3 / 4;
34668 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
34669 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
34670 index fa7d701..1e404c7 100644
34671 --- a/drivers/atm/lanai.c
34672 +++ b/drivers/atm/lanai.c
34673 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
34674 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
34675 lanai_endtx(lanai, lvcc);
34676 lanai_free_skb(lvcc->tx.atmvcc, skb);
34677 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
34678 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
34679 }
34680
34681 /* Try to fill the buffer - don't call unless there is backlog */
34682 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
34683 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
34684 __net_timestamp(skb);
34685 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
34686 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
34687 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
34688 out:
34689 lvcc->rx.buf.ptr = end;
34690 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
34691 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
34692 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
34693 "vcc %d\n", lanai->number, (unsigned int) s, vci);
34694 lanai->stats.service_rxnotaal5++;
34695 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
34696 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
34697 return 0;
34698 }
34699 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
34700 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
34701 int bytes;
34702 read_unlock(&vcc_sklist_lock);
34703 DPRINTK("got trashed rx pdu on vci %d\n", vci);
34704 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
34705 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
34706 lvcc->stats.x.aal5.service_trash++;
34707 bytes = (SERVICE_GET_END(s) * 16) -
34708 (((unsigned long) lvcc->rx.buf.ptr) -
34709 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
34710 }
34711 if (s & SERVICE_STREAM) {
34712 read_unlock(&vcc_sklist_lock);
34713 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
34714 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
34715 lvcc->stats.x.aal5.service_stream++;
34716 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
34717 "PDU on VCI %d!\n", lanai->number, vci);
34718 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
34719 return 0;
34720 }
34721 DPRINTK("got rx crc error on vci %d\n", vci);
34722 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
34723 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
34724 lvcc->stats.x.aal5.service_rxcrc++;
34725 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
34726 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
34727 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
34728 index 6587dc2..149833d 100644
34729 --- a/drivers/atm/nicstar.c
34730 +++ b/drivers/atm/nicstar.c
34731 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
34732 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
34733 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
34734 card->index);
34735 - atomic_inc(&vcc->stats->tx_err);
34736 + atomic_inc_unchecked(&vcc->stats->tx_err);
34737 dev_kfree_skb_any(skb);
34738 return -EINVAL;
34739 }
34740 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
34741 if (!vc->tx) {
34742 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
34743 card->index);
34744 - atomic_inc(&vcc->stats->tx_err);
34745 + atomic_inc_unchecked(&vcc->stats->tx_err);
34746 dev_kfree_skb_any(skb);
34747 return -EINVAL;
34748 }
34749 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
34750 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
34751 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
34752 card->index);
34753 - atomic_inc(&vcc->stats->tx_err);
34754 + atomic_inc_unchecked(&vcc->stats->tx_err);
34755 dev_kfree_skb_any(skb);
34756 return -EINVAL;
34757 }
34758
34759 if (skb_shinfo(skb)->nr_frags != 0) {
34760 printk("nicstar%d: No scatter-gather yet.\n", card->index);
34761 - atomic_inc(&vcc->stats->tx_err);
34762 + atomic_inc_unchecked(&vcc->stats->tx_err);
34763 dev_kfree_skb_any(skb);
34764 return -EINVAL;
34765 }
34766 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
34767 }
34768
34769 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
34770 - atomic_inc(&vcc->stats->tx_err);
34771 + atomic_inc_unchecked(&vcc->stats->tx_err);
34772 dev_kfree_skb_any(skb);
34773 return -EIO;
34774 }
34775 - atomic_inc(&vcc->stats->tx);
34776 + atomic_inc_unchecked(&vcc->stats->tx);
34777
34778 return 0;
34779 }
34780 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34781 printk
34782 ("nicstar%d: Can't allocate buffers for aal0.\n",
34783 card->index);
34784 - atomic_add(i, &vcc->stats->rx_drop);
34785 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
34786 break;
34787 }
34788 if (!atm_charge(vcc, sb->truesize)) {
34789 RXPRINTK
34790 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
34791 card->index);
34792 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
34793 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
34794 dev_kfree_skb_any(sb);
34795 break;
34796 }
34797 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34798 ATM_SKB(sb)->vcc = vcc;
34799 __net_timestamp(sb);
34800 vcc->push(vcc, sb);
34801 - atomic_inc(&vcc->stats->rx);
34802 + atomic_inc_unchecked(&vcc->stats->rx);
34803 cell += ATM_CELL_PAYLOAD;
34804 }
34805
34806 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34807 if (iovb == NULL) {
34808 printk("nicstar%d: Out of iovec buffers.\n",
34809 card->index);
34810 - atomic_inc(&vcc->stats->rx_drop);
34811 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34812 recycle_rx_buf(card, skb);
34813 return;
34814 }
34815 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34816 small or large buffer itself. */
34817 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
34818 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
34819 - atomic_inc(&vcc->stats->rx_err);
34820 + atomic_inc_unchecked(&vcc->stats->rx_err);
34821 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
34822 NS_MAX_IOVECS);
34823 NS_PRV_IOVCNT(iovb) = 0;
34824 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34825 ("nicstar%d: Expected a small buffer, and this is not one.\n",
34826 card->index);
34827 which_list(card, skb);
34828 - atomic_inc(&vcc->stats->rx_err);
34829 + atomic_inc_unchecked(&vcc->stats->rx_err);
34830 recycle_rx_buf(card, skb);
34831 vc->rx_iov = NULL;
34832 recycle_iov_buf(card, iovb);
34833 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34834 ("nicstar%d: Expected a large buffer, and this is not one.\n",
34835 card->index);
34836 which_list(card, skb);
34837 - atomic_inc(&vcc->stats->rx_err);
34838 + atomic_inc_unchecked(&vcc->stats->rx_err);
34839 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
34840 NS_PRV_IOVCNT(iovb));
34841 vc->rx_iov = NULL;
34842 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34843 printk(" - PDU size mismatch.\n");
34844 else
34845 printk(".\n");
34846 - atomic_inc(&vcc->stats->rx_err);
34847 + atomic_inc_unchecked(&vcc->stats->rx_err);
34848 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
34849 NS_PRV_IOVCNT(iovb));
34850 vc->rx_iov = NULL;
34851 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34852 /* skb points to a small buffer */
34853 if (!atm_charge(vcc, skb->truesize)) {
34854 push_rxbufs(card, skb);
34855 - atomic_inc(&vcc->stats->rx_drop);
34856 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34857 } else {
34858 skb_put(skb, len);
34859 dequeue_sm_buf(card, skb);
34860 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34861 ATM_SKB(skb)->vcc = vcc;
34862 __net_timestamp(skb);
34863 vcc->push(vcc, skb);
34864 - atomic_inc(&vcc->stats->rx);
34865 + atomic_inc_unchecked(&vcc->stats->rx);
34866 }
34867 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
34868 struct sk_buff *sb;
34869 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34870 if (len <= NS_SMBUFSIZE) {
34871 if (!atm_charge(vcc, sb->truesize)) {
34872 push_rxbufs(card, sb);
34873 - atomic_inc(&vcc->stats->rx_drop);
34874 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34875 } else {
34876 skb_put(sb, len);
34877 dequeue_sm_buf(card, sb);
34878 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34879 ATM_SKB(sb)->vcc = vcc;
34880 __net_timestamp(sb);
34881 vcc->push(vcc, sb);
34882 - atomic_inc(&vcc->stats->rx);
34883 + atomic_inc_unchecked(&vcc->stats->rx);
34884 }
34885
34886 push_rxbufs(card, skb);
34887 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34888
34889 if (!atm_charge(vcc, skb->truesize)) {
34890 push_rxbufs(card, skb);
34891 - atomic_inc(&vcc->stats->rx_drop);
34892 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34893 } else {
34894 dequeue_lg_buf(card, skb);
34895 #ifdef NS_USE_DESTRUCTORS
34896 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34897 ATM_SKB(skb)->vcc = vcc;
34898 __net_timestamp(skb);
34899 vcc->push(vcc, skb);
34900 - atomic_inc(&vcc->stats->rx);
34901 + atomic_inc_unchecked(&vcc->stats->rx);
34902 }
34903
34904 push_rxbufs(card, sb);
34905 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34906 printk
34907 ("nicstar%d: Out of huge buffers.\n",
34908 card->index);
34909 - atomic_inc(&vcc->stats->rx_drop);
34910 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34911 recycle_iovec_rx_bufs(card,
34912 (struct iovec *)
34913 iovb->data,
34914 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34915 card->hbpool.count++;
34916 } else
34917 dev_kfree_skb_any(hb);
34918 - atomic_inc(&vcc->stats->rx_drop);
34919 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34920 } else {
34921 /* Copy the small buffer to the huge buffer */
34922 sb = (struct sk_buff *)iov->iov_base;
34923 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34924 #endif /* NS_USE_DESTRUCTORS */
34925 __net_timestamp(hb);
34926 vcc->push(vcc, hb);
34927 - atomic_inc(&vcc->stats->rx);
34928 + atomic_inc_unchecked(&vcc->stats->rx);
34929 }
34930 }
34931
34932 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
34933 index 32784d1..4a8434a 100644
34934 --- a/drivers/atm/solos-pci.c
34935 +++ b/drivers/atm/solos-pci.c
34936 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
34937 }
34938 atm_charge(vcc, skb->truesize);
34939 vcc->push(vcc, skb);
34940 - atomic_inc(&vcc->stats->rx);
34941 + atomic_inc_unchecked(&vcc->stats->rx);
34942 break;
34943
34944 case PKT_STATUS:
34945 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
34946 vcc = SKB_CB(oldskb)->vcc;
34947
34948 if (vcc) {
34949 - atomic_inc(&vcc->stats->tx);
34950 + atomic_inc_unchecked(&vcc->stats->tx);
34951 solos_pop(vcc, oldskb);
34952 } else {
34953 dev_kfree_skb_irq(oldskb);
34954 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
34955 index 0215934..ce9f5b1 100644
34956 --- a/drivers/atm/suni.c
34957 +++ b/drivers/atm/suni.c
34958 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
34959
34960
34961 #define ADD_LIMITED(s,v) \
34962 - atomic_add((v),&stats->s); \
34963 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
34964 + atomic_add_unchecked((v),&stats->s); \
34965 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
34966
34967
34968 static void suni_hz(unsigned long from_timer)
34969 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
34970 index 5120a96..e2572bd 100644
34971 --- a/drivers/atm/uPD98402.c
34972 +++ b/drivers/atm/uPD98402.c
34973 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
34974 struct sonet_stats tmp;
34975 int error = 0;
34976
34977 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
34978 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
34979 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
34980 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
34981 if (zero && !error) {
34982 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
34983
34984
34985 #define ADD_LIMITED(s,v) \
34986 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
34987 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
34988 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
34989 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
34990 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
34991 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
34992
34993
34994 static void stat_event(struct atm_dev *dev)
34995 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
34996 if (reason & uPD98402_INT_PFM) stat_event(dev);
34997 if (reason & uPD98402_INT_PCO) {
34998 (void) GET(PCOCR); /* clear interrupt cause */
34999 - atomic_add(GET(HECCT),
35000 + atomic_add_unchecked(GET(HECCT),
35001 &PRIV(dev)->sonet_stats.uncorr_hcs);
35002 }
35003 if ((reason & uPD98402_INT_RFO) &&
35004 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35005 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35006 uPD98402_INT_LOS),PIMR); /* enable them */
35007 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35008 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35009 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35010 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35011 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35012 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35013 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35014 return 0;
35015 }
35016
35017 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35018 index 969c3c2..9b72956 100644
35019 --- a/drivers/atm/zatm.c
35020 +++ b/drivers/atm/zatm.c
35021 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35022 }
35023 if (!size) {
35024 dev_kfree_skb_irq(skb);
35025 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35026 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35027 continue;
35028 }
35029 if (!atm_charge(vcc,skb->truesize)) {
35030 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35031 skb->len = size;
35032 ATM_SKB(skb)->vcc = vcc;
35033 vcc->push(vcc,skb);
35034 - atomic_inc(&vcc->stats->rx);
35035 + atomic_inc_unchecked(&vcc->stats->rx);
35036 }
35037 zout(pos & 0xffff,MTA(mbx));
35038 #if 0 /* probably a stupid idea */
35039 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35040 skb_queue_head(&zatm_vcc->backlog,skb);
35041 break;
35042 }
35043 - atomic_inc(&vcc->stats->tx);
35044 + atomic_inc_unchecked(&vcc->stats->tx);
35045 wake_up(&zatm_vcc->tx_wait);
35046 }
35047
35048 diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
35049 index d78b204..ecc1929 100644
35050 --- a/drivers/base/attribute_container.c
35051 +++ b/drivers/base/attribute_container.c
35052 @@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
35053 ic->classdev.parent = get_device(dev);
35054 ic->classdev.class = cont->class;
35055 cont->class->dev_release = attribute_container_release;
35056 - dev_set_name(&ic->classdev, dev_name(dev));
35057 + dev_set_name(&ic->classdev, "%s", dev_name(dev));
35058 if (fn)
35059 fn(cont, dev, &ic->classdev);
35060 else
35061 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35062 index d414331..b4dd4ba 100644
35063 --- a/drivers/base/bus.c
35064 +++ b/drivers/base/bus.c
35065 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35066 return -EINVAL;
35067
35068 mutex_lock(&subsys->p->mutex);
35069 - list_add_tail(&sif->node, &subsys->p->interfaces);
35070 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35071 if (sif->add_dev) {
35072 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35073 while ((dev = subsys_dev_iter_next(&iter)))
35074 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35075 subsys = sif->subsys;
35076
35077 mutex_lock(&subsys->p->mutex);
35078 - list_del_init(&sif->node);
35079 + pax_list_del_init((struct list_head *)&sif->node);
35080 if (sif->remove_dev) {
35081 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35082 while ((dev = subsys_dev_iter_next(&iter)))
35083 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35084 index 7413d06..79155fa 100644
35085 --- a/drivers/base/devtmpfs.c
35086 +++ b/drivers/base/devtmpfs.c
35087 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35088 if (!thread)
35089 return 0;
35090
35091 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35092 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35093 if (err)
35094 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35095 else
35096 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35097 *err = sys_unshare(CLONE_NEWNS);
35098 if (*err)
35099 goto out;
35100 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35101 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35102 if (*err)
35103 goto out;
35104 - sys_chdir("/.."); /* will traverse into overmounted root */
35105 - sys_chroot(".");
35106 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35107 + sys_chroot((char __force_user *)".");
35108 complete(&setup_done);
35109 while (1) {
35110 spin_lock(&req_lock);
35111 diff --git a/drivers/base/node.c b/drivers/base/node.c
35112 index 7616a77c..8f57f51 100644
35113 --- a/drivers/base/node.c
35114 +++ b/drivers/base/node.c
35115 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35116 struct node_attr {
35117 struct device_attribute attr;
35118 enum node_states state;
35119 -};
35120 +} __do_const;
35121
35122 static ssize_t show_node_state(struct device *dev,
35123 struct device_attribute *attr, char *buf)
35124 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35125 index 7072404..76dcebd 100644
35126 --- a/drivers/base/power/domain.c
35127 +++ b/drivers/base/power/domain.c
35128 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35129 {
35130 struct cpuidle_driver *cpuidle_drv;
35131 struct gpd_cpu_data *cpu_data;
35132 - struct cpuidle_state *idle_state;
35133 + cpuidle_state_no_const *idle_state;
35134 int ret = 0;
35135
35136 if (IS_ERR_OR_NULL(genpd) || state < 0)
35137 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35138 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35139 {
35140 struct gpd_cpu_data *cpu_data;
35141 - struct cpuidle_state *idle_state;
35142 + cpuidle_state_no_const *idle_state;
35143 int ret = 0;
35144
35145 if (IS_ERR_OR_NULL(genpd))
35146 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35147 index a53ebd2..8f73eeb 100644
35148 --- a/drivers/base/power/sysfs.c
35149 +++ b/drivers/base/power/sysfs.c
35150 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35151 return -EIO;
35152 }
35153 }
35154 - return sprintf(buf, p);
35155 + return sprintf(buf, "%s", p);
35156 }
35157
35158 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35159 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35160 index 79715e7..df06b3b 100644
35161 --- a/drivers/base/power/wakeup.c
35162 +++ b/drivers/base/power/wakeup.c
35163 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35164 * They need to be modified together atomically, so it's better to use one
35165 * atomic variable to hold them both.
35166 */
35167 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35168 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35169
35170 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35171 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35172
35173 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35174 {
35175 - unsigned int comb = atomic_read(&combined_event_count);
35176 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35177
35178 *cnt = (comb >> IN_PROGRESS_BITS);
35179 *inpr = comb & MAX_IN_PROGRESS;
35180 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35181 ws->start_prevent_time = ws->last_time;
35182
35183 /* Increment the counter of events in progress. */
35184 - cec = atomic_inc_return(&combined_event_count);
35185 + cec = atomic_inc_return_unchecked(&combined_event_count);
35186
35187 trace_wakeup_source_activate(ws->name, cec);
35188 }
35189 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35190 * Increment the counter of registered wakeup events and decrement the
35191 * couter of wakeup events in progress simultaneously.
35192 */
35193 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35194 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35195 trace_wakeup_source_deactivate(ws->name, cec);
35196
35197 split_counters(&cnt, &inpr);
35198 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35199 index e8d11b6..7b1b36f 100644
35200 --- a/drivers/base/syscore.c
35201 +++ b/drivers/base/syscore.c
35202 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35203 void register_syscore_ops(struct syscore_ops *ops)
35204 {
35205 mutex_lock(&syscore_ops_lock);
35206 - list_add_tail(&ops->node, &syscore_ops_list);
35207 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35208 mutex_unlock(&syscore_ops_lock);
35209 }
35210 EXPORT_SYMBOL_GPL(register_syscore_ops);
35211 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35212 void unregister_syscore_ops(struct syscore_ops *ops)
35213 {
35214 mutex_lock(&syscore_ops_lock);
35215 - list_del(&ops->node);
35216 + pax_list_del((struct list_head *)&ops->node);
35217 mutex_unlock(&syscore_ops_lock);
35218 }
35219 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35220 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35221 index 62b6c2c..4a11354 100644
35222 --- a/drivers/block/cciss.c
35223 +++ b/drivers/block/cciss.c
35224 @@ -1189,6 +1189,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
35225 int err;
35226 u32 cp;
35227
35228 + memset(&arg64, 0, sizeof(arg64));
35229 +
35230 err = 0;
35231 err |=
35232 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
35233 @@ -3010,7 +3012,7 @@ static void start_io(ctlr_info_t *h)
35234 while (!list_empty(&h->reqQ)) {
35235 c = list_entry(h->reqQ.next, CommandList_struct, list);
35236 /* can't do anything if fifo is full */
35237 - if ((h->access.fifo_full(h))) {
35238 + if ((h->access->fifo_full(h))) {
35239 dev_warn(&h->pdev->dev, "fifo full\n");
35240 break;
35241 }
35242 @@ -3020,7 +3022,7 @@ static void start_io(ctlr_info_t *h)
35243 h->Qdepth--;
35244
35245 /* Tell the controller execute command */
35246 - h->access.submit_command(h, c);
35247 + h->access->submit_command(h, c);
35248
35249 /* Put job onto the completed Q */
35250 addQ(&h->cmpQ, c);
35251 @@ -3446,17 +3448,17 @@ startio:
35252
35253 static inline unsigned long get_next_completion(ctlr_info_t *h)
35254 {
35255 - return h->access.command_completed(h);
35256 + return h->access->command_completed(h);
35257 }
35258
35259 static inline int interrupt_pending(ctlr_info_t *h)
35260 {
35261 - return h->access.intr_pending(h);
35262 + return h->access->intr_pending(h);
35263 }
35264
35265 static inline long interrupt_not_for_us(ctlr_info_t *h)
35266 {
35267 - return ((h->access.intr_pending(h) == 0) ||
35268 + return ((h->access->intr_pending(h) == 0) ||
35269 (h->interrupts_enabled == 0));
35270 }
35271
35272 @@ -3489,7 +3491,7 @@ static inline u32 next_command(ctlr_info_t *h)
35273 u32 a;
35274
35275 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
35276 - return h->access.command_completed(h);
35277 + return h->access->command_completed(h);
35278
35279 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
35280 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
35281 @@ -4046,7 +4048,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
35282 trans_support & CFGTBL_Trans_use_short_tags);
35283
35284 /* Change the access methods to the performant access methods */
35285 - h->access = SA5_performant_access;
35286 + h->access = &SA5_performant_access;
35287 h->transMethod = CFGTBL_Trans_Performant;
35288
35289 return;
35290 @@ -4319,7 +4321,7 @@ static int cciss_pci_init(ctlr_info_t *h)
35291 if (prod_index < 0)
35292 return -ENODEV;
35293 h->product_name = products[prod_index].product_name;
35294 - h->access = *(products[prod_index].access);
35295 + h->access = products[prod_index].access;
35296
35297 if (cciss_board_disabled(h)) {
35298 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
35299 @@ -5051,7 +5053,7 @@ reinit_after_soft_reset:
35300 }
35301
35302 /* make sure the board interrupts are off */
35303 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
35304 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
35305 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
35306 if (rc)
35307 goto clean2;
35308 @@ -5101,7 +5103,7 @@ reinit_after_soft_reset:
35309 * fake ones to scoop up any residual completions.
35310 */
35311 spin_lock_irqsave(&h->lock, flags);
35312 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
35313 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
35314 spin_unlock_irqrestore(&h->lock, flags);
35315 free_irq(h->intr[h->intr_mode], h);
35316 rc = cciss_request_irq(h, cciss_msix_discard_completions,
35317 @@ -5121,9 +5123,9 @@ reinit_after_soft_reset:
35318 dev_info(&h->pdev->dev, "Board READY.\n");
35319 dev_info(&h->pdev->dev,
35320 "Waiting for stale completions to drain.\n");
35321 - h->access.set_intr_mask(h, CCISS_INTR_ON);
35322 + h->access->set_intr_mask(h, CCISS_INTR_ON);
35323 msleep(10000);
35324 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
35325 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
35326
35327 rc = controller_reset_failed(h->cfgtable);
35328 if (rc)
35329 @@ -5146,7 +5148,7 @@ reinit_after_soft_reset:
35330 cciss_scsi_setup(h);
35331
35332 /* Turn the interrupts on so we can service requests */
35333 - h->access.set_intr_mask(h, CCISS_INTR_ON);
35334 + h->access->set_intr_mask(h, CCISS_INTR_ON);
35335
35336 /* Get the firmware version */
35337 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
35338 @@ -5218,7 +5220,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
35339 kfree(flush_buf);
35340 if (return_code != IO_OK)
35341 dev_warn(&h->pdev->dev, "Error flushing cache\n");
35342 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
35343 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
35344 free_irq(h->intr[h->intr_mode], h);
35345 }
35346
35347 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
35348 index 7fda30e..eb5dfe0 100644
35349 --- a/drivers/block/cciss.h
35350 +++ b/drivers/block/cciss.h
35351 @@ -101,7 +101,7 @@ struct ctlr_info
35352 /* information about each logical volume */
35353 drive_info_struct *drv[CISS_MAX_LUN];
35354
35355 - struct access_method access;
35356 + struct access_method *access;
35357
35358 /* queue and queue Info */
35359 struct list_head reqQ;
35360 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
35361 index 639d26b..fd6ad1f 100644
35362 --- a/drivers/block/cpqarray.c
35363 +++ b/drivers/block/cpqarray.c
35364 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
35365 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
35366 goto Enomem4;
35367 }
35368 - hba[i]->access.set_intr_mask(hba[i], 0);
35369 + hba[i]->access->set_intr_mask(hba[i], 0);
35370 if (request_irq(hba[i]->intr, do_ida_intr,
35371 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
35372 {
35373 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
35374 add_timer(&hba[i]->timer);
35375
35376 /* Enable IRQ now that spinlock and rate limit timer are set up */
35377 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
35378 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
35379
35380 for(j=0; j<NWD; j++) {
35381 struct gendisk *disk = ida_gendisk[i][j];
35382 @@ -694,7 +694,7 @@ DBGINFO(
35383 for(i=0; i<NR_PRODUCTS; i++) {
35384 if (board_id == products[i].board_id) {
35385 c->product_name = products[i].product_name;
35386 - c->access = *(products[i].access);
35387 + c->access = products[i].access;
35388 break;
35389 }
35390 }
35391 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
35392 hba[ctlr]->intr = intr;
35393 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
35394 hba[ctlr]->product_name = products[j].product_name;
35395 - hba[ctlr]->access = *(products[j].access);
35396 + hba[ctlr]->access = products[j].access;
35397 hba[ctlr]->ctlr = ctlr;
35398 hba[ctlr]->board_id = board_id;
35399 hba[ctlr]->pci_dev = NULL; /* not PCI */
35400 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
35401
35402 while((c = h->reqQ) != NULL) {
35403 /* Can't do anything if we're busy */
35404 - if (h->access.fifo_full(h) == 0)
35405 + if (h->access->fifo_full(h) == 0)
35406 return;
35407
35408 /* Get the first entry from the request Q */
35409 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
35410 h->Qdepth--;
35411
35412 /* Tell the controller to do our bidding */
35413 - h->access.submit_command(h, c);
35414 + h->access->submit_command(h, c);
35415
35416 /* Get onto the completion Q */
35417 addQ(&h->cmpQ, c);
35418 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
35419 unsigned long flags;
35420 __u32 a,a1;
35421
35422 - istat = h->access.intr_pending(h);
35423 + istat = h->access->intr_pending(h);
35424 /* Is this interrupt for us? */
35425 if (istat == 0)
35426 return IRQ_NONE;
35427 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
35428 */
35429 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
35430 if (istat & FIFO_NOT_EMPTY) {
35431 - while((a = h->access.command_completed(h))) {
35432 + while((a = h->access->command_completed(h))) {
35433 a1 = a; a &= ~3;
35434 if ((c = h->cmpQ) == NULL)
35435 {
35436 @@ -1193,6 +1193,7 @@ out_passthru:
35437 ida_pci_info_struct pciinfo;
35438
35439 if (!arg) return -EINVAL;
35440 + memset(&pciinfo, 0, sizeof(pciinfo));
35441 pciinfo.bus = host->pci_dev->bus->number;
35442 pciinfo.dev_fn = host->pci_dev->devfn;
35443 pciinfo.board_id = host->board_id;
35444 @@ -1447,11 +1448,11 @@ static int sendcmd(
35445 /*
35446 * Disable interrupt
35447 */
35448 - info_p->access.set_intr_mask(info_p, 0);
35449 + info_p->access->set_intr_mask(info_p, 0);
35450 /* Make sure there is room in the command FIFO */
35451 /* Actually it should be completely empty at this time. */
35452 for (i = 200000; i > 0; i--) {
35453 - temp = info_p->access.fifo_full(info_p);
35454 + temp = info_p->access->fifo_full(info_p);
35455 if (temp != 0) {
35456 break;
35457 }
35458 @@ -1464,7 +1465,7 @@ DBG(
35459 /*
35460 * Send the cmd
35461 */
35462 - info_p->access.submit_command(info_p, c);
35463 + info_p->access->submit_command(info_p, c);
35464 complete = pollcomplete(ctlr);
35465
35466 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
35467 @@ -1547,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
35468 * we check the new geometry. Then turn interrupts back on when
35469 * we're done.
35470 */
35471 - host->access.set_intr_mask(host, 0);
35472 + host->access->set_intr_mask(host, 0);
35473 getgeometry(ctlr);
35474 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
35475 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
35476
35477 for(i=0; i<NWD; i++) {
35478 struct gendisk *disk = ida_gendisk[ctlr][i];
35479 @@ -1589,7 +1590,7 @@ static int pollcomplete(int ctlr)
35480 /* Wait (up to 2 seconds) for a command to complete */
35481
35482 for (i = 200000; i > 0; i--) {
35483 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
35484 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
35485 if (done == 0) {
35486 udelay(10); /* a short fixed delay */
35487 } else
35488 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
35489 index be73e9d..7fbf140 100644
35490 --- a/drivers/block/cpqarray.h
35491 +++ b/drivers/block/cpqarray.h
35492 @@ -99,7 +99,7 @@ struct ctlr_info {
35493 drv_info_t drv[NWD];
35494 struct proc_dir_entry *proc;
35495
35496 - struct access_method access;
35497 + struct access_method *access;
35498
35499 cmdlist_t *reqQ;
35500 cmdlist_t *cmpQ;
35501 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
35502 index f943aac..99bfd19 100644
35503 --- a/drivers/block/drbd/drbd_int.h
35504 +++ b/drivers/block/drbd/drbd_int.h
35505 @@ -582,7 +582,7 @@ struct drbd_epoch {
35506 struct drbd_tconn *tconn;
35507 struct list_head list;
35508 unsigned int barrier_nr;
35509 - atomic_t epoch_size; /* increased on every request added. */
35510 + atomic_unchecked_t epoch_size; /* increased on every request added. */
35511 atomic_t active; /* increased on every req. added, and dec on every finished. */
35512 unsigned long flags;
35513 };
35514 @@ -1021,7 +1021,7 @@ struct drbd_conf {
35515 unsigned int al_tr_number;
35516 int al_tr_cycle;
35517 wait_queue_head_t seq_wait;
35518 - atomic_t packet_seq;
35519 + atomic_unchecked_t packet_seq;
35520 unsigned int peer_seq;
35521 spinlock_t peer_seq_lock;
35522 unsigned int minor;
35523 @@ -1562,7 +1562,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
35524 char __user *uoptval;
35525 int err;
35526
35527 - uoptval = (char __user __force *)optval;
35528 + uoptval = (char __force_user *)optval;
35529
35530 set_fs(KERNEL_DS);
35531 if (level == SOL_SOCKET)
35532 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
35533 index a5dca6a..bb27967 100644
35534 --- a/drivers/block/drbd/drbd_main.c
35535 +++ b/drivers/block/drbd/drbd_main.c
35536 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
35537 p->sector = sector;
35538 p->block_id = block_id;
35539 p->blksize = blksize;
35540 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
35541 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
35542 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
35543 }
35544
35545 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
35546 return -EIO;
35547 p->sector = cpu_to_be64(req->i.sector);
35548 p->block_id = (unsigned long)req;
35549 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
35550 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
35551 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
35552 if (mdev->state.conn >= C_SYNC_SOURCE &&
35553 mdev->state.conn <= C_PAUSED_SYNC_T)
35554 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
35555 {
35556 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
35557
35558 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
35559 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
35560 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
35561 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
35562 kfree(tconn->current_epoch);
35563
35564 idr_destroy(&tconn->volumes);
35565 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
35566 index 4222aff..1f79506 100644
35567 --- a/drivers/block/drbd/drbd_receiver.c
35568 +++ b/drivers/block/drbd/drbd_receiver.c
35569 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
35570 {
35571 int err;
35572
35573 - atomic_set(&mdev->packet_seq, 0);
35574 + atomic_set_unchecked(&mdev->packet_seq, 0);
35575 mdev->peer_seq = 0;
35576
35577 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
35578 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
35579 do {
35580 next_epoch = NULL;
35581
35582 - epoch_size = atomic_read(&epoch->epoch_size);
35583 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
35584
35585 switch (ev & ~EV_CLEANUP) {
35586 case EV_PUT:
35587 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
35588 rv = FE_DESTROYED;
35589 } else {
35590 epoch->flags = 0;
35591 - atomic_set(&epoch->epoch_size, 0);
35592 + atomic_set_unchecked(&epoch->epoch_size, 0);
35593 /* atomic_set(&epoch->active, 0); is already zero */
35594 if (rv == FE_STILL_LIVE)
35595 rv = FE_RECYCLED;
35596 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
35597 conn_wait_active_ee_empty(tconn);
35598 drbd_flush(tconn);
35599
35600 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
35601 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
35602 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
35603 if (epoch)
35604 break;
35605 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
35606 }
35607
35608 epoch->flags = 0;
35609 - atomic_set(&epoch->epoch_size, 0);
35610 + atomic_set_unchecked(&epoch->epoch_size, 0);
35611 atomic_set(&epoch->active, 0);
35612
35613 spin_lock(&tconn->epoch_lock);
35614 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
35615 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
35616 list_add(&epoch->list, &tconn->current_epoch->list);
35617 tconn->current_epoch = epoch;
35618 tconn->epochs++;
35619 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
35620
35621 err = wait_for_and_update_peer_seq(mdev, peer_seq);
35622 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
35623 - atomic_inc(&tconn->current_epoch->epoch_size);
35624 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
35625 err2 = drbd_drain_block(mdev, pi->size);
35626 if (!err)
35627 err = err2;
35628 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
35629
35630 spin_lock(&tconn->epoch_lock);
35631 peer_req->epoch = tconn->current_epoch;
35632 - atomic_inc(&peer_req->epoch->epoch_size);
35633 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
35634 atomic_inc(&peer_req->epoch->active);
35635 spin_unlock(&tconn->epoch_lock);
35636
35637 @@ -4347,7 +4347,7 @@ struct data_cmd {
35638 int expect_payload;
35639 size_t pkt_size;
35640 int (*fn)(struct drbd_tconn *, struct packet_info *);
35641 -};
35642 +} __do_const;
35643
35644 static struct data_cmd drbd_cmd_handler[] = {
35645 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
35646 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
35647 if (!list_empty(&tconn->current_epoch->list))
35648 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
35649 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
35650 - atomic_set(&tconn->current_epoch->epoch_size, 0);
35651 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
35652 tconn->send.seen_any_write_yet = false;
35653
35654 conn_info(tconn, "Connection closed\n");
35655 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
35656 struct asender_cmd {
35657 size_t pkt_size;
35658 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
35659 -};
35660 +} __do_const;
35661
35662 static struct asender_cmd asender_tbl[] = {
35663 [P_PING] = { 0, got_Ping },
35664 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
35665 index d92d50f..a7e9d97 100644
35666 --- a/drivers/block/loop.c
35667 +++ b/drivers/block/loop.c
35668 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
35669
35670 file_start_write(file);
35671 set_fs(get_ds());
35672 - bw = file->f_op->write(file, buf, len, &pos);
35673 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
35674 set_fs(old_fs);
35675 file_end_write(file);
35676 if (likely(bw == len))
35677 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
35678 index f5d0ea1..c62380a 100644
35679 --- a/drivers/block/pktcdvd.c
35680 +++ b/drivers/block/pktcdvd.c
35681 @@ -84,7 +84,7 @@
35682 #define MAX_SPEED 0xffff
35683
35684 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
35685 - ~(sector_t)((pd)->settings.size - 1))
35686 + ~(sector_t)((pd)->settings.size - 1UL))
35687
35688 static DEFINE_MUTEX(pktcdvd_mutex);
35689 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
35690 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
35691 index 8a3aff7..d7538c2 100644
35692 --- a/drivers/cdrom/cdrom.c
35693 +++ b/drivers/cdrom/cdrom.c
35694 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
35695 ENSURE(reset, CDC_RESET);
35696 ENSURE(generic_packet, CDC_GENERIC_PACKET);
35697 cdi->mc_flags = 0;
35698 - cdo->n_minors = 0;
35699 cdi->options = CDO_USE_FFLAGS;
35700
35701 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
35702 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
35703 else
35704 cdi->cdda_method = CDDA_OLD;
35705
35706 - if (!cdo->generic_packet)
35707 - cdo->generic_packet = cdrom_dummy_generic_packet;
35708 + if (!cdo->generic_packet) {
35709 + pax_open_kernel();
35710 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
35711 + pax_close_kernel();
35712 + }
35713
35714 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
35715 mutex_lock(&cdrom_mutex);
35716 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
35717 if (cdi->exit)
35718 cdi->exit(cdi);
35719
35720 - cdi->ops->n_minors--;
35721 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
35722 }
35723
35724 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
35725 */
35726 nr = nframes;
35727 do {
35728 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
35729 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
35730 if (cgc.buffer)
35731 break;
35732
35733 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
35734 struct cdrom_device_info *cdi;
35735 int ret;
35736
35737 - ret = scnprintf(info + *pos, max_size - *pos, header);
35738 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
35739 if (!ret)
35740 return 1;
35741
35742 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
35743 index 4afcb65..a68a32d 100644
35744 --- a/drivers/cdrom/gdrom.c
35745 +++ b/drivers/cdrom/gdrom.c
35746 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
35747 .audio_ioctl = gdrom_audio_ioctl,
35748 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
35749 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
35750 - .n_minors = 1,
35751 };
35752
35753 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
35754 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
35755 index 3bb6fa3..34013fb 100644
35756 --- a/drivers/char/Kconfig
35757 +++ b/drivers/char/Kconfig
35758 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
35759
35760 config DEVKMEM
35761 bool "/dev/kmem virtual device support"
35762 - default y
35763 + default n
35764 + depends on !GRKERNSEC_KMEM
35765 help
35766 Say Y here if you want to support the /dev/kmem device. The
35767 /dev/kmem device is rarely used, but can be used for certain
35768 @@ -582,6 +583,7 @@ config DEVPORT
35769 bool
35770 depends on !M68K
35771 depends on ISA || PCI
35772 + depends on !GRKERNSEC_KMEM
35773 default y
35774
35775 source "drivers/s390/char/Kconfig"
35776 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
35777 index a48e05b..6bac831 100644
35778 --- a/drivers/char/agp/compat_ioctl.c
35779 +++ b/drivers/char/agp/compat_ioctl.c
35780 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
35781 return -ENOMEM;
35782 }
35783
35784 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
35785 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
35786 sizeof(*usegment) * ureserve.seg_count)) {
35787 kfree(usegment);
35788 kfree(ksegment);
35789 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
35790 index 2e04433..771f2cc 100644
35791 --- a/drivers/char/agp/frontend.c
35792 +++ b/drivers/char/agp/frontend.c
35793 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
35794 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
35795 return -EFAULT;
35796
35797 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
35798 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
35799 return -EFAULT;
35800
35801 client = agp_find_client_by_pid(reserve.pid);
35802 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
35803 if (segment == NULL)
35804 return -ENOMEM;
35805
35806 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
35807 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
35808 sizeof(struct agp_segment) * reserve.seg_count)) {
35809 kfree(segment);
35810 return -EFAULT;
35811 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
35812 index 4f94375..413694e 100644
35813 --- a/drivers/char/genrtc.c
35814 +++ b/drivers/char/genrtc.c
35815 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
35816 switch (cmd) {
35817
35818 case RTC_PLL_GET:
35819 + memset(&pll, 0, sizeof(pll));
35820 if (get_rtc_pll(&pll))
35821 return -EINVAL;
35822 else
35823 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
35824 index d784650..e8bfd69 100644
35825 --- a/drivers/char/hpet.c
35826 +++ b/drivers/char/hpet.c
35827 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
35828 }
35829
35830 static int
35831 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
35832 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
35833 struct hpet_info *info)
35834 {
35835 struct hpet_timer __iomem *timer;
35836 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
35837 index 86fe45c..c0ea948 100644
35838 --- a/drivers/char/hw_random/intel-rng.c
35839 +++ b/drivers/char/hw_random/intel-rng.c
35840 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
35841
35842 if (no_fwh_detect)
35843 return -ENODEV;
35844 - printk(warning);
35845 + printk("%s", warning);
35846 return -EBUSY;
35847 }
35848
35849 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
35850 index 4445fa1..7c6de37 100644
35851 --- a/drivers/char/ipmi/ipmi_msghandler.c
35852 +++ b/drivers/char/ipmi/ipmi_msghandler.c
35853 @@ -420,7 +420,7 @@ struct ipmi_smi {
35854 struct proc_dir_entry *proc_dir;
35855 char proc_dir_name[10];
35856
35857 - atomic_t stats[IPMI_NUM_STATS];
35858 + atomic_unchecked_t stats[IPMI_NUM_STATS];
35859
35860 /*
35861 * run_to_completion duplicate of smb_info, smi_info
35862 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
35863
35864
35865 #define ipmi_inc_stat(intf, stat) \
35866 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
35867 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
35868 #define ipmi_get_stat(intf, stat) \
35869 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
35870 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
35871
35872 static int is_lan_addr(struct ipmi_addr *addr)
35873 {
35874 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
35875 INIT_LIST_HEAD(&intf->cmd_rcvrs);
35876 init_waitqueue_head(&intf->waitq);
35877 for (i = 0; i < IPMI_NUM_STATS; i++)
35878 - atomic_set(&intf->stats[i], 0);
35879 + atomic_set_unchecked(&intf->stats[i], 0);
35880
35881 intf->proc_dir = NULL;
35882
35883 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
35884 index af4b23f..79806fc 100644
35885 --- a/drivers/char/ipmi/ipmi_si_intf.c
35886 +++ b/drivers/char/ipmi/ipmi_si_intf.c
35887 @@ -275,7 +275,7 @@ struct smi_info {
35888 unsigned char slave_addr;
35889
35890 /* Counters and things for the proc filesystem. */
35891 - atomic_t stats[SI_NUM_STATS];
35892 + atomic_unchecked_t stats[SI_NUM_STATS];
35893
35894 struct task_struct *thread;
35895
35896 @@ -284,9 +284,9 @@ struct smi_info {
35897 };
35898
35899 #define smi_inc_stat(smi, stat) \
35900 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
35901 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
35902 #define smi_get_stat(smi, stat) \
35903 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
35904 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
35905
35906 #define SI_MAX_PARMS 4
35907
35908 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
35909 atomic_set(&new_smi->req_events, 0);
35910 new_smi->run_to_completion = 0;
35911 for (i = 0; i < SI_NUM_STATS; i++)
35912 - atomic_set(&new_smi->stats[i], 0);
35913 + atomic_set_unchecked(&new_smi->stats[i], 0);
35914
35915 new_smi->interrupt_disabled = 1;
35916 atomic_set(&new_smi->stop_operation, 0);
35917 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
35918 index 1ccbe94..6ad651a 100644
35919 --- a/drivers/char/mem.c
35920 +++ b/drivers/char/mem.c
35921 @@ -18,6 +18,7 @@
35922 #include <linux/raw.h>
35923 #include <linux/tty.h>
35924 #include <linux/capability.h>
35925 +#include <linux/security.h>
35926 #include <linux/ptrace.h>
35927 #include <linux/device.h>
35928 #include <linux/highmem.h>
35929 @@ -38,6 +39,10 @@
35930
35931 #define DEVPORT_MINOR 4
35932
35933 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
35934 +extern const struct file_operations grsec_fops;
35935 +#endif
35936 +
35937 static inline unsigned long size_inside_page(unsigned long start,
35938 unsigned long size)
35939 {
35940 @@ -69,9 +74,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
35941
35942 while (cursor < to) {
35943 if (!devmem_is_allowed(pfn)) {
35944 +#ifdef CONFIG_GRKERNSEC_KMEM
35945 + gr_handle_mem_readwrite(from, to);
35946 +#else
35947 printk(KERN_INFO
35948 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
35949 current->comm, from, to);
35950 +#endif
35951 return 0;
35952 }
35953 cursor += PAGE_SIZE;
35954 @@ -79,6 +88,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
35955 }
35956 return 1;
35957 }
35958 +#elif defined(CONFIG_GRKERNSEC_KMEM)
35959 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
35960 +{
35961 + return 0;
35962 +}
35963 #else
35964 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
35965 {
35966 @@ -121,6 +135,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
35967
35968 while (count > 0) {
35969 unsigned long remaining;
35970 + char *temp;
35971
35972 sz = size_inside_page(p, count);
35973
35974 @@ -136,7 +151,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
35975 if (!ptr)
35976 return -EFAULT;
35977
35978 - remaining = copy_to_user(buf, ptr, sz);
35979 +#ifdef CONFIG_PAX_USERCOPY
35980 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
35981 + if (!temp) {
35982 + unxlate_dev_mem_ptr(p, ptr);
35983 + return -ENOMEM;
35984 + }
35985 + memcpy(temp, ptr, sz);
35986 +#else
35987 + temp = ptr;
35988 +#endif
35989 +
35990 + remaining = copy_to_user(buf, temp, sz);
35991 +
35992 +#ifdef CONFIG_PAX_USERCOPY
35993 + kfree(temp);
35994 +#endif
35995 +
35996 unxlate_dev_mem_ptr(p, ptr);
35997 if (remaining)
35998 return -EFAULT;
35999 @@ -379,7 +410,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
36000 else
36001 csize = count;
36002
36003 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
36004 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
36005 if (rc < 0)
36006 return rc;
36007 buf += csize;
36008 @@ -399,9 +430,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36009 size_t count, loff_t *ppos)
36010 {
36011 unsigned long p = *ppos;
36012 - ssize_t low_count, read, sz;
36013 + ssize_t low_count, read, sz, err = 0;
36014 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36015 - int err = 0;
36016
36017 read = 0;
36018 if (p < (unsigned long) high_memory) {
36019 @@ -423,6 +453,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36020 }
36021 #endif
36022 while (low_count > 0) {
36023 + char *temp;
36024 +
36025 sz = size_inside_page(p, low_count);
36026
36027 /*
36028 @@ -432,7 +464,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36029 */
36030 kbuf = xlate_dev_kmem_ptr((char *)p);
36031
36032 - if (copy_to_user(buf, kbuf, sz))
36033 +#ifdef CONFIG_PAX_USERCOPY
36034 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36035 + if (!temp)
36036 + return -ENOMEM;
36037 + memcpy(temp, kbuf, sz);
36038 +#else
36039 + temp = kbuf;
36040 +#endif
36041 +
36042 + err = copy_to_user(buf, temp, sz);
36043 +
36044 +#ifdef CONFIG_PAX_USERCOPY
36045 + kfree(temp);
36046 +#endif
36047 +
36048 + if (err)
36049 return -EFAULT;
36050 buf += sz;
36051 p += sz;
36052 @@ -869,6 +916,9 @@ static const struct memdev {
36053 #ifdef CONFIG_CRASH_DUMP
36054 [12] = { "oldmem", 0, &oldmem_fops, NULL },
36055 #endif
36056 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36057 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36058 +#endif
36059 };
36060
36061 static int memory_open(struct inode *inode, struct file *filp)
36062 @@ -940,7 +990,7 @@ static int __init chr_dev_init(void)
36063 continue;
36064
36065 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36066 - NULL, devlist[minor].name);
36067 + NULL, "%s", devlist[minor].name);
36068 }
36069
36070 return tty_init();
36071 diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
36072 index c689697..04e6d6a2 100644
36073 --- a/drivers/char/mwave/tp3780i.c
36074 +++ b/drivers/char/mwave/tp3780i.c
36075 @@ -479,6 +479,7 @@ int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities
36076 PRINTK_2(TRACE_TP3780I,
36077 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
36078
36079 + memset(pAbilities, 0, sizeof(*pAbilities));
36080 /* fill out standard constant fields */
36081 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
36082 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
36083 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36084 index 9df78e2..01ba9ae 100644
36085 --- a/drivers/char/nvram.c
36086 +++ b/drivers/char/nvram.c
36087 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36088
36089 spin_unlock_irq(&rtc_lock);
36090
36091 - if (copy_to_user(buf, contents, tmp - contents))
36092 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36093 return -EFAULT;
36094
36095 *ppos = i;
36096 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36097 index 5c5cc00..ac9edb7 100644
36098 --- a/drivers/char/pcmcia/synclink_cs.c
36099 +++ b/drivers/char/pcmcia/synclink_cs.c
36100 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36101
36102 if (debug_level >= DEBUG_LEVEL_INFO)
36103 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36104 - __FILE__, __LINE__, info->device_name, port->count);
36105 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36106
36107 - WARN_ON(!port->count);
36108 + WARN_ON(!atomic_read(&port->count));
36109
36110 if (tty_port_close_start(port, tty, filp) == 0)
36111 goto cleanup;
36112 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36113 cleanup:
36114 if (debug_level >= DEBUG_LEVEL_INFO)
36115 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36116 - tty->driver->name, port->count);
36117 + tty->driver->name, atomic_read(&port->count));
36118 }
36119
36120 /* Wait until the transmitter is empty.
36121 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36122
36123 if (debug_level >= DEBUG_LEVEL_INFO)
36124 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36125 - __FILE__, __LINE__, tty->driver->name, port->count);
36126 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36127
36128 /* If port is closing, signal caller to try again */
36129 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36130 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36131 goto cleanup;
36132 }
36133 spin_lock(&port->lock);
36134 - port->count++;
36135 + atomic_inc(&port->count);
36136 spin_unlock(&port->lock);
36137 spin_unlock_irqrestore(&info->netlock, flags);
36138
36139 - if (port->count == 1) {
36140 + if (atomic_read(&port->count) == 1) {
36141 /* 1st open on this device, init hardware */
36142 retval = startup(info, tty);
36143 if (retval < 0)
36144 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36145 unsigned short new_crctype;
36146
36147 /* return error if TTY interface open */
36148 - if (info->port.count)
36149 + if (atomic_read(&info->port.count))
36150 return -EBUSY;
36151
36152 switch (encoding)
36153 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36154
36155 /* arbitrate between network and tty opens */
36156 spin_lock_irqsave(&info->netlock, flags);
36157 - if (info->port.count != 0 || info->netcount != 0) {
36158 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36159 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36160 spin_unlock_irqrestore(&info->netlock, flags);
36161 return -EBUSY;
36162 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36163 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36164
36165 /* return error if TTY interface open */
36166 - if (info->port.count)
36167 + if (atomic_read(&info->port.count))
36168 return -EBUSY;
36169
36170 if (cmd != SIOCWANDEV)
36171 diff --git a/drivers/char/random.c b/drivers/char/random.c
36172 index 35487e8..dac8bd1 100644
36173 --- a/drivers/char/random.c
36174 +++ b/drivers/char/random.c
36175 @@ -272,8 +272,13 @@
36176 /*
36177 * Configuration information
36178 */
36179 +#ifdef CONFIG_GRKERNSEC_RANDNET
36180 +#define INPUT_POOL_WORDS 512
36181 +#define OUTPUT_POOL_WORDS 128
36182 +#else
36183 #define INPUT_POOL_WORDS 128
36184 #define OUTPUT_POOL_WORDS 32
36185 +#endif
36186 #define SEC_XFER_SIZE 512
36187 #define EXTRACT_SIZE 10
36188
36189 @@ -313,10 +318,17 @@ static struct poolinfo {
36190 int poolwords;
36191 int tap1, tap2, tap3, tap4, tap5;
36192 } poolinfo_table[] = {
36193 +#ifdef CONFIG_GRKERNSEC_RANDNET
36194 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36195 + { 512, 411, 308, 208, 104, 1 },
36196 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36197 + { 128, 103, 76, 51, 25, 1 },
36198 +#else
36199 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36200 { 128, 103, 76, 51, 25, 1 },
36201 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36202 { 32, 26, 20, 14, 7, 1 },
36203 +#endif
36204 #if 0
36205 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36206 { 2048, 1638, 1231, 819, 411, 1 },
36207 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36208 input_rotate += i ? 7 : 14;
36209 }
36210
36211 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36212 - ACCESS_ONCE(r->add_ptr) = i;
36213 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36214 + ACCESS_ONCE_RW(r->add_ptr) = i;
36215 smp_wmb();
36216
36217 if (out)
36218 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36219
36220 extract_buf(r, tmp);
36221 i = min_t(int, nbytes, EXTRACT_SIZE);
36222 - if (copy_to_user(buf, tmp, i)) {
36223 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36224 ret = -EFAULT;
36225 break;
36226 }
36227 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36228 #include <linux/sysctl.h>
36229
36230 static int min_read_thresh = 8, min_write_thresh;
36231 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36232 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36233 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36234 static char sysctl_bootid[16];
36235
36236 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
36237 static int proc_do_uuid(ctl_table *table, int write,
36238 void __user *buffer, size_t *lenp, loff_t *ppos)
36239 {
36240 - ctl_table fake_table;
36241 + ctl_table_no_const fake_table;
36242 unsigned char buf[64], tmp_uuid[16], *uuid;
36243
36244 uuid = table->data;
36245 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
36246 index bf2349db..5456d53 100644
36247 --- a/drivers/char/sonypi.c
36248 +++ b/drivers/char/sonypi.c
36249 @@ -54,6 +54,7 @@
36250
36251 #include <asm/uaccess.h>
36252 #include <asm/io.h>
36253 +#include <asm/local.h>
36254
36255 #include <linux/sonypi.h>
36256
36257 @@ -490,7 +491,7 @@ static struct sonypi_device {
36258 spinlock_t fifo_lock;
36259 wait_queue_head_t fifo_proc_list;
36260 struct fasync_struct *fifo_async;
36261 - int open_count;
36262 + local_t open_count;
36263 int model;
36264 struct input_dev *input_jog_dev;
36265 struct input_dev *input_key_dev;
36266 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
36267 static int sonypi_misc_release(struct inode *inode, struct file *file)
36268 {
36269 mutex_lock(&sonypi_device.lock);
36270 - sonypi_device.open_count--;
36271 + local_dec(&sonypi_device.open_count);
36272 mutex_unlock(&sonypi_device.lock);
36273 return 0;
36274 }
36275 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
36276 {
36277 mutex_lock(&sonypi_device.lock);
36278 /* Flush input queue on first open */
36279 - if (!sonypi_device.open_count)
36280 + if (!local_read(&sonypi_device.open_count))
36281 kfifo_reset(&sonypi_device.fifo);
36282 - sonypi_device.open_count++;
36283 + local_inc(&sonypi_device.open_count);
36284 mutex_unlock(&sonypi_device.lock);
36285
36286 return 0;
36287 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
36288 index 64420b3..5c40b56 100644
36289 --- a/drivers/char/tpm/tpm_acpi.c
36290 +++ b/drivers/char/tpm/tpm_acpi.c
36291 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
36292 virt = acpi_os_map_memory(start, len);
36293 if (!virt) {
36294 kfree(log->bios_event_log);
36295 + log->bios_event_log = NULL;
36296 printk("%s: ERROR - Unable to map memory\n", __func__);
36297 return -EIO;
36298 }
36299
36300 - memcpy_fromio(log->bios_event_log, virt, len);
36301 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
36302
36303 acpi_os_unmap_memory(virt, len);
36304 return 0;
36305 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
36306 index 84ddc55..1d32f1e 100644
36307 --- a/drivers/char/tpm/tpm_eventlog.c
36308 +++ b/drivers/char/tpm/tpm_eventlog.c
36309 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
36310 event = addr;
36311
36312 if ((event->event_type == 0 && event->event_size == 0) ||
36313 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
36314 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
36315 return NULL;
36316
36317 return addr;
36318 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
36319 return NULL;
36320
36321 if ((event->event_type == 0 && event->event_size == 0) ||
36322 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
36323 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
36324 return NULL;
36325
36326 (*pos)++;
36327 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
36328 int i;
36329
36330 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
36331 - seq_putc(m, data[i]);
36332 + if (!seq_putc(m, data[i]))
36333 + return -EFAULT;
36334
36335 return 0;
36336 }
36337 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
36338 index fc45567..fa2a590 100644
36339 --- a/drivers/char/virtio_console.c
36340 +++ b/drivers/char/virtio_console.c
36341 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
36342 if (to_user) {
36343 ssize_t ret;
36344
36345 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
36346 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
36347 if (ret)
36348 return -EFAULT;
36349 } else {
36350 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
36351 if (!port_has_data(port) && !port->host_connected)
36352 return 0;
36353
36354 - return fill_readbuf(port, ubuf, count, true);
36355 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
36356 }
36357
36358 static int wait_port_writable(struct port *port, bool nonblock)
36359 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
36360 index a33f46f..a720eed 100644
36361 --- a/drivers/clk/clk-composite.c
36362 +++ b/drivers/clk/clk-composite.c
36363 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
36364 struct clk *clk;
36365 struct clk_init_data init;
36366 struct clk_composite *composite;
36367 - struct clk_ops *clk_composite_ops;
36368 + clk_ops_no_const *clk_composite_ops;
36369
36370 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
36371 if (!composite) {
36372 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
36373 index bd11315..7f87098 100644
36374 --- a/drivers/clk/socfpga/clk.c
36375 +++ b/drivers/clk/socfpga/clk.c
36376 @@ -22,6 +22,7 @@
36377 #include <linux/clk-provider.h>
36378 #include <linux/io.h>
36379 #include <linux/of.h>
36380 +#include <asm/pgtable.h>
36381
36382 /* Clock Manager offsets */
36383 #define CLKMGR_CTRL 0x0
36384 @@ -135,8 +136,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
36385 if (strcmp(clk_name, "main_pll") || strcmp(clk_name, "periph_pll") ||
36386 strcmp(clk_name, "sdram_pll")) {
36387 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
36388 - clk_pll_ops.enable = clk_gate_ops.enable;
36389 - clk_pll_ops.disable = clk_gate_ops.disable;
36390 + pax_open_kernel();
36391 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
36392 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
36393 + pax_close_kernel();
36394 }
36395
36396 clk = clk_register(NULL, &socfpga_clk->hw.hw);
36397 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
36398 index a2b2541..bc1e7ff 100644
36399 --- a/drivers/clocksource/arm_arch_timer.c
36400 +++ b/drivers/clocksource/arm_arch_timer.c
36401 @@ -264,7 +264,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
36402 return NOTIFY_OK;
36403 }
36404
36405 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
36406 +static struct notifier_block arch_timer_cpu_nb = {
36407 .notifier_call = arch_timer_cpu_notify,
36408 };
36409
36410 diff --git a/drivers/clocksource/bcm_kona_timer.c b/drivers/clocksource/bcm_kona_timer.c
36411 index 350f493..489479e 100644
36412 --- a/drivers/clocksource/bcm_kona_timer.c
36413 +++ b/drivers/clocksource/bcm_kona_timer.c
36414 @@ -199,7 +199,7 @@ static struct irqaction kona_timer_irq = {
36415 .handler = kona_timer_interrupt,
36416 };
36417
36418 -static void __init kona_timer_init(void)
36419 +static void __init kona_timer_init(struct device_node *np)
36420 {
36421 kona_timers_init();
36422 kona_timer_clockevents_init();
36423 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
36424 index ade7513..069445f 100644
36425 --- a/drivers/clocksource/metag_generic.c
36426 +++ b/drivers/clocksource/metag_generic.c
36427 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
36428 return NOTIFY_OK;
36429 }
36430
36431 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
36432 +static struct notifier_block arch_timer_cpu_nb = {
36433 .notifier_call = arch_timer_cpu_notify,
36434 };
36435
36436 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
36437 index edc089e..bc7c0bc 100644
36438 --- a/drivers/cpufreq/acpi-cpufreq.c
36439 +++ b/drivers/cpufreq/acpi-cpufreq.c
36440 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
36441 return sprintf(buf, "%u\n", boost_enabled);
36442 }
36443
36444 -static struct global_attr global_boost = __ATTR(boost, 0644,
36445 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
36446 show_global_boost,
36447 store_global_boost);
36448
36449 @@ -705,8 +705,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
36450 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
36451 per_cpu(acfreq_data, cpu) = data;
36452
36453 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
36454 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
36455 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
36456 + pax_open_kernel();
36457 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
36458 + pax_close_kernel();
36459 + }
36460
36461 result = acpi_processor_register_performance(data->acpi_data, cpu);
36462 if (result)
36463 @@ -832,7 +835,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
36464 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
36465 break;
36466 case ACPI_ADR_SPACE_FIXED_HARDWARE:
36467 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
36468 + pax_open_kernel();
36469 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
36470 + pax_close_kernel();
36471 policy->cur = get_cur_freq_on_cpu(cpu);
36472 break;
36473 default:
36474 @@ -843,8 +848,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
36475 acpi_processor_notify_smm(THIS_MODULE);
36476
36477 /* Check for APERF/MPERF support in hardware */
36478 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
36479 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
36480 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
36481 + pax_open_kernel();
36482 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
36483 + pax_close_kernel();
36484 + }
36485
36486 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
36487 for (i = 0; i < perf->state_count; i++)
36488 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
36489 index 6485547..477033e 100644
36490 --- a/drivers/cpufreq/cpufreq.c
36491 +++ b/drivers/cpufreq/cpufreq.c
36492 @@ -1854,7 +1854,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
36493 return NOTIFY_OK;
36494 }
36495
36496 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
36497 +static struct notifier_block cpufreq_cpu_notifier = {
36498 .notifier_call = cpufreq_cpu_callback,
36499 };
36500
36501 @@ -1886,8 +1886,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
36502
36503 pr_debug("trying to register driver %s\n", driver_data->name);
36504
36505 - if (driver_data->setpolicy)
36506 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
36507 + if (driver_data->setpolicy) {
36508 + pax_open_kernel();
36509 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
36510 + pax_close_kernel();
36511 + }
36512
36513 write_lock_irqsave(&cpufreq_driver_lock, flags);
36514 if (cpufreq_driver) {
36515 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
36516 index a86ff72..aad2b03 100644
36517 --- a/drivers/cpufreq/cpufreq_governor.c
36518 +++ b/drivers/cpufreq/cpufreq_governor.c
36519 @@ -235,7 +235,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
36520 struct dbs_data *dbs_data;
36521 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
36522 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
36523 - struct od_ops *od_ops = NULL;
36524 + const struct od_ops *od_ops = NULL;
36525 struct od_dbs_tuners *od_tuners = NULL;
36526 struct cs_dbs_tuners *cs_tuners = NULL;
36527 struct cpu_dbs_common_info *cpu_cdbs;
36528 @@ -298,7 +298,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
36529
36530 if ((cdata->governor == GOV_CONSERVATIVE) &&
36531 (!policy->governor->initialized)) {
36532 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
36533 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
36534
36535 cpufreq_register_notifier(cs_ops->notifier_block,
36536 CPUFREQ_TRANSITION_NOTIFIER);
36537 @@ -315,7 +315,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
36538
36539 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
36540 (policy->governor->initialized == 1)) {
36541 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
36542 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
36543
36544 cpufreq_unregister_notifier(cs_ops->notifier_block,
36545 CPUFREQ_TRANSITION_NOTIFIER);
36546 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
36547 index 0d9e6be..461fd3b 100644
36548 --- a/drivers/cpufreq/cpufreq_governor.h
36549 +++ b/drivers/cpufreq/cpufreq_governor.h
36550 @@ -204,7 +204,7 @@ struct common_dbs_data {
36551 void (*exit)(struct dbs_data *dbs_data);
36552
36553 /* Governor specific ops, see below */
36554 - void *gov_ops;
36555 + const void *gov_ops;
36556 };
36557
36558 /* Governer Per policy data */
36559 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
36560 index c087347..dad6268 100644
36561 --- a/drivers/cpufreq/cpufreq_ondemand.c
36562 +++ b/drivers/cpufreq/cpufreq_ondemand.c
36563 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
36564 (struct cpufreq_policy *, unsigned int, unsigned int),
36565 unsigned int powersave_bias)
36566 {
36567 - od_ops.powersave_bias_target = f;
36568 + pax_open_kernel();
36569 + *(void **)&od_ops.powersave_bias_target = f;
36570 + pax_close_kernel();
36571 od_set_powersave_bias(powersave_bias);
36572 }
36573 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
36574
36575 void od_unregister_powersave_bias_handler(void)
36576 {
36577 - od_ops.powersave_bias_target = generic_powersave_bias_target;
36578 + pax_open_kernel();
36579 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
36580 + pax_close_kernel();
36581 od_set_powersave_bias(0);
36582 }
36583 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
36584 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
36585 index bfd6273..e39dd63 100644
36586 --- a/drivers/cpufreq/cpufreq_stats.c
36587 +++ b/drivers/cpufreq/cpufreq_stats.c
36588 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
36589 }
36590
36591 /* priority=1 so this will get called before cpufreq_remove_dev */
36592 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
36593 +static struct notifier_block cpufreq_stat_cpu_notifier = {
36594 .notifier_call = cpufreq_stat_cpu_callback,
36595 .priority = 1,
36596 };
36597 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
36598 index 421ef37..e708530c 100644
36599 --- a/drivers/cpufreq/p4-clockmod.c
36600 +++ b/drivers/cpufreq/p4-clockmod.c
36601 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
36602 case 0x0F: /* Core Duo */
36603 case 0x16: /* Celeron Core */
36604 case 0x1C: /* Atom */
36605 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36606 + pax_open_kernel();
36607 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36608 + pax_close_kernel();
36609 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
36610 case 0x0D: /* Pentium M (Dothan) */
36611 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36612 + pax_open_kernel();
36613 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36614 + pax_close_kernel();
36615 /* fall through */
36616 case 0x09: /* Pentium M (Banias) */
36617 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
36618 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
36619
36620 /* on P-4s, the TSC runs with constant frequency independent whether
36621 * throttling is active or not. */
36622 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36623 + pax_open_kernel();
36624 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36625 + pax_close_kernel();
36626
36627 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
36628 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
36629 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
36630 index c71ee14..7c2e183 100644
36631 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
36632 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
36633 @@ -18,14 +18,12 @@
36634 #include <asm/head.h>
36635 #include <asm/timer.h>
36636
36637 -static struct cpufreq_driver *cpufreq_us3_driver;
36638 -
36639 struct us3_freq_percpu_info {
36640 struct cpufreq_frequency_table table[4];
36641 };
36642
36643 /* Indexed by cpu number. */
36644 -static struct us3_freq_percpu_info *us3_freq_table;
36645 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
36646
36647 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
36648 * in the Safari config register.
36649 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
36650
36651 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
36652 {
36653 - if (cpufreq_us3_driver)
36654 - us3_set_cpu_divider_index(policy, 0);
36655 + us3_set_cpu_divider_index(policy->cpu, 0);
36656
36657 return 0;
36658 }
36659
36660 +static int __init us3_freq_init(void);
36661 +static void __exit us3_freq_exit(void);
36662 +
36663 +static struct cpufreq_driver cpufreq_us3_driver = {
36664 + .init = us3_freq_cpu_init,
36665 + .verify = us3_freq_verify,
36666 + .target = us3_freq_target,
36667 + .get = us3_freq_get,
36668 + .exit = us3_freq_cpu_exit,
36669 + .owner = THIS_MODULE,
36670 + .name = "UltraSPARC-III",
36671 +
36672 +};
36673 +
36674 static int __init us3_freq_init(void)
36675 {
36676 unsigned long manuf, impl, ver;
36677 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
36678 (impl == CHEETAH_IMPL ||
36679 impl == CHEETAH_PLUS_IMPL ||
36680 impl == JAGUAR_IMPL ||
36681 - impl == PANTHER_IMPL)) {
36682 - struct cpufreq_driver *driver;
36683 -
36684 - ret = -ENOMEM;
36685 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
36686 - if (!driver)
36687 - goto err_out;
36688 -
36689 - us3_freq_table = kzalloc(
36690 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
36691 - GFP_KERNEL);
36692 - if (!us3_freq_table)
36693 - goto err_out;
36694 -
36695 - driver->init = us3_freq_cpu_init;
36696 - driver->verify = us3_freq_verify;
36697 - driver->target = us3_freq_target;
36698 - driver->get = us3_freq_get;
36699 - driver->exit = us3_freq_cpu_exit;
36700 - driver->owner = THIS_MODULE,
36701 - strcpy(driver->name, "UltraSPARC-III");
36702 -
36703 - cpufreq_us3_driver = driver;
36704 - ret = cpufreq_register_driver(driver);
36705 - if (ret)
36706 - goto err_out;
36707 -
36708 - return 0;
36709 -
36710 -err_out:
36711 - if (driver) {
36712 - kfree(driver);
36713 - cpufreq_us3_driver = NULL;
36714 - }
36715 - kfree(us3_freq_table);
36716 - us3_freq_table = NULL;
36717 - return ret;
36718 - }
36719 + impl == PANTHER_IMPL))
36720 + return cpufreq_register_driver(&cpufreq_us3_driver);
36721
36722 return -ENODEV;
36723 }
36724
36725 static void __exit us3_freq_exit(void)
36726 {
36727 - if (cpufreq_us3_driver) {
36728 - cpufreq_unregister_driver(cpufreq_us3_driver);
36729 - kfree(cpufreq_us3_driver);
36730 - cpufreq_us3_driver = NULL;
36731 - kfree(us3_freq_table);
36732 - us3_freq_table = NULL;
36733 - }
36734 + cpufreq_unregister_driver(&cpufreq_us3_driver);
36735 }
36736
36737 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
36738 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
36739 index 618e6f4..e89d915 100644
36740 --- a/drivers/cpufreq/speedstep-centrino.c
36741 +++ b/drivers/cpufreq/speedstep-centrino.c
36742 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
36743 !cpu_has(cpu, X86_FEATURE_EST))
36744 return -ENODEV;
36745
36746 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
36747 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
36748 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
36749 + pax_open_kernel();
36750 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
36751 + pax_close_kernel();
36752 + }
36753
36754 if (policy->cpu != 0)
36755 return -ENODEV;
36756 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
36757 index c3a93fe..e808f24 100644
36758 --- a/drivers/cpuidle/cpuidle.c
36759 +++ b/drivers/cpuidle/cpuidle.c
36760 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
36761
36762 static void poll_idle_init(struct cpuidle_driver *drv)
36763 {
36764 - struct cpuidle_state *state = &drv->states[0];
36765 + cpuidle_state_no_const *state = &drv->states[0];
36766
36767 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
36768 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
36769 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
36770 index ea2f8e7..70ac501 100644
36771 --- a/drivers/cpuidle/governor.c
36772 +++ b/drivers/cpuidle/governor.c
36773 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
36774 mutex_lock(&cpuidle_lock);
36775 if (__cpuidle_find_governor(gov->name) == NULL) {
36776 ret = 0;
36777 - list_add_tail(&gov->governor_list, &cpuidle_governors);
36778 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
36779 if (!cpuidle_curr_governor ||
36780 cpuidle_curr_governor->rating < gov->rating)
36781 cpuidle_switch_governor(gov);
36782 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
36783 new_gov = cpuidle_replace_governor(gov->rating);
36784 cpuidle_switch_governor(new_gov);
36785 }
36786 - list_del(&gov->governor_list);
36787 + pax_list_del((struct list_head *)&gov->governor_list);
36788 mutex_unlock(&cpuidle_lock);
36789 }
36790
36791 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
36792 index 428754a..8bdf9cc 100644
36793 --- a/drivers/cpuidle/sysfs.c
36794 +++ b/drivers/cpuidle/sysfs.c
36795 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
36796 NULL
36797 };
36798
36799 -static struct attribute_group cpuidle_attr_group = {
36800 +static attribute_group_no_const cpuidle_attr_group = {
36801 .attrs = cpuidle_default_attrs,
36802 .name = "cpuidle",
36803 };
36804 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
36805 index 3b36797..db0b0c0 100644
36806 --- a/drivers/devfreq/devfreq.c
36807 +++ b/drivers/devfreq/devfreq.c
36808 @@ -477,7 +477,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
36809 GFP_KERNEL);
36810 devfreq->last_stat_updated = jiffies;
36811
36812 - dev_set_name(&devfreq->dev, dev_name(dev));
36813 + dev_set_name(&devfreq->dev, "%s", dev_name(dev));
36814 err = device_register(&devfreq->dev);
36815 if (err) {
36816 put_device(&devfreq->dev);
36817 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
36818 goto err_out;
36819 }
36820
36821 - list_add(&governor->node, &devfreq_governor_list);
36822 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
36823
36824 list_for_each_entry(devfreq, &devfreq_list, node) {
36825 int ret = 0;
36826 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
36827 }
36828 }
36829
36830 - list_del(&governor->node);
36831 + pax_list_del((struct list_head *)&governor->node);
36832 err_out:
36833 mutex_unlock(&devfreq_list_lock);
36834
36835 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
36836 index b70709b..1d8d02a 100644
36837 --- a/drivers/dma/sh/shdma.c
36838 +++ b/drivers/dma/sh/shdma.c
36839 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
36840 return ret;
36841 }
36842
36843 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
36844 +static struct notifier_block sh_dmae_nmi_notifier = {
36845 .notifier_call = sh_dmae_nmi_handler,
36846
36847 /* Run before NMI debug handler and KGDB */
36848 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
36849 index c4d700a..0b57abd 100644
36850 --- a/drivers/edac/edac_mc_sysfs.c
36851 +++ b/drivers/edac/edac_mc_sysfs.c
36852 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
36853 struct dev_ch_attribute {
36854 struct device_attribute attr;
36855 int channel;
36856 -};
36857 +} __do_const;
36858
36859 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
36860 struct dev_ch_attribute dev_attr_legacy_##_name = \
36861 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
36862 }
36863
36864 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
36865 + pax_open_kernel();
36866 if (mci->get_sdram_scrub_rate) {
36867 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
36868 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
36869 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
36870 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
36871 }
36872 if (mci->set_sdram_scrub_rate) {
36873 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
36874 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
36875 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
36876 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
36877 }
36878 + pax_close_kernel();
36879 err = device_create_file(&mci->dev,
36880 &dev_attr_sdram_scrub_rate);
36881 if (err) {
36882 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
36883 index e8658e4..22746d6 100644
36884 --- a/drivers/edac/edac_pci_sysfs.c
36885 +++ b/drivers/edac/edac_pci_sysfs.c
36886 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
36887 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
36888 static int edac_pci_poll_msec = 1000; /* one second workq period */
36889
36890 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
36891 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
36892 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
36893 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
36894
36895 static struct kobject *edac_pci_top_main_kobj;
36896 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
36897 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
36898 void *value;
36899 ssize_t(*show) (void *, char *);
36900 ssize_t(*store) (void *, const char *, size_t);
36901 -};
36902 +} __do_const;
36903
36904 /* Set of show/store abstract level functions for PCI Parity object */
36905 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
36906 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36907 edac_printk(KERN_CRIT, EDAC_PCI,
36908 "Signaled System Error on %s\n",
36909 pci_name(dev));
36910 - atomic_inc(&pci_nonparity_count);
36911 + atomic_inc_unchecked(&pci_nonparity_count);
36912 }
36913
36914 if (status & (PCI_STATUS_PARITY)) {
36915 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36916 "Master Data Parity Error on %s\n",
36917 pci_name(dev));
36918
36919 - atomic_inc(&pci_parity_count);
36920 + atomic_inc_unchecked(&pci_parity_count);
36921 }
36922
36923 if (status & (PCI_STATUS_DETECTED_PARITY)) {
36924 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36925 "Detected Parity Error on %s\n",
36926 pci_name(dev));
36927
36928 - atomic_inc(&pci_parity_count);
36929 + atomic_inc_unchecked(&pci_parity_count);
36930 }
36931 }
36932
36933 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36934 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
36935 "Signaled System Error on %s\n",
36936 pci_name(dev));
36937 - atomic_inc(&pci_nonparity_count);
36938 + atomic_inc_unchecked(&pci_nonparity_count);
36939 }
36940
36941 if (status & (PCI_STATUS_PARITY)) {
36942 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36943 "Master Data Parity Error on "
36944 "%s\n", pci_name(dev));
36945
36946 - atomic_inc(&pci_parity_count);
36947 + atomic_inc_unchecked(&pci_parity_count);
36948 }
36949
36950 if (status & (PCI_STATUS_DETECTED_PARITY)) {
36951 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36952 "Detected Parity Error on %s\n",
36953 pci_name(dev));
36954
36955 - atomic_inc(&pci_parity_count);
36956 + atomic_inc_unchecked(&pci_parity_count);
36957 }
36958 }
36959 }
36960 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
36961 if (!check_pci_errors)
36962 return;
36963
36964 - before_count = atomic_read(&pci_parity_count);
36965 + before_count = atomic_read_unchecked(&pci_parity_count);
36966
36967 /* scan all PCI devices looking for a Parity Error on devices and
36968 * bridges.
36969 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
36970 /* Only if operator has selected panic on PCI Error */
36971 if (edac_pci_get_panic_on_pe()) {
36972 /* If the count is different 'after' from 'before' */
36973 - if (before_count != atomic_read(&pci_parity_count))
36974 + if (before_count != atomic_read_unchecked(&pci_parity_count))
36975 panic("EDAC: PCI Parity Error");
36976 }
36977 }
36978 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
36979 index 51b7e3a..aa8a3e8 100644
36980 --- a/drivers/edac/mce_amd.h
36981 +++ b/drivers/edac/mce_amd.h
36982 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
36983 bool (*mc0_mce)(u16, u8);
36984 bool (*mc1_mce)(u16, u8);
36985 bool (*mc2_mce)(u16, u8);
36986 -};
36987 +} __no_const;
36988
36989 void amd_report_gart_errors(bool);
36990 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
36991 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
36992 index 57ea7f4..789e3c3 100644
36993 --- a/drivers/firewire/core-card.c
36994 +++ b/drivers/firewire/core-card.c
36995 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
36996
36997 void fw_core_remove_card(struct fw_card *card)
36998 {
36999 - struct fw_card_driver dummy_driver = dummy_driver_template;
37000 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37001
37002 card->driver->update_phy_reg(card, 4,
37003 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37004 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37005 index 664a6ff..af13580 100644
37006 --- a/drivers/firewire/core-device.c
37007 +++ b/drivers/firewire/core-device.c
37008 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37009 struct config_rom_attribute {
37010 struct device_attribute attr;
37011 u32 key;
37012 -};
37013 +} __do_const;
37014
37015 static ssize_t show_immediate(struct device *dev,
37016 struct device_attribute *dattr, char *buf)
37017 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37018 index 28a94c7..58da63a 100644
37019 --- a/drivers/firewire/core-transaction.c
37020 +++ b/drivers/firewire/core-transaction.c
37021 @@ -38,6 +38,7 @@
37022 #include <linux/timer.h>
37023 #include <linux/types.h>
37024 #include <linux/workqueue.h>
37025 +#include <linux/sched.h>
37026
37027 #include <asm/byteorder.h>
37028
37029 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37030 index 515a42c..5ecf3ba 100644
37031 --- a/drivers/firewire/core.h
37032 +++ b/drivers/firewire/core.h
37033 @@ -111,6 +111,7 @@ struct fw_card_driver {
37034
37035 int (*stop_iso)(struct fw_iso_context *ctx);
37036 };
37037 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37038
37039 void fw_card_initialize(struct fw_card *card,
37040 const struct fw_card_driver *driver, struct device *device);
37041 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37042 index 94a58a0..f5eba42 100644
37043 --- a/drivers/firmware/dmi-id.c
37044 +++ b/drivers/firmware/dmi-id.c
37045 @@ -16,7 +16,7 @@
37046 struct dmi_device_attribute{
37047 struct device_attribute dev_attr;
37048 int field;
37049 -};
37050 +} __do_const;
37051 #define to_dmi_dev_attr(_dev_attr) \
37052 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37053
37054 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37055 index b95159b..841ae55 100644
37056 --- a/drivers/firmware/dmi_scan.c
37057 +++ b/drivers/firmware/dmi_scan.c
37058 @@ -497,11 +497,6 @@ void __init dmi_scan_machine(void)
37059 }
37060 }
37061 else {
37062 - /*
37063 - * no iounmap() for that ioremap(); it would be a no-op, but
37064 - * it's so early in setup that sucker gets confused into doing
37065 - * what it shouldn't if we actually call it.
37066 - */
37067 p = dmi_ioremap(0xF0000, 0x10000);
37068 if (p == NULL)
37069 goto error;
37070 @@ -786,7 +781,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37071 if (buf == NULL)
37072 return -1;
37073
37074 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37075 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37076
37077 iounmap(buf);
37078 return 0;
37079 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37080 index 5145fa3..0d3babd 100644
37081 --- a/drivers/firmware/efi/efi.c
37082 +++ b/drivers/firmware/efi/efi.c
37083 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37084 };
37085
37086 static struct efivars generic_efivars;
37087 -static struct efivar_operations generic_ops;
37088 +static efivar_operations_no_const generic_ops __read_only;
37089
37090 static int generic_ops_register(void)
37091 {
37092 - generic_ops.get_variable = efi.get_variable;
37093 - generic_ops.set_variable = efi.set_variable;
37094 - generic_ops.get_next_variable = efi.get_next_variable;
37095 - generic_ops.query_variable_store = efi_query_variable_store;
37096 + pax_open_kernel();
37097 + *(void **)&generic_ops.get_variable = efi.get_variable;
37098 + *(void **)&generic_ops.set_variable = efi.set_variable;
37099 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37100 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37101 + pax_close_kernel();
37102
37103 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37104 }
37105 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37106 index 8bd1bb6..c48b0c6 100644
37107 --- a/drivers/firmware/efi/efivars.c
37108 +++ b/drivers/firmware/efi/efivars.c
37109 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37110 static int
37111 create_efivars_bin_attributes(void)
37112 {
37113 - struct bin_attribute *attr;
37114 + bin_attribute_no_const *attr;
37115 int error;
37116
37117 /* new_var */
37118 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37119 index 2a90ba6..07f3733 100644
37120 --- a/drivers/firmware/google/memconsole.c
37121 +++ b/drivers/firmware/google/memconsole.c
37122 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37123 if (!found_memconsole())
37124 return -ENODEV;
37125
37126 - memconsole_bin_attr.size = memconsole_length;
37127 + pax_open_kernel();
37128 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37129 + pax_close_kernel();
37130
37131 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37132
37133 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37134 index e16d932..f0206ef 100644
37135 --- a/drivers/gpio/gpio-ich.c
37136 +++ b/drivers/gpio/gpio-ich.c
37137 @@ -69,7 +69,7 @@ struct ichx_desc {
37138 /* Some chipsets have quirks, let these use their own request/get */
37139 int (*request)(struct gpio_chip *chip, unsigned offset);
37140 int (*get)(struct gpio_chip *chip, unsigned offset);
37141 -};
37142 +} __do_const;
37143
37144 static struct {
37145 spinlock_t lock;
37146 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37147 index 9902732..64b62dd 100644
37148 --- a/drivers/gpio/gpio-vr41xx.c
37149 +++ b/drivers/gpio/gpio-vr41xx.c
37150 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37151 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37152 maskl, pendl, maskh, pendh);
37153
37154 - atomic_inc(&irq_err_count);
37155 + atomic_inc_unchecked(&irq_err_count);
37156
37157 return -EINVAL;
37158 }
37159 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37160 index ed1334e..ee0dd42 100644
37161 --- a/drivers/gpu/drm/drm_crtc_helper.c
37162 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37163 @@ -321,7 +321,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37164 struct drm_crtc *tmp;
37165 int crtc_mask = 1;
37166
37167 - WARN(!crtc, "checking null crtc?\n");
37168 + BUG_ON(!crtc);
37169
37170 dev = crtc->dev;
37171
37172 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37173 index 9cc247f..36aa285 100644
37174 --- a/drivers/gpu/drm/drm_drv.c
37175 +++ b/drivers/gpu/drm/drm_drv.c
37176 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
37177 /**
37178 * Copy and IOCTL return string to user space
37179 */
37180 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37181 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37182 {
37183 int len;
37184
37185 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
37186 struct drm_file *file_priv = filp->private_data;
37187 struct drm_device *dev;
37188 const struct drm_ioctl_desc *ioctl = NULL;
37189 - drm_ioctl_t *func;
37190 + drm_ioctl_no_const_t func;
37191 unsigned int nr = DRM_IOCTL_NR(cmd);
37192 int retcode = -EINVAL;
37193 char stack_kdata[128];
37194 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
37195 return -ENODEV;
37196
37197 atomic_inc(&dev->ioctl_count);
37198 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37199 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37200 ++file_priv->ioctl_count;
37201
37202 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37203 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37204 index 429e07d..e681a2c 100644
37205 --- a/drivers/gpu/drm/drm_fops.c
37206 +++ b/drivers/gpu/drm/drm_fops.c
37207 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
37208 }
37209
37210 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
37211 - atomic_set(&dev->counts[i], 0);
37212 + atomic_set_unchecked(&dev->counts[i], 0);
37213
37214 dev->sigdata.lock = NULL;
37215
37216 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
37217 if (drm_device_is_unplugged(dev))
37218 return -ENODEV;
37219
37220 - if (!dev->open_count++)
37221 + if (local_inc_return(&dev->open_count) == 1)
37222 need_setup = 1;
37223 mutex_lock(&dev->struct_mutex);
37224 old_imapping = inode->i_mapping;
37225 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
37226 retcode = drm_open_helper(inode, filp, dev);
37227 if (retcode)
37228 goto err_undo;
37229 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
37230 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
37231 if (need_setup) {
37232 retcode = drm_setup(dev);
37233 if (retcode)
37234 @@ -166,7 +166,7 @@ err_undo:
37235 iput(container_of(dev->dev_mapping, struct inode, i_data));
37236 dev->dev_mapping = old_mapping;
37237 mutex_unlock(&dev->struct_mutex);
37238 - dev->open_count--;
37239 + local_dec(&dev->open_count);
37240 return retcode;
37241 }
37242 EXPORT_SYMBOL(drm_open);
37243 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
37244
37245 mutex_lock(&drm_global_mutex);
37246
37247 - DRM_DEBUG("open_count = %d\n", dev->open_count);
37248 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
37249
37250 if (dev->driver->preclose)
37251 dev->driver->preclose(dev, file_priv);
37252 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
37253 * Begin inline drm_release
37254 */
37255
37256 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
37257 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
37258 task_pid_nr(current),
37259 (long)old_encode_dev(file_priv->minor->device),
37260 - dev->open_count);
37261 + local_read(&dev->open_count));
37262
37263 /* Release any auth tokens that might point to this file_priv,
37264 (do that under the drm_global_mutex) */
37265 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
37266 * End inline drm_release
37267 */
37268
37269 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
37270 - if (!--dev->open_count) {
37271 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
37272 + if (local_dec_and_test(&dev->open_count)) {
37273 if (atomic_read(&dev->ioctl_count)) {
37274 DRM_ERROR("Device busy: %d\n",
37275 atomic_read(&dev->ioctl_count));
37276 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
37277 index f731116..629842c 100644
37278 --- a/drivers/gpu/drm/drm_global.c
37279 +++ b/drivers/gpu/drm/drm_global.c
37280 @@ -36,7 +36,7 @@
37281 struct drm_global_item {
37282 struct mutex mutex;
37283 void *object;
37284 - int refcount;
37285 + atomic_t refcount;
37286 };
37287
37288 static struct drm_global_item glob[DRM_GLOBAL_NUM];
37289 @@ -49,7 +49,7 @@ void drm_global_init(void)
37290 struct drm_global_item *item = &glob[i];
37291 mutex_init(&item->mutex);
37292 item->object = NULL;
37293 - item->refcount = 0;
37294 + atomic_set(&item->refcount, 0);
37295 }
37296 }
37297
37298 @@ -59,7 +59,7 @@ void drm_global_release(void)
37299 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
37300 struct drm_global_item *item = &glob[i];
37301 BUG_ON(item->object != NULL);
37302 - BUG_ON(item->refcount != 0);
37303 + BUG_ON(atomic_read(&item->refcount) != 0);
37304 }
37305 }
37306
37307 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
37308 void *object;
37309
37310 mutex_lock(&item->mutex);
37311 - if (item->refcount == 0) {
37312 + if (atomic_read(&item->refcount) == 0) {
37313 item->object = kzalloc(ref->size, GFP_KERNEL);
37314 if (unlikely(item->object == NULL)) {
37315 ret = -ENOMEM;
37316 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
37317 goto out_err;
37318
37319 }
37320 - ++item->refcount;
37321 + atomic_inc(&item->refcount);
37322 ref->object = item->object;
37323 object = item->object;
37324 mutex_unlock(&item->mutex);
37325 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
37326 struct drm_global_item *item = &glob[ref->global_type];
37327
37328 mutex_lock(&item->mutex);
37329 - BUG_ON(item->refcount == 0);
37330 + BUG_ON(atomic_read(&item->refcount) == 0);
37331 BUG_ON(ref->object != item->object);
37332 - if (--item->refcount == 0) {
37333 + if (atomic_dec_and_test(&item->refcount)) {
37334 ref->release(ref);
37335 item->object = NULL;
37336 }
37337 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
37338 index d4b20ce..77a8d41 100644
37339 --- a/drivers/gpu/drm/drm_info.c
37340 +++ b/drivers/gpu/drm/drm_info.c
37341 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
37342 struct drm_local_map *map;
37343 struct drm_map_list *r_list;
37344
37345 - /* Hardcoded from _DRM_FRAME_BUFFER,
37346 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
37347 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
37348 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
37349 + static const char * const types[] = {
37350 + [_DRM_FRAME_BUFFER] = "FB",
37351 + [_DRM_REGISTERS] = "REG",
37352 + [_DRM_SHM] = "SHM",
37353 + [_DRM_AGP] = "AGP",
37354 + [_DRM_SCATTER_GATHER] = "SG",
37355 + [_DRM_CONSISTENT] = "PCI",
37356 + [_DRM_GEM] = "GEM" };
37357 const char *type;
37358 int i;
37359
37360 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
37361 map = r_list->map;
37362 if (!map)
37363 continue;
37364 - if (map->type < 0 || map->type > 5)
37365 + if (map->type >= ARRAY_SIZE(types))
37366 type = "??";
37367 else
37368 type = types[map->type];
37369 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
37370 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
37371 vma->vm_flags & VM_LOCKED ? 'l' : '-',
37372 vma->vm_flags & VM_IO ? 'i' : '-',
37373 +#ifdef CONFIG_GRKERNSEC_HIDESYM
37374 + 0);
37375 +#else
37376 vma->vm_pgoff);
37377 +#endif
37378
37379 #if defined(__i386__)
37380 pgprot = pgprot_val(vma->vm_page_prot);
37381 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
37382 index 2f4c434..dd12cd2 100644
37383 --- a/drivers/gpu/drm/drm_ioc32.c
37384 +++ b/drivers/gpu/drm/drm_ioc32.c
37385 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
37386 request = compat_alloc_user_space(nbytes);
37387 if (!access_ok(VERIFY_WRITE, request, nbytes))
37388 return -EFAULT;
37389 - list = (struct drm_buf_desc *) (request + 1);
37390 + list = (struct drm_buf_desc __user *) (request + 1);
37391
37392 if (__put_user(count, &request->count)
37393 || __put_user(list, &request->list))
37394 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
37395 request = compat_alloc_user_space(nbytes);
37396 if (!access_ok(VERIFY_WRITE, request, nbytes))
37397 return -EFAULT;
37398 - list = (struct drm_buf_pub *) (request + 1);
37399 + list = (struct drm_buf_pub __user *) (request + 1);
37400
37401 if (__put_user(count, &request->count)
37402 || __put_user(list, &request->list))
37403 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
37404 return 0;
37405 }
37406
37407 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
37408 +drm_ioctl_compat_t drm_compat_ioctls[] = {
37409 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
37410 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
37411 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
37412 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
37413 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
37414 {
37415 unsigned int nr = DRM_IOCTL_NR(cmd);
37416 - drm_ioctl_compat_t *fn;
37417 int ret;
37418
37419 /* Assume that ioctls without an explicit compat routine will just
37420 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
37421 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
37422 return drm_ioctl(filp, cmd, arg);
37423
37424 - fn = drm_compat_ioctls[nr];
37425 -
37426 - if (fn != NULL)
37427 - ret = (*fn) (filp, cmd, arg);
37428 + if (drm_compat_ioctls[nr] != NULL)
37429 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
37430 else
37431 ret = drm_ioctl(filp, cmd, arg);
37432
37433 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
37434 index e77bd8b..1571b85 100644
37435 --- a/drivers/gpu/drm/drm_ioctl.c
37436 +++ b/drivers/gpu/drm/drm_ioctl.c
37437 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
37438 stats->data[i].value =
37439 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
37440 else
37441 - stats->data[i].value = atomic_read(&dev->counts[i]);
37442 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
37443 stats->data[i].type = dev->types[i];
37444 }
37445
37446 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
37447 index d752c96..fe08455 100644
37448 --- a/drivers/gpu/drm/drm_lock.c
37449 +++ b/drivers/gpu/drm/drm_lock.c
37450 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
37451 if (drm_lock_take(&master->lock, lock->context)) {
37452 master->lock.file_priv = file_priv;
37453 master->lock.lock_time = jiffies;
37454 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
37455 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
37456 break; /* Got lock */
37457 }
37458
37459 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
37460 return -EINVAL;
37461 }
37462
37463 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
37464 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
37465
37466 if (drm_lock_free(&master->lock, lock->context)) {
37467 /* FIXME: Should really bail out here. */
37468 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
37469 index 16f3ec5..b28f9ca 100644
37470 --- a/drivers/gpu/drm/drm_stub.c
37471 +++ b/drivers/gpu/drm/drm_stub.c
37472 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
37473
37474 drm_device_set_unplugged(dev);
37475
37476 - if (dev->open_count == 0) {
37477 + if (local_read(&dev->open_count) == 0) {
37478 drm_put_dev(dev);
37479 }
37480 mutex_unlock(&drm_global_mutex);
37481 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
37482 index 0229665..f61329c 100644
37483 --- a/drivers/gpu/drm/drm_sysfs.c
37484 +++ b/drivers/gpu/drm/drm_sysfs.c
37485 @@ -499,7 +499,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
37486 int drm_sysfs_device_add(struct drm_minor *minor)
37487 {
37488 int err;
37489 - char *minor_str;
37490 + const char *minor_str;
37491
37492 minor->kdev.parent = minor->dev->dev;
37493
37494 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
37495 index 004ecdf..db1f6e0 100644
37496 --- a/drivers/gpu/drm/i810/i810_dma.c
37497 +++ b/drivers/gpu/drm/i810/i810_dma.c
37498 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
37499 dma->buflist[vertex->idx],
37500 vertex->discard, vertex->used);
37501
37502 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
37503 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
37504 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
37505 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
37506 sarea_priv->last_enqueue = dev_priv->counter - 1;
37507 sarea_priv->last_dispatch = (int)hw_status[5];
37508
37509 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
37510 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
37511 mc->last_render);
37512
37513 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
37514 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
37515 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
37516 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
37517 sarea_priv->last_enqueue = dev_priv->counter - 1;
37518 sarea_priv->last_dispatch = (int)hw_status[5];
37519
37520 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
37521 index 6e0acad..93c8289 100644
37522 --- a/drivers/gpu/drm/i810/i810_drv.h
37523 +++ b/drivers/gpu/drm/i810/i810_drv.h
37524 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
37525 int page_flipping;
37526
37527 wait_queue_head_t irq_queue;
37528 - atomic_t irq_received;
37529 - atomic_t irq_emitted;
37530 + atomic_unchecked_t irq_received;
37531 + atomic_unchecked_t irq_emitted;
37532
37533 int front_offset;
37534 } drm_i810_private_t;
37535 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
37536 index e913d32..4d9b351 100644
37537 --- a/drivers/gpu/drm/i915/i915_debugfs.c
37538 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
37539 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
37540 I915_READ(GTIMR));
37541 }
37542 seq_printf(m, "Interrupts received: %d\n",
37543 - atomic_read(&dev_priv->irq_received));
37544 + atomic_read_unchecked(&dev_priv->irq_received));
37545 for_each_ring(ring, dev_priv, i) {
37546 if (IS_GEN6(dev) || IS_GEN7(dev)) {
37547 seq_printf(m,
37548 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
37549 index 17d9b0b..860e6d9 100644
37550 --- a/drivers/gpu/drm/i915/i915_dma.c
37551 +++ b/drivers/gpu/drm/i915/i915_dma.c
37552 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
37553 bool can_switch;
37554
37555 spin_lock(&dev->count_lock);
37556 - can_switch = (dev->open_count == 0);
37557 + can_switch = (local_read(&dev->open_count) == 0);
37558 spin_unlock(&dev->count_lock);
37559 return can_switch;
37560 }
37561 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
37562 index 47d8b68..52f5d8d 100644
37563 --- a/drivers/gpu/drm/i915/i915_drv.h
37564 +++ b/drivers/gpu/drm/i915/i915_drv.h
37565 @@ -916,7 +916,7 @@ typedef struct drm_i915_private {
37566 drm_dma_handle_t *status_page_dmah;
37567 struct resource mch_res;
37568
37569 - atomic_t irq_received;
37570 + atomic_unchecked_t irq_received;
37571
37572 /* protects the irq masks */
37573 spinlock_t irq_lock;
37574 @@ -1813,7 +1813,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
37575 struct drm_i915_private *dev_priv, unsigned port);
37576 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
37577 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
37578 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
37579 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
37580 {
37581 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
37582 }
37583 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
37584 index 117ce38..eefd237 100644
37585 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
37586 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
37587 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
37588
37589 static int
37590 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
37591 - int count)
37592 + unsigned int count)
37593 {
37594 - int i;
37595 + unsigned int i;
37596 int relocs_total = 0;
37597 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
37598
37599 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
37600 index 3c59584..500f2e9 100644
37601 --- a/drivers/gpu/drm/i915/i915_ioc32.c
37602 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
37603 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
37604 (unsigned long)request);
37605 }
37606
37607 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
37608 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
37609 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
37610 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
37611 [DRM_I915_GETPARAM] = compat_i915_getparam,
37612 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
37613 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
37614 {
37615 unsigned int nr = DRM_IOCTL_NR(cmd);
37616 - drm_ioctl_compat_t *fn = NULL;
37617 int ret;
37618
37619 if (nr < DRM_COMMAND_BASE)
37620 return drm_compat_ioctl(filp, cmd, arg);
37621
37622 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
37623 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
37624 -
37625 - if (fn != NULL)
37626 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
37627 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
37628 ret = (*fn) (filp, cmd, arg);
37629 - else
37630 + } else
37631 ret = drm_ioctl(filp, cmd, arg);
37632
37633 return ret;
37634 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
37635 index e5e32869..1678f36 100644
37636 --- a/drivers/gpu/drm/i915/i915_irq.c
37637 +++ b/drivers/gpu/drm/i915/i915_irq.c
37638 @@ -670,7 +670,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
37639 int pipe;
37640 u32 pipe_stats[I915_MAX_PIPES];
37641
37642 - atomic_inc(&dev_priv->irq_received);
37643 + atomic_inc_unchecked(&dev_priv->irq_received);
37644
37645 while (true) {
37646 iir = I915_READ(VLV_IIR);
37647 @@ -835,7 +835,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
37648 irqreturn_t ret = IRQ_NONE;
37649 int i;
37650
37651 - atomic_inc(&dev_priv->irq_received);
37652 + atomic_inc_unchecked(&dev_priv->irq_received);
37653
37654 /* disable master interrupt before clearing iir */
37655 de_ier = I915_READ(DEIER);
37656 @@ -925,7 +925,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
37657 int ret = IRQ_NONE;
37658 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
37659
37660 - atomic_inc(&dev_priv->irq_received);
37661 + atomic_inc_unchecked(&dev_priv->irq_received);
37662
37663 /* disable master interrupt before clearing iir */
37664 de_ier = I915_READ(DEIER);
37665 @@ -2089,7 +2089,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
37666 {
37667 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
37668
37669 - atomic_set(&dev_priv->irq_received, 0);
37670 + atomic_set_unchecked(&dev_priv->irq_received, 0);
37671
37672 I915_WRITE(HWSTAM, 0xeffe);
37673
37674 @@ -2124,7 +2124,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
37675 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
37676 int pipe;
37677
37678 - atomic_set(&dev_priv->irq_received, 0);
37679 + atomic_set_unchecked(&dev_priv->irq_received, 0);
37680
37681 /* VLV magic */
37682 I915_WRITE(VLV_IMR, 0);
37683 @@ -2411,7 +2411,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
37684 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
37685 int pipe;
37686
37687 - atomic_set(&dev_priv->irq_received, 0);
37688 + atomic_set_unchecked(&dev_priv->irq_received, 0);
37689
37690 for_each_pipe(pipe)
37691 I915_WRITE(PIPESTAT(pipe), 0);
37692 @@ -2490,7 +2490,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
37693 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
37694 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
37695
37696 - atomic_inc(&dev_priv->irq_received);
37697 + atomic_inc_unchecked(&dev_priv->irq_received);
37698
37699 iir = I915_READ16(IIR);
37700 if (iir == 0)
37701 @@ -2565,7 +2565,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
37702 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
37703 int pipe;
37704
37705 - atomic_set(&dev_priv->irq_received, 0);
37706 + atomic_set_unchecked(&dev_priv->irq_received, 0);
37707
37708 if (I915_HAS_HOTPLUG(dev)) {
37709 I915_WRITE(PORT_HOTPLUG_EN, 0);
37710 @@ -2664,7 +2664,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
37711 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
37712 int pipe, ret = IRQ_NONE;
37713
37714 - atomic_inc(&dev_priv->irq_received);
37715 + atomic_inc_unchecked(&dev_priv->irq_received);
37716
37717 iir = I915_READ(IIR);
37718 do {
37719 @@ -2791,7 +2791,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
37720 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
37721 int pipe;
37722
37723 - atomic_set(&dev_priv->irq_received, 0);
37724 + atomic_set_unchecked(&dev_priv->irq_received, 0);
37725
37726 I915_WRITE(PORT_HOTPLUG_EN, 0);
37727 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
37728 @@ -2898,7 +2898,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
37729 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
37730 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
37731
37732 - atomic_inc(&dev_priv->irq_received);
37733 + atomic_inc_unchecked(&dev_priv->irq_received);
37734
37735 iir = I915_READ(IIR);
37736
37737 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
37738 index eea5982..eeef407 100644
37739 --- a/drivers/gpu/drm/i915/intel_display.c
37740 +++ b/drivers/gpu/drm/i915/intel_display.c
37741 @@ -8935,13 +8935,13 @@ struct intel_quirk {
37742 int subsystem_vendor;
37743 int subsystem_device;
37744 void (*hook)(struct drm_device *dev);
37745 -};
37746 +} __do_const;
37747
37748 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
37749 struct intel_dmi_quirk {
37750 void (*hook)(struct drm_device *dev);
37751 const struct dmi_system_id (*dmi_id_list)[];
37752 -};
37753 +} __do_const;
37754
37755 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
37756 {
37757 @@ -8949,18 +8949,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
37758 return 1;
37759 }
37760
37761 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
37762 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
37763 {
37764 - .dmi_id_list = &(const struct dmi_system_id[]) {
37765 - {
37766 - .callback = intel_dmi_reverse_brightness,
37767 - .ident = "NCR Corporation",
37768 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
37769 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
37770 - },
37771 - },
37772 - { } /* terminating entry */
37773 + .callback = intel_dmi_reverse_brightness,
37774 + .ident = "NCR Corporation",
37775 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
37776 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
37777 },
37778 + },
37779 + { } /* terminating entry */
37780 +};
37781 +
37782 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
37783 + {
37784 + .dmi_id_list = &intel_dmi_quirks_table,
37785 .hook = quirk_invert_brightness,
37786 },
37787 };
37788 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
37789 index 54558a0..2d97005 100644
37790 --- a/drivers/gpu/drm/mga/mga_drv.h
37791 +++ b/drivers/gpu/drm/mga/mga_drv.h
37792 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
37793 u32 clear_cmd;
37794 u32 maccess;
37795
37796 - atomic_t vbl_received; /**< Number of vblanks received. */
37797 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
37798 wait_queue_head_t fence_queue;
37799 - atomic_t last_fence_retired;
37800 + atomic_unchecked_t last_fence_retired;
37801 u32 next_fence_to_post;
37802
37803 unsigned int fb_cpp;
37804 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
37805 index 709e90d..89a1c0d 100644
37806 --- a/drivers/gpu/drm/mga/mga_ioc32.c
37807 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
37808 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
37809 return 0;
37810 }
37811
37812 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
37813 +drm_ioctl_compat_t mga_compat_ioctls[] = {
37814 [DRM_MGA_INIT] = compat_mga_init,
37815 [DRM_MGA_GETPARAM] = compat_mga_getparam,
37816 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
37817 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
37818 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
37819 {
37820 unsigned int nr = DRM_IOCTL_NR(cmd);
37821 - drm_ioctl_compat_t *fn = NULL;
37822 int ret;
37823
37824 if (nr < DRM_COMMAND_BASE)
37825 return drm_compat_ioctl(filp, cmd, arg);
37826
37827 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
37828 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
37829 -
37830 - if (fn != NULL)
37831 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
37832 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
37833 ret = (*fn) (filp, cmd, arg);
37834 - else
37835 + } else
37836 ret = drm_ioctl(filp, cmd, arg);
37837
37838 return ret;
37839 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
37840 index 598c281..60d590e 100644
37841 --- a/drivers/gpu/drm/mga/mga_irq.c
37842 +++ b/drivers/gpu/drm/mga/mga_irq.c
37843 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
37844 if (crtc != 0)
37845 return 0;
37846
37847 - return atomic_read(&dev_priv->vbl_received);
37848 + return atomic_read_unchecked(&dev_priv->vbl_received);
37849 }
37850
37851
37852 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
37853 /* VBLANK interrupt */
37854 if (status & MGA_VLINEPEN) {
37855 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
37856 - atomic_inc(&dev_priv->vbl_received);
37857 + atomic_inc_unchecked(&dev_priv->vbl_received);
37858 drm_handle_vblank(dev, 0);
37859 handled = 1;
37860 }
37861 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
37862 if ((prim_start & ~0x03) != (prim_end & ~0x03))
37863 MGA_WRITE(MGA_PRIMEND, prim_end);
37864
37865 - atomic_inc(&dev_priv->last_fence_retired);
37866 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
37867 DRM_WAKEUP(&dev_priv->fence_queue);
37868 handled = 1;
37869 }
37870 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
37871 * using fences.
37872 */
37873 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
37874 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
37875 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
37876 - *sequence) <= (1 << 23)));
37877
37878 *sequence = cur_fence;
37879 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
37880 index 6aa2137..fe8dc55 100644
37881 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
37882 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
37883 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
37884 struct bit_table {
37885 const char id;
37886 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
37887 -};
37888 +} __no_const;
37889
37890 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
37891
37892 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
37893 index f2b30f8..d0f9a95 100644
37894 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
37895 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
37896 @@ -92,7 +92,7 @@ struct nouveau_drm {
37897 struct drm_global_reference mem_global_ref;
37898 struct ttm_bo_global_ref bo_global_ref;
37899 struct ttm_bo_device bdev;
37900 - atomic_t validate_sequence;
37901 + atomic_unchecked_t validate_sequence;
37902 int (*move)(struct nouveau_channel *,
37903 struct ttm_buffer_object *,
37904 struct ttm_mem_reg *, struct ttm_mem_reg *);
37905 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
37906 index b4b4d0c..b7edc15 100644
37907 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
37908 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
37909 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
37910 int ret, i;
37911 struct nouveau_bo *res_bo = NULL;
37912
37913 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
37914 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
37915 retry:
37916 if (++trycnt > 100000) {
37917 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
37918 @@ -359,7 +359,7 @@ retry:
37919 if (ret) {
37920 validate_fini(op, NULL);
37921 if (unlikely(ret == -EAGAIN)) {
37922 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
37923 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
37924 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
37925 sequence);
37926 if (!ret)
37927 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
37928 index 08214bc..9208577 100644
37929 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
37930 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
37931 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
37932 unsigned long arg)
37933 {
37934 unsigned int nr = DRM_IOCTL_NR(cmd);
37935 - drm_ioctl_compat_t *fn = NULL;
37936 + drm_ioctl_compat_t fn = NULL;
37937 int ret;
37938
37939 if (nr < DRM_COMMAND_BASE)
37940 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
37941 index 25d3495..d81aaf6 100644
37942 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
37943 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
37944 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
37945 bool can_switch;
37946
37947 spin_lock(&dev->count_lock);
37948 - can_switch = (dev->open_count == 0);
37949 + can_switch = (local_read(&dev->open_count) == 0);
37950 spin_unlock(&dev->count_lock);
37951 return can_switch;
37952 }
37953 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
37954 index 489cb8c..0b8d0d3 100644
37955 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
37956 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
37957 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
37958 }
37959 }
37960
37961 -static struct vm_operations_struct qxl_ttm_vm_ops;
37962 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
37963 static const struct vm_operations_struct *ttm_vm_ops;
37964
37965 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
37966 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
37967 return r;
37968 if (unlikely(ttm_vm_ops == NULL)) {
37969 ttm_vm_ops = vma->vm_ops;
37970 + pax_open_kernel();
37971 qxl_ttm_vm_ops = *ttm_vm_ops;
37972 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
37973 + pax_close_kernel();
37974 }
37975 vma->vm_ops = &qxl_ttm_vm_ops;
37976 return 0;
37977 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
37978 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
37979 {
37980 #if defined(CONFIG_DEBUG_FS)
37981 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
37982 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
37983 - unsigned i;
37984 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
37985 + {
37986 + .name = "qxl_mem_mm",
37987 + .show = &qxl_mm_dump_table,
37988 + },
37989 + {
37990 + .name = "qxl_surf_mm",
37991 + .show = &qxl_mm_dump_table,
37992 + }
37993 + };
37994
37995 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
37996 - if (i == 0)
37997 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
37998 - else
37999 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38000 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38001 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38002 - qxl_mem_types_list[i].driver_features = 0;
38003 - if (i == 0)
38004 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38005 - else
38006 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38007 + pax_open_kernel();
38008 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38009 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38010 + pax_close_kernel();
38011
38012 - }
38013 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38014 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38015 #else
38016 return 0;
38017 #endif
38018 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38019 index d4660cf..70dbe65 100644
38020 --- a/drivers/gpu/drm/r128/r128_cce.c
38021 +++ b/drivers/gpu/drm/r128/r128_cce.c
38022 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38023
38024 /* GH: Simple idle check.
38025 */
38026 - atomic_set(&dev_priv->idle_count, 0);
38027 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38028
38029 /* We don't support anything other than bus-mastering ring mode,
38030 * but the ring can be in either AGP or PCI space for the ring
38031 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38032 index 930c71b..499aded 100644
38033 --- a/drivers/gpu/drm/r128/r128_drv.h
38034 +++ b/drivers/gpu/drm/r128/r128_drv.h
38035 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38036 int is_pci;
38037 unsigned long cce_buffers_offset;
38038
38039 - atomic_t idle_count;
38040 + atomic_unchecked_t idle_count;
38041
38042 int page_flipping;
38043 int current_page;
38044 u32 crtc_offset;
38045 u32 crtc_offset_cntl;
38046
38047 - atomic_t vbl_received;
38048 + atomic_unchecked_t vbl_received;
38049
38050 u32 color_fmt;
38051 unsigned int front_offset;
38052 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38053 index a954c54..9cc595c 100644
38054 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38055 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38056 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38057 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38058 }
38059
38060 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38061 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38062 [DRM_R128_INIT] = compat_r128_init,
38063 [DRM_R128_DEPTH] = compat_r128_depth,
38064 [DRM_R128_STIPPLE] = compat_r128_stipple,
38065 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
38066 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38067 {
38068 unsigned int nr = DRM_IOCTL_NR(cmd);
38069 - drm_ioctl_compat_t *fn = NULL;
38070 int ret;
38071
38072 if (nr < DRM_COMMAND_BASE)
38073 return drm_compat_ioctl(filp, cmd, arg);
38074
38075 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
38076 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38077 -
38078 - if (fn != NULL)
38079 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
38080 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
38081 ret = (*fn) (filp, cmd, arg);
38082 - else
38083 + } else
38084 ret = drm_ioctl(filp, cmd, arg);
38085
38086 return ret;
38087 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
38088 index 2ea4f09..d391371 100644
38089 --- a/drivers/gpu/drm/r128/r128_irq.c
38090 +++ b/drivers/gpu/drm/r128/r128_irq.c
38091 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
38092 if (crtc != 0)
38093 return 0;
38094
38095 - return atomic_read(&dev_priv->vbl_received);
38096 + return atomic_read_unchecked(&dev_priv->vbl_received);
38097 }
38098
38099 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38100 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
38101 /* VBLANK interrupt */
38102 if (status & R128_CRTC_VBLANK_INT) {
38103 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
38104 - atomic_inc(&dev_priv->vbl_received);
38105 + atomic_inc_unchecked(&dev_priv->vbl_received);
38106 drm_handle_vblank(dev, 0);
38107 return IRQ_HANDLED;
38108 }
38109 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
38110 index 19bb7e6..de7e2a2 100644
38111 --- a/drivers/gpu/drm/r128/r128_state.c
38112 +++ b/drivers/gpu/drm/r128/r128_state.c
38113 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38114
38115 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38116 {
38117 - if (atomic_read(&dev_priv->idle_count) == 0)
38118 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38119 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38120 else
38121 - atomic_set(&dev_priv->idle_count, 0);
38122 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38123 }
38124
38125 #endif
38126 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38127 index 5a82b6b..9e69c73 100644
38128 --- a/drivers/gpu/drm/radeon/mkregtable.c
38129 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38130 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
38131 regex_t mask_rex;
38132 regmatch_t match[4];
38133 char buf[1024];
38134 - size_t end;
38135 + long end;
38136 int len;
38137 int done = 0;
38138 int r;
38139 unsigned o;
38140 struct offset *offset;
38141 char last_reg_s[10];
38142 - int last_reg;
38143 + unsigned long last_reg;
38144
38145 if (regcomp
38146 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38147 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38148 index b0dc0b6..a9bfe9c 100644
38149 --- a/drivers/gpu/drm/radeon/radeon_device.c
38150 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38151 @@ -1014,7 +1014,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38152 bool can_switch;
38153
38154 spin_lock(&dev->count_lock);
38155 - can_switch = (dev->open_count == 0);
38156 + can_switch = (local_read(&dev->open_count) == 0);
38157 spin_unlock(&dev->count_lock);
38158 return can_switch;
38159 }
38160 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
38161 index b369d42..8dd04eb 100644
38162 --- a/drivers/gpu/drm/radeon/radeon_drv.h
38163 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
38164 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
38165
38166 /* SW interrupt */
38167 wait_queue_head_t swi_queue;
38168 - atomic_t swi_emitted;
38169 + atomic_unchecked_t swi_emitted;
38170 int vblank_crtc;
38171 uint32_t irq_enable_reg;
38172 uint32_t r500_disp_irq_reg;
38173 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
38174 index c180df8..5fd8186 100644
38175 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
38176 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
38177 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38178 request = compat_alloc_user_space(sizeof(*request));
38179 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
38180 || __put_user(req32.param, &request->param)
38181 - || __put_user((void __user *)(unsigned long)req32.value,
38182 + || __put_user((unsigned long)req32.value,
38183 &request->value))
38184 return -EFAULT;
38185
38186 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38187 #define compat_radeon_cp_setparam NULL
38188 #endif /* X86_64 || IA64 */
38189
38190 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38191 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
38192 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
38193 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
38194 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
38195 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38196 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38197 {
38198 unsigned int nr = DRM_IOCTL_NR(cmd);
38199 - drm_ioctl_compat_t *fn = NULL;
38200 int ret;
38201
38202 if (nr < DRM_COMMAND_BASE)
38203 return drm_compat_ioctl(filp, cmd, arg);
38204
38205 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
38206 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38207 -
38208 - if (fn != NULL)
38209 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
38210 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38211 ret = (*fn) (filp, cmd, arg);
38212 - else
38213 + } else
38214 ret = drm_ioctl(filp, cmd, arg);
38215
38216 return ret;
38217 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
38218 index 8d68e97..9dcfed8 100644
38219 --- a/drivers/gpu/drm/radeon/radeon_irq.c
38220 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
38221 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
38222 unsigned int ret;
38223 RING_LOCALS;
38224
38225 - atomic_inc(&dev_priv->swi_emitted);
38226 - ret = atomic_read(&dev_priv->swi_emitted);
38227 + atomic_inc_unchecked(&dev_priv->swi_emitted);
38228 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
38229
38230 BEGIN_RING(4);
38231 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
38232 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
38233 drm_radeon_private_t *dev_priv =
38234 (drm_radeon_private_t *) dev->dev_private;
38235
38236 - atomic_set(&dev_priv->swi_emitted, 0);
38237 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
38238 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
38239
38240 dev->max_vblank_count = 0x001fffff;
38241 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
38242 index 4d20910..6726b6d 100644
38243 --- a/drivers/gpu/drm/radeon/radeon_state.c
38244 +++ b/drivers/gpu/drm/radeon/radeon_state.c
38245 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
38246 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
38247 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
38248
38249 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
38250 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
38251 sarea_priv->nbox * sizeof(depth_boxes[0])))
38252 return -EFAULT;
38253
38254 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
38255 {
38256 drm_radeon_private_t *dev_priv = dev->dev_private;
38257 drm_radeon_getparam_t *param = data;
38258 - int value;
38259 + int value = 0;
38260
38261 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
38262
38263 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
38264 index 6c0ce89..57a2529 100644
38265 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
38266 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
38267 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
38268 man->size = size >> PAGE_SHIFT;
38269 }
38270
38271 -static struct vm_operations_struct radeon_ttm_vm_ops;
38272 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
38273 static const struct vm_operations_struct *ttm_vm_ops = NULL;
38274
38275 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38276 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
38277 }
38278 if (unlikely(ttm_vm_ops == NULL)) {
38279 ttm_vm_ops = vma->vm_ops;
38280 + pax_open_kernel();
38281 radeon_ttm_vm_ops = *ttm_vm_ops;
38282 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
38283 + pax_close_kernel();
38284 }
38285 vma->vm_ops = &radeon_ttm_vm_ops;
38286 return 0;
38287 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
38288 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
38289 {
38290 #if defined(CONFIG_DEBUG_FS)
38291 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
38292 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
38293 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
38294 + {
38295 + .name = "radeon_vram_mm",
38296 + .show = &radeon_mm_dump_table,
38297 + },
38298 + {
38299 + .name = "radeon_gtt_mm",
38300 + .show = &radeon_mm_dump_table,
38301 + },
38302 + {
38303 + .name = "ttm_page_pool",
38304 + .show = &ttm_page_alloc_debugfs,
38305 + },
38306 + {
38307 + .name = "ttm_dma_page_pool",
38308 + .show = &ttm_dma_page_alloc_debugfs,
38309 + },
38310 + };
38311 unsigned i;
38312
38313 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
38314 - if (i == 0)
38315 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
38316 - else
38317 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
38318 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
38319 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
38320 - radeon_mem_types_list[i].driver_features = 0;
38321 - if (i == 0)
38322 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
38323 - else
38324 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
38325 -
38326 - }
38327 - /* Add ttm page pool to debugfs */
38328 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
38329 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
38330 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
38331 - radeon_mem_types_list[i].driver_features = 0;
38332 - radeon_mem_types_list[i++].data = NULL;
38333 + pax_open_kernel();
38334 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
38335 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
38336 + pax_close_kernel();
38337 #ifdef CONFIG_SWIOTLB
38338 - if (swiotlb_nr_tbl()) {
38339 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
38340 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
38341 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
38342 - radeon_mem_types_list[i].driver_features = 0;
38343 - radeon_mem_types_list[i++].data = NULL;
38344 - }
38345 + if (swiotlb_nr_tbl())
38346 + i++;
38347 #endif
38348 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
38349
38350 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
38351 index 55880d5..9e95342 100644
38352 --- a/drivers/gpu/drm/radeon/rs690.c
38353 +++ b/drivers/gpu/drm/radeon/rs690.c
38354 @@ -327,9 +327,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
38355 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
38356 rdev->pm.sideport_bandwidth.full)
38357 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
38358 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
38359 + read_delay_latency.full = dfixed_const(800 * 1000);
38360 read_delay_latency.full = dfixed_div(read_delay_latency,
38361 rdev->pm.igp_sideport_mclk);
38362 + a.full = dfixed_const(370);
38363 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
38364 } else {
38365 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
38366 rdev->pm.k8_bandwidth.full)
38367 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
38368 index dbc2def..0a9f710 100644
38369 --- a/drivers/gpu/drm/ttm/ttm_memory.c
38370 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
38371 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
38372 zone->glob = glob;
38373 glob->zone_kernel = zone;
38374 ret = kobject_init_and_add(
38375 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
38376 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
38377 if (unlikely(ret != 0)) {
38378 kobject_put(&zone->kobj);
38379 return ret;
38380 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
38381 zone->glob = glob;
38382 glob->zone_dma32 = zone;
38383 ret = kobject_init_and_add(
38384 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
38385 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
38386 if (unlikely(ret != 0)) {
38387 kobject_put(&zone->kobj);
38388 return ret;
38389 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
38390 index bd2a3b4..122d9ad 100644
38391 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
38392 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
38393 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
38394 static int ttm_pool_mm_shrink(struct shrinker *shrink,
38395 struct shrink_control *sc)
38396 {
38397 - static atomic_t start_pool = ATOMIC_INIT(0);
38398 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
38399 unsigned i;
38400 - unsigned pool_offset = atomic_add_return(1, &start_pool);
38401 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
38402 struct ttm_page_pool *pool;
38403 int shrink_pages = sc->nr_to_scan;
38404
38405 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
38406 index dc0c065..58a0782 100644
38407 --- a/drivers/gpu/drm/udl/udl_fb.c
38408 +++ b/drivers/gpu/drm/udl/udl_fb.c
38409 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
38410 fb_deferred_io_cleanup(info);
38411 kfree(info->fbdefio);
38412 info->fbdefio = NULL;
38413 - info->fbops->fb_mmap = udl_fb_mmap;
38414 }
38415
38416 pr_warn("released /dev/fb%d user=%d count=%d\n",
38417 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
38418 index 893a650..6190d3b 100644
38419 --- a/drivers/gpu/drm/via/via_drv.h
38420 +++ b/drivers/gpu/drm/via/via_drv.h
38421 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
38422 typedef uint32_t maskarray_t[5];
38423
38424 typedef struct drm_via_irq {
38425 - atomic_t irq_received;
38426 + atomic_unchecked_t irq_received;
38427 uint32_t pending_mask;
38428 uint32_t enable_mask;
38429 wait_queue_head_t irq_queue;
38430 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
38431 struct timeval last_vblank;
38432 int last_vblank_valid;
38433 unsigned usec_per_vblank;
38434 - atomic_t vbl_received;
38435 + atomic_unchecked_t vbl_received;
38436 drm_via_state_t hc_state;
38437 char pci_buf[VIA_PCI_BUF_SIZE];
38438 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
38439 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
38440 index ac98964..5dbf512 100644
38441 --- a/drivers/gpu/drm/via/via_irq.c
38442 +++ b/drivers/gpu/drm/via/via_irq.c
38443 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
38444 if (crtc != 0)
38445 return 0;
38446
38447 - return atomic_read(&dev_priv->vbl_received);
38448 + return atomic_read_unchecked(&dev_priv->vbl_received);
38449 }
38450
38451 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
38452 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
38453
38454 status = VIA_READ(VIA_REG_INTERRUPT);
38455 if (status & VIA_IRQ_VBLANK_PENDING) {
38456 - atomic_inc(&dev_priv->vbl_received);
38457 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
38458 + atomic_inc_unchecked(&dev_priv->vbl_received);
38459 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
38460 do_gettimeofday(&cur_vblank);
38461 if (dev_priv->last_vblank_valid) {
38462 dev_priv->usec_per_vblank =
38463 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
38464 dev_priv->last_vblank = cur_vblank;
38465 dev_priv->last_vblank_valid = 1;
38466 }
38467 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
38468 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
38469 DRM_DEBUG("US per vblank is: %u\n",
38470 dev_priv->usec_per_vblank);
38471 }
38472 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
38473
38474 for (i = 0; i < dev_priv->num_irqs; ++i) {
38475 if (status & cur_irq->pending_mask) {
38476 - atomic_inc(&cur_irq->irq_received);
38477 + atomic_inc_unchecked(&cur_irq->irq_received);
38478 DRM_WAKEUP(&cur_irq->irq_queue);
38479 handled = 1;
38480 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
38481 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
38482 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
38483 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
38484 masks[irq][4]));
38485 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
38486 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
38487 } else {
38488 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
38489 (((cur_irq_sequence =
38490 - atomic_read(&cur_irq->irq_received)) -
38491 + atomic_read_unchecked(&cur_irq->irq_received)) -
38492 *sequence) <= (1 << 23)));
38493 }
38494 *sequence = cur_irq_sequence;
38495 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
38496 }
38497
38498 for (i = 0; i < dev_priv->num_irqs; ++i) {
38499 - atomic_set(&cur_irq->irq_received, 0);
38500 + atomic_set_unchecked(&cur_irq->irq_received, 0);
38501 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
38502 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
38503 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
38504 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
38505 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
38506 case VIA_IRQ_RELATIVE:
38507 irqwait->request.sequence +=
38508 - atomic_read(&cur_irq->irq_received);
38509 + atomic_read_unchecked(&cur_irq->irq_received);
38510 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
38511 case VIA_IRQ_ABSOLUTE:
38512 break;
38513 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
38514 index 13aeda7..4a952d1 100644
38515 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
38516 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
38517 @@ -290,7 +290,7 @@ struct vmw_private {
38518 * Fencing and IRQs.
38519 */
38520
38521 - atomic_t marker_seq;
38522 + atomic_unchecked_t marker_seq;
38523 wait_queue_head_t fence_queue;
38524 wait_queue_head_t fifo_queue;
38525 int fence_queue_waiters; /* Protected by hw_mutex */
38526 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
38527 index 3eb1486..0a47ee9 100644
38528 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
38529 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
38530 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
38531 (unsigned int) min,
38532 (unsigned int) fifo->capabilities);
38533
38534 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
38535 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
38536 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
38537 vmw_marker_queue_init(&fifo->marker_queue);
38538 return vmw_fifo_send_fence(dev_priv, &dummy);
38539 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
38540 if (reserveable)
38541 iowrite32(bytes, fifo_mem +
38542 SVGA_FIFO_RESERVED);
38543 - return fifo_mem + (next_cmd >> 2);
38544 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
38545 } else {
38546 need_bounce = true;
38547 }
38548 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
38549
38550 fm = vmw_fifo_reserve(dev_priv, bytes);
38551 if (unlikely(fm == NULL)) {
38552 - *seqno = atomic_read(&dev_priv->marker_seq);
38553 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
38554 ret = -ENOMEM;
38555 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
38556 false, 3*HZ);
38557 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
38558 }
38559
38560 do {
38561 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
38562 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
38563 } while (*seqno == 0);
38564
38565 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
38566 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
38567 index c509d40..3b640c3 100644
38568 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
38569 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
38570 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
38571 int ret;
38572
38573 num_clips = arg->num_clips;
38574 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
38575 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
38576
38577 if (unlikely(num_clips == 0))
38578 return 0;
38579 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
38580 int ret;
38581
38582 num_clips = arg->num_clips;
38583 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
38584 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
38585
38586 if (unlikely(num_clips == 0))
38587 return 0;
38588 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
38589 index 4640adb..e1384ed 100644
38590 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
38591 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
38592 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
38593 * emitted. Then the fence is stale and signaled.
38594 */
38595
38596 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
38597 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
38598 > VMW_FENCE_WRAP);
38599
38600 return ret;
38601 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
38602
38603 if (fifo_idle)
38604 down_read(&fifo_state->rwsem);
38605 - signal_seq = atomic_read(&dev_priv->marker_seq);
38606 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
38607 ret = 0;
38608
38609 for (;;) {
38610 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
38611 index 8a8725c2..afed796 100644
38612 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
38613 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
38614 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
38615 while (!vmw_lag_lt(queue, us)) {
38616 spin_lock(&queue->lock);
38617 if (list_empty(&queue->head))
38618 - seqno = atomic_read(&dev_priv->marker_seq);
38619 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
38620 else {
38621 marker = list_first_entry(&queue->head,
38622 struct vmw_marker, head);
38623 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
38624 index 8c04943..4370ed9 100644
38625 --- a/drivers/gpu/host1x/drm/dc.c
38626 +++ b/drivers/gpu/host1x/drm/dc.c
38627 @@ -999,7 +999,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
38628 }
38629
38630 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
38631 - dc->debugfs_files[i].data = dc;
38632 + *(void **)&dc->debugfs_files[i].data = dc;
38633
38634 err = drm_debugfs_create_files(dc->debugfs_files,
38635 ARRAY_SIZE(debugfs_files),
38636 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
38637 index 402f486..f862d7e 100644
38638 --- a/drivers/hid/hid-core.c
38639 +++ b/drivers/hid/hid-core.c
38640 @@ -2275,7 +2275,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
38641
38642 int hid_add_device(struct hid_device *hdev)
38643 {
38644 - static atomic_t id = ATOMIC_INIT(0);
38645 + static atomic_unchecked_t id = ATOMIC_INIT(0);
38646 int ret;
38647
38648 if (WARN_ON(hdev->status & HID_STAT_ADDED))
38649 @@ -2309,7 +2309,7 @@ int hid_add_device(struct hid_device *hdev)
38650 /* XXX hack, any other cleaner solution after the driver core
38651 * is converted to allow more than 20 bytes as the device name? */
38652 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
38653 - hdev->vendor, hdev->product, atomic_inc_return(&id));
38654 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
38655
38656 hid_debug_register(hdev, dev_name(&hdev->dev));
38657 ret = device_add(&hdev->dev);
38658 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
38659 index 90124ff..3761764 100644
38660 --- a/drivers/hid/hid-wiimote-debug.c
38661 +++ b/drivers/hid/hid-wiimote-debug.c
38662 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
38663 else if (size == 0)
38664 return -EIO;
38665
38666 - if (copy_to_user(u, buf, size))
38667 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
38668 return -EFAULT;
38669
38670 *off += size;
38671 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
38672 index 0b122f8..b1d8160 100644
38673 --- a/drivers/hv/channel.c
38674 +++ b/drivers/hv/channel.c
38675 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
38676 int ret = 0;
38677 int t;
38678
38679 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
38680 - atomic_inc(&vmbus_connection.next_gpadl_handle);
38681 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
38682 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
38683
38684 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
38685 if (ret)
38686 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
38687 index ae49237..380d4c9 100644
38688 --- a/drivers/hv/hv.c
38689 +++ b/drivers/hv/hv.c
38690 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
38691 u64 output_address = (output) ? virt_to_phys(output) : 0;
38692 u32 output_address_hi = output_address >> 32;
38693 u32 output_address_lo = output_address & 0xFFFFFFFF;
38694 - void *hypercall_page = hv_context.hypercall_page;
38695 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
38696
38697 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
38698 "=a"(hv_status_lo) : "d" (control_hi),
38699 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
38700 index 12f2f9e..679603c 100644
38701 --- a/drivers/hv/hyperv_vmbus.h
38702 +++ b/drivers/hv/hyperv_vmbus.h
38703 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
38704 struct vmbus_connection {
38705 enum vmbus_connect_state conn_state;
38706
38707 - atomic_t next_gpadl_handle;
38708 + atomic_unchecked_t next_gpadl_handle;
38709
38710 /*
38711 * Represents channel interrupts. Each bit position represents a
38712 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
38713 index 4004e54..c2de226 100644
38714 --- a/drivers/hv/vmbus_drv.c
38715 +++ b/drivers/hv/vmbus_drv.c
38716 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
38717 {
38718 int ret = 0;
38719
38720 - static atomic_t device_num = ATOMIC_INIT(0);
38721 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
38722
38723 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
38724 - atomic_inc_return(&device_num));
38725 + atomic_inc_return_unchecked(&device_num));
38726
38727 child_device_obj->device.bus = &hv_bus;
38728 child_device_obj->device.parent = &hv_acpi_dev->dev;
38729 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
38730 index 6351aba..dc4aaf4 100644
38731 --- a/drivers/hwmon/acpi_power_meter.c
38732 +++ b/drivers/hwmon/acpi_power_meter.c
38733 @@ -117,7 +117,7 @@ struct sensor_template {
38734 struct device_attribute *devattr,
38735 const char *buf, size_t count);
38736 int index;
38737 -};
38738 +} __do_const;
38739
38740 /* Averaging interval */
38741 static int update_avg_interval(struct acpi_power_meter_resource *resource)
38742 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
38743 struct sensor_template *attrs)
38744 {
38745 struct device *dev = &resource->acpi_dev->dev;
38746 - struct sensor_device_attribute *sensors =
38747 + sensor_device_attribute_no_const *sensors =
38748 &resource->sensors[resource->num_sensors];
38749 int res = 0;
38750
38751 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
38752 index 62c2e32..8f2859a 100644
38753 --- a/drivers/hwmon/applesmc.c
38754 +++ b/drivers/hwmon/applesmc.c
38755 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
38756 {
38757 struct applesmc_node_group *grp;
38758 struct applesmc_dev_attr *node;
38759 - struct attribute *attr;
38760 + attribute_no_const *attr;
38761 int ret, i;
38762
38763 for (grp = groups; grp->format; grp++) {
38764 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
38765 index b25c643..a13460d 100644
38766 --- a/drivers/hwmon/asus_atk0110.c
38767 +++ b/drivers/hwmon/asus_atk0110.c
38768 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
38769 struct atk_sensor_data {
38770 struct list_head list;
38771 struct atk_data *data;
38772 - struct device_attribute label_attr;
38773 - struct device_attribute input_attr;
38774 - struct device_attribute limit1_attr;
38775 - struct device_attribute limit2_attr;
38776 + device_attribute_no_const label_attr;
38777 + device_attribute_no_const input_attr;
38778 + device_attribute_no_const limit1_attr;
38779 + device_attribute_no_const limit2_attr;
38780 char label_attr_name[ATTR_NAME_SIZE];
38781 char input_attr_name[ATTR_NAME_SIZE];
38782 char limit1_attr_name[ATTR_NAME_SIZE];
38783 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
38784 static struct device_attribute atk_name_attr =
38785 __ATTR(name, 0444, atk_name_show, NULL);
38786
38787 -static void atk_init_attribute(struct device_attribute *attr, char *name,
38788 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
38789 sysfs_show_func show)
38790 {
38791 sysfs_attr_init(&attr->attr);
38792 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
38793 index 658ce3a..0d0c2f3 100644
38794 --- a/drivers/hwmon/coretemp.c
38795 +++ b/drivers/hwmon/coretemp.c
38796 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
38797 return NOTIFY_OK;
38798 }
38799
38800 -static struct notifier_block coretemp_cpu_notifier __refdata = {
38801 +static struct notifier_block coretemp_cpu_notifier = {
38802 .notifier_call = coretemp_cpu_callback,
38803 };
38804
38805 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
38806 index 1429f6e..ee03d59 100644
38807 --- a/drivers/hwmon/ibmaem.c
38808 +++ b/drivers/hwmon/ibmaem.c
38809 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
38810 struct aem_rw_sensor_template *rw)
38811 {
38812 struct device *dev = &data->pdev->dev;
38813 - struct sensor_device_attribute *sensors = data->sensors;
38814 + sensor_device_attribute_no_const *sensors = data->sensors;
38815 int err;
38816
38817 /* Set up read-only sensors */
38818 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
38819 index 52b77af..aed1ddf 100644
38820 --- a/drivers/hwmon/iio_hwmon.c
38821 +++ b/drivers/hwmon/iio_hwmon.c
38822 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
38823 {
38824 struct device *dev = &pdev->dev;
38825 struct iio_hwmon_state *st;
38826 - struct sensor_device_attribute *a;
38827 + sensor_device_attribute_no_const *a;
38828 int ret, i;
38829 int in_i = 1, temp_i = 1, curr_i = 1;
38830 enum iio_chan_type type;
38831 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
38832 index 9add6092..ee7ba3f 100644
38833 --- a/drivers/hwmon/pmbus/pmbus_core.c
38834 +++ b/drivers/hwmon/pmbus/pmbus_core.c
38835 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
38836 return 0;
38837 }
38838
38839 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
38840 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
38841 const char *name,
38842 umode_t mode,
38843 ssize_t (*show)(struct device *dev,
38844 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
38845 dev_attr->store = store;
38846 }
38847
38848 -static void pmbus_attr_init(struct sensor_device_attribute *a,
38849 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
38850 const char *name,
38851 umode_t mode,
38852 ssize_t (*show)(struct device *dev,
38853 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
38854 u16 reg, u8 mask)
38855 {
38856 struct pmbus_boolean *boolean;
38857 - struct sensor_device_attribute *a;
38858 + sensor_device_attribute_no_const *a;
38859
38860 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
38861 if (!boolean)
38862 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
38863 bool update, bool readonly)
38864 {
38865 struct pmbus_sensor *sensor;
38866 - struct device_attribute *a;
38867 + device_attribute_no_const *a;
38868
38869 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
38870 if (!sensor)
38871 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
38872 const char *lstring, int index)
38873 {
38874 struct pmbus_label *label;
38875 - struct device_attribute *a;
38876 + device_attribute_no_const *a;
38877
38878 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
38879 if (!label)
38880 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
38881 index 2507f90..1645765 100644
38882 --- a/drivers/hwmon/sht15.c
38883 +++ b/drivers/hwmon/sht15.c
38884 @@ -169,7 +169,7 @@ struct sht15_data {
38885 int supply_uv;
38886 bool supply_uv_valid;
38887 struct work_struct update_supply_work;
38888 - atomic_t interrupt_handled;
38889 + atomic_unchecked_t interrupt_handled;
38890 };
38891
38892 /**
38893 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
38894 ret = gpio_direction_input(data->pdata->gpio_data);
38895 if (ret)
38896 return ret;
38897 - atomic_set(&data->interrupt_handled, 0);
38898 + atomic_set_unchecked(&data->interrupt_handled, 0);
38899
38900 enable_irq(gpio_to_irq(data->pdata->gpio_data));
38901 if (gpio_get_value(data->pdata->gpio_data) == 0) {
38902 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
38903 /* Only relevant if the interrupt hasn't occurred. */
38904 - if (!atomic_read(&data->interrupt_handled))
38905 + if (!atomic_read_unchecked(&data->interrupt_handled))
38906 schedule_work(&data->read_work);
38907 }
38908 ret = wait_event_timeout(data->wait_queue,
38909 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
38910
38911 /* First disable the interrupt */
38912 disable_irq_nosync(irq);
38913 - atomic_inc(&data->interrupt_handled);
38914 + atomic_inc_unchecked(&data->interrupt_handled);
38915 /* Then schedule a reading work struct */
38916 if (data->state != SHT15_READING_NOTHING)
38917 schedule_work(&data->read_work);
38918 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
38919 * If not, then start the interrupt again - care here as could
38920 * have gone low in meantime so verify it hasn't!
38921 */
38922 - atomic_set(&data->interrupt_handled, 0);
38923 + atomic_set_unchecked(&data->interrupt_handled, 0);
38924 enable_irq(gpio_to_irq(data->pdata->gpio_data));
38925 /* If still not occurred or another handler was scheduled */
38926 if (gpio_get_value(data->pdata->gpio_data)
38927 - || atomic_read(&data->interrupt_handled))
38928 + || atomic_read_unchecked(&data->interrupt_handled))
38929 return;
38930 }
38931
38932 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
38933 index 76f157b..9c0db1b 100644
38934 --- a/drivers/hwmon/via-cputemp.c
38935 +++ b/drivers/hwmon/via-cputemp.c
38936 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
38937 return NOTIFY_OK;
38938 }
38939
38940 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
38941 +static struct notifier_block via_cputemp_cpu_notifier = {
38942 .notifier_call = via_cputemp_cpu_callback,
38943 };
38944
38945 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
38946 index 07f01ac..d79ad3d 100644
38947 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
38948 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
38949 @@ -43,7 +43,7 @@
38950 extern struct i2c_adapter amd756_smbus;
38951
38952 static struct i2c_adapter *s4882_adapter;
38953 -static struct i2c_algorithm *s4882_algo;
38954 +static i2c_algorithm_no_const *s4882_algo;
38955
38956 /* Wrapper access functions for multiplexed SMBus */
38957 static DEFINE_MUTEX(amd756_lock);
38958 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
38959 index 2ca268d..c6acbdf 100644
38960 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
38961 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
38962 @@ -41,7 +41,7 @@
38963 extern struct i2c_adapter *nforce2_smbus;
38964
38965 static struct i2c_adapter *s4985_adapter;
38966 -static struct i2c_algorithm *s4985_algo;
38967 +static i2c_algorithm_no_const *s4985_algo;
38968
38969 /* Wrapper access functions for multiplexed SMBus */
38970 static DEFINE_MUTEX(nforce2_lock);
38971 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
38972 index c3ccdea..5b3dc1a 100644
38973 --- a/drivers/i2c/i2c-dev.c
38974 +++ b/drivers/i2c/i2c-dev.c
38975 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
38976 break;
38977 }
38978
38979 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
38980 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
38981 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
38982 if (IS_ERR(rdwr_pa[i].buf)) {
38983 res = PTR_ERR(rdwr_pa[i].buf);
38984 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
38985 index 2ff6204..218c16e 100644
38986 --- a/drivers/ide/ide-cd.c
38987 +++ b/drivers/ide/ide-cd.c
38988 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
38989 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
38990 if ((unsigned long)buf & alignment
38991 || blk_rq_bytes(rq) & q->dma_pad_mask
38992 - || object_is_on_stack(buf))
38993 + || object_starts_on_stack(buf))
38994 drive->dma = 0;
38995 }
38996 }
38997 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
38998 index e145931..08bfc59 100644
38999 --- a/drivers/iio/industrialio-core.c
39000 +++ b/drivers/iio/industrialio-core.c
39001 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
39002 }
39003
39004 static
39005 -int __iio_device_attr_init(struct device_attribute *dev_attr,
39006 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
39007 const char *postfix,
39008 struct iio_chan_spec const *chan,
39009 ssize_t (*readfunc)(struct device *dev,
39010 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
39011 index 784b97c..c9ceadf 100644
39012 --- a/drivers/infiniband/core/cm.c
39013 +++ b/drivers/infiniband/core/cm.c
39014 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
39015
39016 struct cm_counter_group {
39017 struct kobject obj;
39018 - atomic_long_t counter[CM_ATTR_COUNT];
39019 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
39020 };
39021
39022 struct cm_counter_attribute {
39023 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
39024 struct ib_mad_send_buf *msg = NULL;
39025 int ret;
39026
39027 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39028 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39029 counter[CM_REQ_COUNTER]);
39030
39031 /* Quick state check to discard duplicate REQs. */
39032 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
39033 if (!cm_id_priv)
39034 return;
39035
39036 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39037 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39038 counter[CM_REP_COUNTER]);
39039 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
39040 if (ret)
39041 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
39042 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
39043 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
39044 spin_unlock_irq(&cm_id_priv->lock);
39045 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39046 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39047 counter[CM_RTU_COUNTER]);
39048 goto out;
39049 }
39050 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
39051 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
39052 dreq_msg->local_comm_id);
39053 if (!cm_id_priv) {
39054 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39055 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39056 counter[CM_DREQ_COUNTER]);
39057 cm_issue_drep(work->port, work->mad_recv_wc);
39058 return -EINVAL;
39059 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
39060 case IB_CM_MRA_REP_RCVD:
39061 break;
39062 case IB_CM_TIMEWAIT:
39063 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39064 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39065 counter[CM_DREQ_COUNTER]);
39066 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39067 goto unlock;
39068 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
39069 cm_free_msg(msg);
39070 goto deref;
39071 case IB_CM_DREQ_RCVD:
39072 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39073 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39074 counter[CM_DREQ_COUNTER]);
39075 goto unlock;
39076 default:
39077 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
39078 ib_modify_mad(cm_id_priv->av.port->mad_agent,
39079 cm_id_priv->msg, timeout)) {
39080 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
39081 - atomic_long_inc(&work->port->
39082 + atomic_long_inc_unchecked(&work->port->
39083 counter_group[CM_RECV_DUPLICATES].
39084 counter[CM_MRA_COUNTER]);
39085 goto out;
39086 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
39087 break;
39088 case IB_CM_MRA_REQ_RCVD:
39089 case IB_CM_MRA_REP_RCVD:
39090 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39091 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39092 counter[CM_MRA_COUNTER]);
39093 /* fall through */
39094 default:
39095 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
39096 case IB_CM_LAP_IDLE:
39097 break;
39098 case IB_CM_MRA_LAP_SENT:
39099 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39100 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39101 counter[CM_LAP_COUNTER]);
39102 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
39103 goto unlock;
39104 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
39105 cm_free_msg(msg);
39106 goto deref;
39107 case IB_CM_LAP_RCVD:
39108 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39109 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39110 counter[CM_LAP_COUNTER]);
39111 goto unlock;
39112 default:
39113 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
39114 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
39115 if (cur_cm_id_priv) {
39116 spin_unlock_irq(&cm.lock);
39117 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39118 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39119 counter[CM_SIDR_REQ_COUNTER]);
39120 goto out; /* Duplicate message. */
39121 }
39122 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
39123 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
39124 msg->retries = 1;
39125
39126 - atomic_long_add(1 + msg->retries,
39127 + atomic_long_add_unchecked(1 + msg->retries,
39128 &port->counter_group[CM_XMIT].counter[attr_index]);
39129 if (msg->retries)
39130 - atomic_long_add(msg->retries,
39131 + atomic_long_add_unchecked(msg->retries,
39132 &port->counter_group[CM_XMIT_RETRIES].
39133 counter[attr_index]);
39134
39135 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
39136 }
39137
39138 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
39139 - atomic_long_inc(&port->counter_group[CM_RECV].
39140 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
39141 counter[attr_id - CM_ATTR_ID_OFFSET]);
39142
39143 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
39144 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
39145 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
39146
39147 return sprintf(buf, "%ld\n",
39148 - atomic_long_read(&group->counter[cm_attr->index]));
39149 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
39150 }
39151
39152 static const struct sysfs_ops cm_counter_ops = {
39153 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
39154 index 9f5ad7c..588cd84 100644
39155 --- a/drivers/infiniband/core/fmr_pool.c
39156 +++ b/drivers/infiniband/core/fmr_pool.c
39157 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
39158
39159 struct task_struct *thread;
39160
39161 - atomic_t req_ser;
39162 - atomic_t flush_ser;
39163 + atomic_unchecked_t req_ser;
39164 + atomic_unchecked_t flush_ser;
39165
39166 wait_queue_head_t force_wait;
39167 };
39168 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
39169 struct ib_fmr_pool *pool = pool_ptr;
39170
39171 do {
39172 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
39173 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
39174 ib_fmr_batch_release(pool);
39175
39176 - atomic_inc(&pool->flush_ser);
39177 + atomic_inc_unchecked(&pool->flush_ser);
39178 wake_up_interruptible(&pool->force_wait);
39179
39180 if (pool->flush_function)
39181 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
39182 }
39183
39184 set_current_state(TASK_INTERRUPTIBLE);
39185 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
39186 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
39187 !kthread_should_stop())
39188 schedule();
39189 __set_current_state(TASK_RUNNING);
39190 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
39191 pool->dirty_watermark = params->dirty_watermark;
39192 pool->dirty_len = 0;
39193 spin_lock_init(&pool->pool_lock);
39194 - atomic_set(&pool->req_ser, 0);
39195 - atomic_set(&pool->flush_ser, 0);
39196 + atomic_set_unchecked(&pool->req_ser, 0);
39197 + atomic_set_unchecked(&pool->flush_ser, 0);
39198 init_waitqueue_head(&pool->force_wait);
39199
39200 pool->thread = kthread_run(ib_fmr_cleanup_thread,
39201 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
39202 }
39203 spin_unlock_irq(&pool->pool_lock);
39204
39205 - serial = atomic_inc_return(&pool->req_ser);
39206 + serial = atomic_inc_return_unchecked(&pool->req_ser);
39207 wake_up_process(pool->thread);
39208
39209 if (wait_event_interruptible(pool->force_wait,
39210 - atomic_read(&pool->flush_ser) - serial >= 0))
39211 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
39212 return -EINTR;
39213
39214 return 0;
39215 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
39216 } else {
39217 list_add_tail(&fmr->list, &pool->dirty_list);
39218 if (++pool->dirty_len >= pool->dirty_watermark) {
39219 - atomic_inc(&pool->req_ser);
39220 + atomic_inc_unchecked(&pool->req_ser);
39221 wake_up_process(pool->thread);
39222 }
39223 }
39224 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
39225 index 4cb8eb2..146bf60 100644
39226 --- a/drivers/infiniband/hw/cxgb4/mem.c
39227 +++ b/drivers/infiniband/hw/cxgb4/mem.c
39228 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
39229 int err;
39230 struct fw_ri_tpte tpt;
39231 u32 stag_idx;
39232 - static atomic_t key;
39233 + static atomic_unchecked_t key;
39234
39235 if (c4iw_fatal_error(rdev))
39236 return -EIO;
39237 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
39238 if (rdev->stats.stag.cur > rdev->stats.stag.max)
39239 rdev->stats.stag.max = rdev->stats.stag.cur;
39240 mutex_unlock(&rdev->stats.lock);
39241 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
39242 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
39243 }
39244 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
39245 __func__, stag_state, type, pdid, stag_idx);
39246 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
39247 index 79b3dbc..96e5fcc 100644
39248 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
39249 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
39250 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
39251 struct ib_atomic_eth *ateth;
39252 struct ipath_ack_entry *e;
39253 u64 vaddr;
39254 - atomic64_t *maddr;
39255 + atomic64_unchecked_t *maddr;
39256 u64 sdata;
39257 u32 rkey;
39258 u8 next;
39259 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
39260 IB_ACCESS_REMOTE_ATOMIC)))
39261 goto nack_acc_unlck;
39262 /* Perform atomic OP and save result. */
39263 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
39264 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
39265 sdata = be64_to_cpu(ateth->swap_data);
39266 e = &qp->s_ack_queue[qp->r_head_ack_queue];
39267 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
39268 - (u64) atomic64_add_return(sdata, maddr) - sdata :
39269 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
39270 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
39271 be64_to_cpu(ateth->compare_data),
39272 sdata);
39273 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
39274 index 1f95bba..9530f87 100644
39275 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
39276 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
39277 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
39278 unsigned long flags;
39279 struct ib_wc wc;
39280 u64 sdata;
39281 - atomic64_t *maddr;
39282 + atomic64_unchecked_t *maddr;
39283 enum ib_wc_status send_status;
39284
39285 /*
39286 @@ -382,11 +382,11 @@ again:
39287 IB_ACCESS_REMOTE_ATOMIC)))
39288 goto acc_err;
39289 /* Perform atomic OP and save result. */
39290 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
39291 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
39292 sdata = wqe->wr.wr.atomic.compare_add;
39293 *(u64 *) sqp->s_sge.sge.vaddr =
39294 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
39295 - (u64) atomic64_add_return(sdata, maddr) - sdata :
39296 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
39297 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
39298 sdata, wqe->wr.wr.atomic.swap);
39299 goto send_comp;
39300 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
39301 index 9d3e5c1..d9afe4a 100644
39302 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
39303 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
39304 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
39305 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
39306 }
39307
39308 -int mthca_QUERY_FW(struct mthca_dev *dev)
39309 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
39310 {
39311 struct mthca_mailbox *mailbox;
39312 u32 *outbox;
39313 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
39314 index ed9a989..e0c5871 100644
39315 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
39316 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
39317 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
39318 return key;
39319 }
39320
39321 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
39322 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
39323 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
39324 {
39325 struct mthca_mailbox *mailbox;
39326 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
39327 index 4291410..d2ab1fb 100644
39328 --- a/drivers/infiniband/hw/nes/nes.c
39329 +++ b/drivers/infiniband/hw/nes/nes.c
39330 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
39331 LIST_HEAD(nes_adapter_list);
39332 static LIST_HEAD(nes_dev_list);
39333
39334 -atomic_t qps_destroyed;
39335 +atomic_unchecked_t qps_destroyed;
39336
39337 static unsigned int ee_flsh_adapter;
39338 static unsigned int sysfs_nonidx_addr;
39339 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
39340 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
39341 struct nes_adapter *nesadapter = nesdev->nesadapter;
39342
39343 - atomic_inc(&qps_destroyed);
39344 + atomic_inc_unchecked(&qps_destroyed);
39345
39346 /* Free the control structures */
39347
39348 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
39349 index 33cc589..3bd6538 100644
39350 --- a/drivers/infiniband/hw/nes/nes.h
39351 +++ b/drivers/infiniband/hw/nes/nes.h
39352 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
39353 extern unsigned int wqm_quanta;
39354 extern struct list_head nes_adapter_list;
39355
39356 -extern atomic_t cm_connects;
39357 -extern atomic_t cm_accepts;
39358 -extern atomic_t cm_disconnects;
39359 -extern atomic_t cm_closes;
39360 -extern atomic_t cm_connecteds;
39361 -extern atomic_t cm_connect_reqs;
39362 -extern atomic_t cm_rejects;
39363 -extern atomic_t mod_qp_timouts;
39364 -extern atomic_t qps_created;
39365 -extern atomic_t qps_destroyed;
39366 -extern atomic_t sw_qps_destroyed;
39367 +extern atomic_unchecked_t cm_connects;
39368 +extern atomic_unchecked_t cm_accepts;
39369 +extern atomic_unchecked_t cm_disconnects;
39370 +extern atomic_unchecked_t cm_closes;
39371 +extern atomic_unchecked_t cm_connecteds;
39372 +extern atomic_unchecked_t cm_connect_reqs;
39373 +extern atomic_unchecked_t cm_rejects;
39374 +extern atomic_unchecked_t mod_qp_timouts;
39375 +extern atomic_unchecked_t qps_created;
39376 +extern atomic_unchecked_t qps_destroyed;
39377 +extern atomic_unchecked_t sw_qps_destroyed;
39378 extern u32 mh_detected;
39379 extern u32 mh_pauses_sent;
39380 extern u32 cm_packets_sent;
39381 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
39382 extern u32 cm_packets_received;
39383 extern u32 cm_packets_dropped;
39384 extern u32 cm_packets_retrans;
39385 -extern atomic_t cm_listens_created;
39386 -extern atomic_t cm_listens_destroyed;
39387 +extern atomic_unchecked_t cm_listens_created;
39388 +extern atomic_unchecked_t cm_listens_destroyed;
39389 extern u32 cm_backlog_drops;
39390 -extern atomic_t cm_loopbacks;
39391 -extern atomic_t cm_nodes_created;
39392 -extern atomic_t cm_nodes_destroyed;
39393 -extern atomic_t cm_accel_dropped_pkts;
39394 -extern atomic_t cm_resets_recvd;
39395 -extern atomic_t pau_qps_created;
39396 -extern atomic_t pau_qps_destroyed;
39397 +extern atomic_unchecked_t cm_loopbacks;
39398 +extern atomic_unchecked_t cm_nodes_created;
39399 +extern atomic_unchecked_t cm_nodes_destroyed;
39400 +extern atomic_unchecked_t cm_accel_dropped_pkts;
39401 +extern atomic_unchecked_t cm_resets_recvd;
39402 +extern atomic_unchecked_t pau_qps_created;
39403 +extern atomic_unchecked_t pau_qps_destroyed;
39404
39405 extern u32 int_mod_timer_init;
39406 extern u32 int_mod_cq_depth_256;
39407 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
39408 index 24b9f1a..00fd004 100644
39409 --- a/drivers/infiniband/hw/nes/nes_cm.c
39410 +++ b/drivers/infiniband/hw/nes/nes_cm.c
39411 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
39412 u32 cm_packets_retrans;
39413 u32 cm_packets_created;
39414 u32 cm_packets_received;
39415 -atomic_t cm_listens_created;
39416 -atomic_t cm_listens_destroyed;
39417 +atomic_unchecked_t cm_listens_created;
39418 +atomic_unchecked_t cm_listens_destroyed;
39419 u32 cm_backlog_drops;
39420 -atomic_t cm_loopbacks;
39421 -atomic_t cm_nodes_created;
39422 -atomic_t cm_nodes_destroyed;
39423 -atomic_t cm_accel_dropped_pkts;
39424 -atomic_t cm_resets_recvd;
39425 +atomic_unchecked_t cm_loopbacks;
39426 +atomic_unchecked_t cm_nodes_created;
39427 +atomic_unchecked_t cm_nodes_destroyed;
39428 +atomic_unchecked_t cm_accel_dropped_pkts;
39429 +atomic_unchecked_t cm_resets_recvd;
39430
39431 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
39432 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
39433 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
39434
39435 static struct nes_cm_core *g_cm_core;
39436
39437 -atomic_t cm_connects;
39438 -atomic_t cm_accepts;
39439 -atomic_t cm_disconnects;
39440 -atomic_t cm_closes;
39441 -atomic_t cm_connecteds;
39442 -atomic_t cm_connect_reqs;
39443 -atomic_t cm_rejects;
39444 +atomic_unchecked_t cm_connects;
39445 +atomic_unchecked_t cm_accepts;
39446 +atomic_unchecked_t cm_disconnects;
39447 +atomic_unchecked_t cm_closes;
39448 +atomic_unchecked_t cm_connecteds;
39449 +atomic_unchecked_t cm_connect_reqs;
39450 +atomic_unchecked_t cm_rejects;
39451
39452 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
39453 {
39454 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
39455 kfree(listener);
39456 listener = NULL;
39457 ret = 0;
39458 - atomic_inc(&cm_listens_destroyed);
39459 + atomic_inc_unchecked(&cm_listens_destroyed);
39460 } else {
39461 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
39462 }
39463 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
39464 cm_node->rem_mac);
39465
39466 add_hte_node(cm_core, cm_node);
39467 - atomic_inc(&cm_nodes_created);
39468 + atomic_inc_unchecked(&cm_nodes_created);
39469
39470 return cm_node;
39471 }
39472 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
39473 }
39474
39475 atomic_dec(&cm_core->node_cnt);
39476 - atomic_inc(&cm_nodes_destroyed);
39477 + atomic_inc_unchecked(&cm_nodes_destroyed);
39478 nesqp = cm_node->nesqp;
39479 if (nesqp) {
39480 nesqp->cm_node = NULL;
39481 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
39482
39483 static void drop_packet(struct sk_buff *skb)
39484 {
39485 - atomic_inc(&cm_accel_dropped_pkts);
39486 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
39487 dev_kfree_skb_any(skb);
39488 }
39489
39490 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
39491 {
39492
39493 int reset = 0; /* whether to send reset in case of err.. */
39494 - atomic_inc(&cm_resets_recvd);
39495 + atomic_inc_unchecked(&cm_resets_recvd);
39496 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
39497 " refcnt=%d\n", cm_node, cm_node->state,
39498 atomic_read(&cm_node->ref_count));
39499 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
39500 rem_ref_cm_node(cm_node->cm_core, cm_node);
39501 return NULL;
39502 }
39503 - atomic_inc(&cm_loopbacks);
39504 + atomic_inc_unchecked(&cm_loopbacks);
39505 loopbackremotenode->loopbackpartner = cm_node;
39506 loopbackremotenode->tcp_cntxt.rcv_wscale =
39507 NES_CM_DEFAULT_RCV_WND_SCALE;
39508 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
39509 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
39510 else {
39511 rem_ref_cm_node(cm_core, cm_node);
39512 - atomic_inc(&cm_accel_dropped_pkts);
39513 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
39514 dev_kfree_skb_any(skb);
39515 }
39516 break;
39517 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
39518
39519 if ((cm_id) && (cm_id->event_handler)) {
39520 if (issue_disconn) {
39521 - atomic_inc(&cm_disconnects);
39522 + atomic_inc_unchecked(&cm_disconnects);
39523 cm_event.event = IW_CM_EVENT_DISCONNECT;
39524 cm_event.status = disconn_status;
39525 cm_event.local_addr = cm_id->local_addr;
39526 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
39527 }
39528
39529 if (issue_close) {
39530 - atomic_inc(&cm_closes);
39531 + atomic_inc_unchecked(&cm_closes);
39532 nes_disconnect(nesqp, 1);
39533
39534 cm_id->provider_data = nesqp;
39535 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
39536
39537 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
39538 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
39539 - atomic_inc(&cm_accepts);
39540 + atomic_inc_unchecked(&cm_accepts);
39541
39542 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
39543 netdev_refcnt_read(nesvnic->netdev));
39544 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
39545 struct nes_cm_core *cm_core;
39546 u8 *start_buff;
39547
39548 - atomic_inc(&cm_rejects);
39549 + atomic_inc_unchecked(&cm_rejects);
39550 cm_node = (struct nes_cm_node *)cm_id->provider_data;
39551 loopback = cm_node->loopbackpartner;
39552 cm_core = cm_node->cm_core;
39553 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
39554 ntohl(cm_id->local_addr.sin_addr.s_addr),
39555 ntohs(cm_id->local_addr.sin_port));
39556
39557 - atomic_inc(&cm_connects);
39558 + atomic_inc_unchecked(&cm_connects);
39559 nesqp->active_conn = 1;
39560
39561 /* cache the cm_id in the qp */
39562 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
39563 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
39564 return err;
39565 }
39566 - atomic_inc(&cm_listens_created);
39567 + atomic_inc_unchecked(&cm_listens_created);
39568 }
39569
39570 cm_id->add_ref(cm_id);
39571 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
39572
39573 if (nesqp->destroyed)
39574 return;
39575 - atomic_inc(&cm_connecteds);
39576 + atomic_inc_unchecked(&cm_connecteds);
39577 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
39578 " local port 0x%04X. jiffies = %lu.\n",
39579 nesqp->hwqp.qp_id,
39580 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
39581
39582 cm_id->add_ref(cm_id);
39583 ret = cm_id->event_handler(cm_id, &cm_event);
39584 - atomic_inc(&cm_closes);
39585 + atomic_inc_unchecked(&cm_closes);
39586 cm_event.event = IW_CM_EVENT_CLOSE;
39587 cm_event.status = 0;
39588 cm_event.provider_data = cm_id->provider_data;
39589 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
39590 return;
39591 cm_id = cm_node->cm_id;
39592
39593 - atomic_inc(&cm_connect_reqs);
39594 + atomic_inc_unchecked(&cm_connect_reqs);
39595 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
39596 cm_node, cm_id, jiffies);
39597
39598 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
39599 return;
39600 cm_id = cm_node->cm_id;
39601
39602 - atomic_inc(&cm_connect_reqs);
39603 + atomic_inc_unchecked(&cm_connect_reqs);
39604 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
39605 cm_node, cm_id, jiffies);
39606
39607 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
39608 index 4166452..fc952c3 100644
39609 --- a/drivers/infiniband/hw/nes/nes_mgt.c
39610 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
39611 @@ -40,8 +40,8 @@
39612 #include "nes.h"
39613 #include "nes_mgt.h"
39614
39615 -atomic_t pau_qps_created;
39616 -atomic_t pau_qps_destroyed;
39617 +atomic_unchecked_t pau_qps_created;
39618 +atomic_unchecked_t pau_qps_destroyed;
39619
39620 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
39621 {
39622 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
39623 {
39624 struct sk_buff *skb;
39625 unsigned long flags;
39626 - atomic_inc(&pau_qps_destroyed);
39627 + atomic_inc_unchecked(&pau_qps_destroyed);
39628
39629 /* Free packets that have not yet been forwarded */
39630 /* Lock is acquired by skb_dequeue when removing the skb */
39631 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
39632 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
39633 skb_queue_head_init(&nesqp->pau_list);
39634 spin_lock_init(&nesqp->pau_lock);
39635 - atomic_inc(&pau_qps_created);
39636 + atomic_inc_unchecked(&pau_qps_created);
39637 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
39638 }
39639
39640 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
39641 index 49eb511..a774366 100644
39642 --- a/drivers/infiniband/hw/nes/nes_nic.c
39643 +++ b/drivers/infiniband/hw/nes/nes_nic.c
39644 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
39645 target_stat_values[++index] = mh_detected;
39646 target_stat_values[++index] = mh_pauses_sent;
39647 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
39648 - target_stat_values[++index] = atomic_read(&cm_connects);
39649 - target_stat_values[++index] = atomic_read(&cm_accepts);
39650 - target_stat_values[++index] = atomic_read(&cm_disconnects);
39651 - target_stat_values[++index] = atomic_read(&cm_connecteds);
39652 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
39653 - target_stat_values[++index] = atomic_read(&cm_rejects);
39654 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
39655 - target_stat_values[++index] = atomic_read(&qps_created);
39656 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
39657 - target_stat_values[++index] = atomic_read(&qps_destroyed);
39658 - target_stat_values[++index] = atomic_read(&cm_closes);
39659 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
39660 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
39661 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
39662 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
39663 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
39664 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
39665 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
39666 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
39667 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
39668 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
39669 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
39670 target_stat_values[++index] = cm_packets_sent;
39671 target_stat_values[++index] = cm_packets_bounced;
39672 target_stat_values[++index] = cm_packets_created;
39673 target_stat_values[++index] = cm_packets_received;
39674 target_stat_values[++index] = cm_packets_dropped;
39675 target_stat_values[++index] = cm_packets_retrans;
39676 - target_stat_values[++index] = atomic_read(&cm_listens_created);
39677 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
39678 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
39679 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
39680 target_stat_values[++index] = cm_backlog_drops;
39681 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
39682 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
39683 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
39684 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
39685 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
39686 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
39687 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
39688 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
39689 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
39690 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
39691 target_stat_values[++index] = nesadapter->free_4kpbl;
39692 target_stat_values[++index] = nesadapter->free_256pbl;
39693 target_stat_values[++index] = int_mod_timer_init;
39694 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
39695 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
39696 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
39697 - target_stat_values[++index] = atomic_read(&pau_qps_created);
39698 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
39699 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
39700 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
39701 }
39702
39703 /**
39704 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
39705 index 8f67fe2..8960859 100644
39706 --- a/drivers/infiniband/hw/nes/nes_verbs.c
39707 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
39708 @@ -46,9 +46,9 @@
39709
39710 #include <rdma/ib_umem.h>
39711
39712 -atomic_t mod_qp_timouts;
39713 -atomic_t qps_created;
39714 -atomic_t sw_qps_destroyed;
39715 +atomic_unchecked_t mod_qp_timouts;
39716 +atomic_unchecked_t qps_created;
39717 +atomic_unchecked_t sw_qps_destroyed;
39718
39719 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
39720
39721 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
39722 if (init_attr->create_flags)
39723 return ERR_PTR(-EINVAL);
39724
39725 - atomic_inc(&qps_created);
39726 + atomic_inc_unchecked(&qps_created);
39727 switch (init_attr->qp_type) {
39728 case IB_QPT_RC:
39729 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
39730 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
39731 struct iw_cm_event cm_event;
39732 int ret = 0;
39733
39734 - atomic_inc(&sw_qps_destroyed);
39735 + atomic_inc_unchecked(&sw_qps_destroyed);
39736 nesqp->destroyed = 1;
39737
39738 /* Blow away the connection if it exists. */
39739 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
39740 index 4d11575..3e890e5 100644
39741 --- a/drivers/infiniband/hw/qib/qib.h
39742 +++ b/drivers/infiniband/hw/qib/qib.h
39743 @@ -51,6 +51,7 @@
39744 #include <linux/completion.h>
39745 #include <linux/kref.h>
39746 #include <linux/sched.h>
39747 +#include <linux/slab.h>
39748
39749 #include "qib_common.h"
39750 #include "qib_verbs.h"
39751 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
39752 index da739d9..da1c7f4 100644
39753 --- a/drivers/input/gameport/gameport.c
39754 +++ b/drivers/input/gameport/gameport.c
39755 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
39756 */
39757 static void gameport_init_port(struct gameport *gameport)
39758 {
39759 - static atomic_t gameport_no = ATOMIC_INIT(0);
39760 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
39761
39762 __module_get(THIS_MODULE);
39763
39764 mutex_init(&gameport->drv_mutex);
39765 device_initialize(&gameport->dev);
39766 dev_set_name(&gameport->dev, "gameport%lu",
39767 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
39768 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
39769 gameport->dev.bus = &gameport_bus;
39770 gameport->dev.release = gameport_release_port;
39771 if (gameport->parent)
39772 diff --git a/drivers/input/input.c b/drivers/input/input.c
39773 index c044699..174d71a 100644
39774 --- a/drivers/input/input.c
39775 +++ b/drivers/input/input.c
39776 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
39777 */
39778 int input_register_device(struct input_dev *dev)
39779 {
39780 - static atomic_t input_no = ATOMIC_INIT(0);
39781 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
39782 struct input_devres *devres = NULL;
39783 struct input_handler *handler;
39784 unsigned int packet_size;
39785 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
39786 dev->setkeycode = input_default_setkeycode;
39787
39788 dev_set_name(&dev->dev, "input%ld",
39789 - (unsigned long) atomic_inc_return(&input_no) - 1);
39790 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
39791
39792 error = device_add(&dev->dev);
39793 if (error)
39794 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
39795 index 04c69af..5f92d00 100644
39796 --- a/drivers/input/joystick/sidewinder.c
39797 +++ b/drivers/input/joystick/sidewinder.c
39798 @@ -30,6 +30,7 @@
39799 #include <linux/kernel.h>
39800 #include <linux/module.h>
39801 #include <linux/slab.h>
39802 +#include <linux/sched.h>
39803 #include <linux/init.h>
39804 #include <linux/input.h>
39805 #include <linux/gameport.h>
39806 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
39807 index fa061d4..4a6957c 100644
39808 --- a/drivers/input/joystick/xpad.c
39809 +++ b/drivers/input/joystick/xpad.c
39810 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
39811
39812 static int xpad_led_probe(struct usb_xpad *xpad)
39813 {
39814 - static atomic_t led_seq = ATOMIC_INIT(0);
39815 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
39816 long led_no;
39817 struct xpad_led *led;
39818 struct led_classdev *led_cdev;
39819 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
39820 if (!led)
39821 return -ENOMEM;
39822
39823 - led_no = (long)atomic_inc_return(&led_seq) - 1;
39824 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
39825
39826 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
39827 led->xpad = xpad;
39828 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
39829 index 2f0b39d..7370f13 100644
39830 --- a/drivers/input/mouse/psmouse.h
39831 +++ b/drivers/input/mouse/psmouse.h
39832 @@ -116,7 +116,7 @@ struct psmouse_attribute {
39833 ssize_t (*set)(struct psmouse *psmouse, void *data,
39834 const char *buf, size_t count);
39835 bool protect;
39836 -};
39837 +} __do_const;
39838 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
39839
39840 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
39841 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
39842 index 4c842c3..590b0bf 100644
39843 --- a/drivers/input/mousedev.c
39844 +++ b/drivers/input/mousedev.c
39845 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
39846
39847 spin_unlock_irq(&client->packet_lock);
39848
39849 - if (copy_to_user(buffer, data, count))
39850 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
39851 return -EFAULT;
39852
39853 return count;
39854 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
39855 index 25fc597..558bf3b3 100644
39856 --- a/drivers/input/serio/serio.c
39857 +++ b/drivers/input/serio/serio.c
39858 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
39859 */
39860 static void serio_init_port(struct serio *serio)
39861 {
39862 - static atomic_t serio_no = ATOMIC_INIT(0);
39863 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
39864
39865 __module_get(THIS_MODULE);
39866
39867 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
39868 mutex_init(&serio->drv_mutex);
39869 device_initialize(&serio->dev);
39870 dev_set_name(&serio->dev, "serio%ld",
39871 - (long)atomic_inc_return(&serio_no) - 1);
39872 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
39873 serio->dev.bus = &serio_bus;
39874 serio->dev.release = serio_release_port;
39875 serio->dev.groups = serio_device_attr_groups;
39876 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
39877 index d8f98b1..f62a640 100644
39878 --- a/drivers/iommu/iommu.c
39879 +++ b/drivers/iommu/iommu.c
39880 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
39881 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
39882 {
39883 bus_register_notifier(bus, &iommu_bus_nb);
39884 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
39885 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
39886 }
39887
39888 /**
39889 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
39890 index dcfea4e..f4226b2 100644
39891 --- a/drivers/iommu/irq_remapping.c
39892 +++ b/drivers/iommu/irq_remapping.c
39893 @@ -354,7 +354,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
39894 void panic_if_irq_remap(const char *msg)
39895 {
39896 if (irq_remapping_enabled)
39897 - panic(msg);
39898 + panic("%s", msg);
39899 }
39900
39901 static void ir_ack_apic_edge(struct irq_data *data)
39902 @@ -375,10 +375,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
39903
39904 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
39905 {
39906 - chip->irq_print_chip = ir_print_prefix;
39907 - chip->irq_ack = ir_ack_apic_edge;
39908 - chip->irq_eoi = ir_ack_apic_level;
39909 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
39910 + pax_open_kernel();
39911 + *(void **)&chip->irq_print_chip = ir_print_prefix;
39912 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
39913 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
39914 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
39915 + pax_close_kernel();
39916 }
39917
39918 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
39919 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
39920 index 19ceaa6..3625818 100644
39921 --- a/drivers/irqchip/irq-gic.c
39922 +++ b/drivers/irqchip/irq-gic.c
39923 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
39924 * Supported arch specific GIC irq extension.
39925 * Default make them NULL.
39926 */
39927 -struct irq_chip gic_arch_extn = {
39928 +irq_chip_no_const gic_arch_extn = {
39929 .irq_eoi = NULL,
39930 .irq_mask = NULL,
39931 .irq_unmask = NULL,
39932 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
39933 chained_irq_exit(chip, desc);
39934 }
39935
39936 -static struct irq_chip gic_chip = {
39937 +static irq_chip_no_const gic_chip __read_only = {
39938 .name = "GIC",
39939 .irq_mask = gic_mask_irq,
39940 .irq_unmask = gic_unmask_irq,
39941 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
39942 index ac6f72b..81150f2 100644
39943 --- a/drivers/isdn/capi/capi.c
39944 +++ b/drivers/isdn/capi/capi.c
39945 @@ -81,8 +81,8 @@ struct capiminor {
39946
39947 struct capi20_appl *ap;
39948 u32 ncci;
39949 - atomic_t datahandle;
39950 - atomic_t msgid;
39951 + atomic_unchecked_t datahandle;
39952 + atomic_unchecked_t msgid;
39953
39954 struct tty_port port;
39955 int ttyinstop;
39956 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
39957 capimsg_setu16(s, 2, mp->ap->applid);
39958 capimsg_setu8 (s, 4, CAPI_DATA_B3);
39959 capimsg_setu8 (s, 5, CAPI_RESP);
39960 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
39961 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
39962 capimsg_setu32(s, 8, mp->ncci);
39963 capimsg_setu16(s, 12, datahandle);
39964 }
39965 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
39966 mp->outbytes -= len;
39967 spin_unlock_bh(&mp->outlock);
39968
39969 - datahandle = atomic_inc_return(&mp->datahandle);
39970 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
39971 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
39972 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
39973 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
39974 capimsg_setu16(skb->data, 2, mp->ap->applid);
39975 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
39976 capimsg_setu8 (skb->data, 5, CAPI_REQ);
39977 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
39978 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
39979 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
39980 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
39981 capimsg_setu16(skb->data, 16, len); /* Data length */
39982 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
39983 index 600c79b..3752bab 100644
39984 --- a/drivers/isdn/gigaset/interface.c
39985 +++ b/drivers/isdn/gigaset/interface.c
39986 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
39987 }
39988 tty->driver_data = cs;
39989
39990 - ++cs->port.count;
39991 + atomic_inc(&cs->port.count);
39992
39993 - if (cs->port.count == 1) {
39994 + if (atomic_read(&cs->port.count) == 1) {
39995 tty_port_tty_set(&cs->port, tty);
39996 cs->port.low_latency = 1;
39997 }
39998 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
39999
40000 if (!cs->connected)
40001 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
40002 - else if (!cs->port.count)
40003 + else if (!atomic_read(&cs->port.count))
40004 dev_warn(cs->dev, "%s: device not opened\n", __func__);
40005 - else if (!--cs->port.count)
40006 + else if (!atomic_dec_return(&cs->port.count))
40007 tty_port_tty_set(&cs->port, NULL);
40008
40009 mutex_unlock(&cs->mutex);
40010 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
40011 index 4d9b195..455075c 100644
40012 --- a/drivers/isdn/hardware/avm/b1.c
40013 +++ b/drivers/isdn/hardware/avm/b1.c
40014 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
40015 }
40016 if (left) {
40017 if (t4file->user) {
40018 - if (copy_from_user(buf, dp, left))
40019 + if (left > sizeof buf || copy_from_user(buf, dp, left))
40020 return -EFAULT;
40021 } else {
40022 memcpy(buf, dp, left);
40023 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
40024 }
40025 if (left) {
40026 if (config->user) {
40027 - if (copy_from_user(buf, dp, left))
40028 + if (left > sizeof buf || copy_from_user(buf, dp, left))
40029 return -EFAULT;
40030 } else {
40031 memcpy(buf, dp, left);
40032 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
40033 index 3c5f249..5fac4d0 100644
40034 --- a/drivers/isdn/i4l/isdn_tty.c
40035 +++ b/drivers/isdn/i4l/isdn_tty.c
40036 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
40037
40038 #ifdef ISDN_DEBUG_MODEM_OPEN
40039 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
40040 - port->count);
40041 + atomic_read(&port->count));
40042 #endif
40043 - port->count++;
40044 + atomic_inc(&port->count);
40045 port->tty = tty;
40046 /*
40047 * Start up serial port
40048 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
40049 #endif
40050 return;
40051 }
40052 - if ((tty->count == 1) && (port->count != 1)) {
40053 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
40054 /*
40055 * Uh, oh. tty->count is 1, which means that the tty
40056 * structure will be freed. Info->count should always
40057 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
40058 * serial port won't be shutdown.
40059 */
40060 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
40061 - "info->count is %d\n", port->count);
40062 - port->count = 1;
40063 + "info->count is %d\n", atomic_read(&port->count));
40064 + atomic_set(&port->count, 1);
40065 }
40066 - if (--port->count < 0) {
40067 + if (atomic_dec_return(&port->count) < 0) {
40068 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
40069 - info->line, port->count);
40070 - port->count = 0;
40071 + info->line, atomic_read(&port->count));
40072 + atomic_set(&port->count, 0);
40073 }
40074 - if (port->count) {
40075 + if (atomic_read(&port->count)) {
40076 #ifdef ISDN_DEBUG_MODEM_OPEN
40077 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
40078 #endif
40079 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
40080 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
40081 return;
40082 isdn_tty_shutdown(info);
40083 - port->count = 0;
40084 + atomic_set(&port->count, 0);
40085 port->flags &= ~ASYNC_NORMAL_ACTIVE;
40086 port->tty = NULL;
40087 wake_up_interruptible(&port->open_wait);
40088 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
40089 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
40090 modem_info *info = &dev->mdm.info[i];
40091
40092 - if (info->port.count == 0)
40093 + if (atomic_read(&info->port.count) == 0)
40094 continue;
40095 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
40096 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
40097 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
40098 index e74df7c..03a03ba 100644
40099 --- a/drivers/isdn/icn/icn.c
40100 +++ b/drivers/isdn/icn/icn.c
40101 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
40102 if (count > len)
40103 count = len;
40104 if (user) {
40105 - if (copy_from_user(msg, buf, count))
40106 + if (count > sizeof msg || copy_from_user(msg, buf, count))
40107 return -EFAULT;
40108 } else
40109 memcpy(msg, buf, count);
40110 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
40111 index 6a8405d..0bd1c7e 100644
40112 --- a/drivers/leds/leds-clevo-mail.c
40113 +++ b/drivers/leds/leds-clevo-mail.c
40114 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
40115 * detected as working, but in reality it is not) as low as
40116 * possible.
40117 */
40118 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
40119 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
40120 {
40121 .callback = clevo_mail_led_dmi_callback,
40122 .ident = "Clevo D410J",
40123 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
40124 index 64e204e..c6bf189 100644
40125 --- a/drivers/leds/leds-ss4200.c
40126 +++ b/drivers/leds/leds-ss4200.c
40127 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
40128 * detected as working, but in reality it is not) as low as
40129 * possible.
40130 */
40131 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
40132 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
40133 {
40134 .callback = ss4200_led_dmi_callback,
40135 .ident = "Intel SS4200-E",
40136 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
40137 index 0bf1e4e..b4bf44e 100644
40138 --- a/drivers/lguest/core.c
40139 +++ b/drivers/lguest/core.c
40140 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
40141 * The end address needs +1 because __get_vm_area allocates an
40142 * extra guard page, so we need space for that.
40143 */
40144 +
40145 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
40146 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
40147 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
40148 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
40149 +#else
40150 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
40151 VM_ALLOC, switcher_addr, switcher_addr
40152 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
40153 +#endif
40154 +
40155 if (!switcher_vma) {
40156 err = -ENOMEM;
40157 printk("lguest: could not map switcher pages high\n");
40158 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
40159 * Now the Switcher is mapped at the right address, we can't fail!
40160 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
40161 */
40162 - memcpy(switcher_vma->addr, start_switcher_text,
40163 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
40164 end_switcher_text - start_switcher_text);
40165
40166 printk(KERN_INFO "lguest: mapped switcher at %p\n",
40167 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
40168 index 5b9ac32..2ef4f26 100644
40169 --- a/drivers/lguest/page_tables.c
40170 +++ b/drivers/lguest/page_tables.c
40171 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
40172 /*:*/
40173
40174 #ifdef CONFIG_X86_PAE
40175 -static void release_pmd(pmd_t *spmd)
40176 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
40177 {
40178 /* If the entry's not present, there's nothing to release. */
40179 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
40180 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
40181 index f0a3347..f6608b2 100644
40182 --- a/drivers/lguest/x86/core.c
40183 +++ b/drivers/lguest/x86/core.c
40184 @@ -59,7 +59,7 @@ static struct {
40185 /* Offset from where switcher.S was compiled to where we've copied it */
40186 static unsigned long switcher_offset(void)
40187 {
40188 - return switcher_addr - (unsigned long)start_switcher_text;
40189 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
40190 }
40191
40192 /* This cpu's struct lguest_pages (after the Switcher text page) */
40193 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
40194 * These copies are pretty cheap, so we do them unconditionally: */
40195 /* Save the current Host top-level page directory.
40196 */
40197 +
40198 +#ifdef CONFIG_PAX_PER_CPU_PGD
40199 + pages->state.host_cr3 = read_cr3();
40200 +#else
40201 pages->state.host_cr3 = __pa(current->mm->pgd);
40202 +#endif
40203 +
40204 /*
40205 * Set up the Guest's page tables to see this CPU's pages (and no
40206 * other CPU's pages).
40207 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
40208 * compiled-in switcher code and the high-mapped copy we just made.
40209 */
40210 for (i = 0; i < IDT_ENTRIES; i++)
40211 - default_idt_entries[i] += switcher_offset();
40212 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
40213
40214 /*
40215 * Set up the Switcher's per-cpu areas.
40216 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
40217 * it will be undisturbed when we switch. To change %cs and jump we
40218 * need this structure to feed to Intel's "lcall" instruction.
40219 */
40220 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
40221 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
40222 lguest_entry.segment = LGUEST_CS;
40223
40224 /*
40225 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
40226 index 40634b0..4f5855e 100644
40227 --- a/drivers/lguest/x86/switcher_32.S
40228 +++ b/drivers/lguest/x86/switcher_32.S
40229 @@ -87,6 +87,7 @@
40230 #include <asm/page.h>
40231 #include <asm/segment.h>
40232 #include <asm/lguest.h>
40233 +#include <asm/processor-flags.h>
40234
40235 // We mark the start of the code to copy
40236 // It's placed in .text tho it's never run here
40237 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
40238 // Changes type when we load it: damn Intel!
40239 // For after we switch over our page tables
40240 // That entry will be read-only: we'd crash.
40241 +
40242 +#ifdef CONFIG_PAX_KERNEXEC
40243 + mov %cr0, %edx
40244 + xor $X86_CR0_WP, %edx
40245 + mov %edx, %cr0
40246 +#endif
40247 +
40248 movl $(GDT_ENTRY_TSS*8), %edx
40249 ltr %dx
40250
40251 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
40252 // Let's clear it again for our return.
40253 // The GDT descriptor of the Host
40254 // Points to the table after two "size" bytes
40255 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
40256 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
40257 // Clear "used" from type field (byte 5, bit 2)
40258 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
40259 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
40260 +
40261 +#ifdef CONFIG_PAX_KERNEXEC
40262 + mov %cr0, %eax
40263 + xor $X86_CR0_WP, %eax
40264 + mov %eax, %cr0
40265 +#endif
40266
40267 // Once our page table's switched, the Guest is live!
40268 // The Host fades as we run this final step.
40269 @@ -295,13 +309,12 @@ deliver_to_host:
40270 // I consulted gcc, and it gave
40271 // These instructions, which I gladly credit:
40272 leal (%edx,%ebx,8), %eax
40273 - movzwl (%eax),%edx
40274 - movl 4(%eax), %eax
40275 - xorw %ax, %ax
40276 - orl %eax, %edx
40277 + movl 4(%eax), %edx
40278 + movw (%eax), %dx
40279 // Now the address of the handler's in %edx
40280 // We call it now: its "iret" drops us home.
40281 - jmp *%edx
40282 + ljmp $__KERNEL_CS, $1f
40283 +1: jmp *%edx
40284
40285 // Every interrupt can come to us here
40286 // But we must truly tell each apart.
40287 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
40288 index 0003992..854bbce 100644
40289 --- a/drivers/md/bcache/closure.h
40290 +++ b/drivers/md/bcache/closure.h
40291 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
40292 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
40293 struct workqueue_struct *wq)
40294 {
40295 - BUG_ON(object_is_on_stack(cl));
40296 + BUG_ON(object_starts_on_stack(cl));
40297 closure_set_ip(cl);
40298 cl->fn = fn;
40299 cl->wq = wq;
40300 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
40301 index 5a2c754..0fa55db 100644
40302 --- a/drivers/md/bitmap.c
40303 +++ b/drivers/md/bitmap.c
40304 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
40305 chunk_kb ? "KB" : "B");
40306 if (bitmap->storage.file) {
40307 seq_printf(seq, ", file: ");
40308 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
40309 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
40310 }
40311
40312 seq_printf(seq, "\n");
40313 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
40314 index 81a79b7..87a0f73 100644
40315 --- a/drivers/md/dm-ioctl.c
40316 +++ b/drivers/md/dm-ioctl.c
40317 @@ -1697,7 +1697,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
40318 cmd == DM_LIST_VERSIONS_CMD)
40319 return 0;
40320
40321 - if ((cmd == DM_DEV_CREATE_CMD)) {
40322 + if (cmd == DM_DEV_CREATE_CMD) {
40323 if (!*param->name) {
40324 DMWARN("name not supplied when creating device");
40325 return -EINVAL;
40326 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
40327 index 699b5be..eac0a15 100644
40328 --- a/drivers/md/dm-raid1.c
40329 +++ b/drivers/md/dm-raid1.c
40330 @@ -40,7 +40,7 @@ enum dm_raid1_error {
40331
40332 struct mirror {
40333 struct mirror_set *ms;
40334 - atomic_t error_count;
40335 + atomic_unchecked_t error_count;
40336 unsigned long error_type;
40337 struct dm_dev *dev;
40338 sector_t offset;
40339 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
40340 struct mirror *m;
40341
40342 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
40343 - if (!atomic_read(&m->error_count))
40344 + if (!atomic_read_unchecked(&m->error_count))
40345 return m;
40346
40347 return NULL;
40348 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
40349 * simple way to tell if a device has encountered
40350 * errors.
40351 */
40352 - atomic_inc(&m->error_count);
40353 + atomic_inc_unchecked(&m->error_count);
40354
40355 if (test_and_set_bit(error_type, &m->error_type))
40356 return;
40357 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
40358 struct mirror *m = get_default_mirror(ms);
40359
40360 do {
40361 - if (likely(!atomic_read(&m->error_count)))
40362 + if (likely(!atomic_read_unchecked(&m->error_count)))
40363 return m;
40364
40365 if (m-- == ms->mirror)
40366 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
40367 {
40368 struct mirror *default_mirror = get_default_mirror(m->ms);
40369
40370 - return !atomic_read(&default_mirror->error_count);
40371 + return !atomic_read_unchecked(&default_mirror->error_count);
40372 }
40373
40374 static int mirror_available(struct mirror_set *ms, struct bio *bio)
40375 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
40376 */
40377 if (likely(region_in_sync(ms, region, 1)))
40378 m = choose_mirror(ms, bio->bi_sector);
40379 - else if (m && atomic_read(&m->error_count))
40380 + else if (m && atomic_read_unchecked(&m->error_count))
40381 m = NULL;
40382
40383 if (likely(m))
40384 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
40385 }
40386
40387 ms->mirror[mirror].ms = ms;
40388 - atomic_set(&(ms->mirror[mirror].error_count), 0);
40389 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
40390 ms->mirror[mirror].error_type = 0;
40391 ms->mirror[mirror].offset = offset;
40392
40393 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
40394 */
40395 static char device_status_char(struct mirror *m)
40396 {
40397 - if (!atomic_read(&(m->error_count)))
40398 + if (!atomic_read_unchecked(&(m->error_count)))
40399 return 'A';
40400
40401 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
40402 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
40403 index d907ca6..cfb8384 100644
40404 --- a/drivers/md/dm-stripe.c
40405 +++ b/drivers/md/dm-stripe.c
40406 @@ -20,7 +20,7 @@ struct stripe {
40407 struct dm_dev *dev;
40408 sector_t physical_start;
40409
40410 - atomic_t error_count;
40411 + atomic_unchecked_t error_count;
40412 };
40413
40414 struct stripe_c {
40415 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
40416 kfree(sc);
40417 return r;
40418 }
40419 - atomic_set(&(sc->stripe[i].error_count), 0);
40420 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
40421 }
40422
40423 ti->private = sc;
40424 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
40425 DMEMIT("%d ", sc->stripes);
40426 for (i = 0; i < sc->stripes; i++) {
40427 DMEMIT("%s ", sc->stripe[i].dev->name);
40428 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
40429 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
40430 'D' : 'A';
40431 }
40432 buffer[i] = '\0';
40433 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
40434 */
40435 for (i = 0; i < sc->stripes; i++)
40436 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
40437 - atomic_inc(&(sc->stripe[i].error_count));
40438 - if (atomic_read(&(sc->stripe[i].error_count)) <
40439 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
40440 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
40441 DM_IO_ERROR_THRESHOLD)
40442 schedule_work(&sc->trigger_event);
40443 }
40444 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
40445 index 1ff252a..ee384c1 100644
40446 --- a/drivers/md/dm-table.c
40447 +++ b/drivers/md/dm-table.c
40448 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
40449 if (!dev_size)
40450 return 0;
40451
40452 - if ((start >= dev_size) || (start + len > dev_size)) {
40453 + if ((start >= dev_size) || (len > dev_size - start)) {
40454 DMWARN("%s: %s too small for target: "
40455 "start=%llu, len=%llu, dev_size=%llu",
40456 dm_device_name(ti->table->md), bdevname(bdev, b),
40457 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
40458 index 60bce43..9b997d0 100644
40459 --- a/drivers/md/dm-thin-metadata.c
40460 +++ b/drivers/md/dm-thin-metadata.c
40461 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
40462 {
40463 pmd->info.tm = pmd->tm;
40464 pmd->info.levels = 2;
40465 - pmd->info.value_type.context = pmd->data_sm;
40466 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
40467 pmd->info.value_type.size = sizeof(__le64);
40468 pmd->info.value_type.inc = data_block_inc;
40469 pmd->info.value_type.dec = data_block_dec;
40470 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
40471
40472 pmd->bl_info.tm = pmd->tm;
40473 pmd->bl_info.levels = 1;
40474 - pmd->bl_info.value_type.context = pmd->data_sm;
40475 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
40476 pmd->bl_info.value_type.size = sizeof(__le64);
40477 pmd->bl_info.value_type.inc = data_block_inc;
40478 pmd->bl_info.value_type.dec = data_block_dec;
40479 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
40480 index 33f2010..23fb84c 100644
40481 --- a/drivers/md/dm.c
40482 +++ b/drivers/md/dm.c
40483 @@ -169,9 +169,9 @@ struct mapped_device {
40484 /*
40485 * Event handling.
40486 */
40487 - atomic_t event_nr;
40488 + atomic_unchecked_t event_nr;
40489 wait_queue_head_t eventq;
40490 - atomic_t uevent_seq;
40491 + atomic_unchecked_t uevent_seq;
40492 struct list_head uevent_list;
40493 spinlock_t uevent_lock; /* Protect access to uevent_list */
40494
40495 @@ -1884,8 +1884,8 @@ static struct mapped_device *alloc_dev(int minor)
40496 rwlock_init(&md->map_lock);
40497 atomic_set(&md->holders, 1);
40498 atomic_set(&md->open_count, 0);
40499 - atomic_set(&md->event_nr, 0);
40500 - atomic_set(&md->uevent_seq, 0);
40501 + atomic_set_unchecked(&md->event_nr, 0);
40502 + atomic_set_unchecked(&md->uevent_seq, 0);
40503 INIT_LIST_HEAD(&md->uevent_list);
40504 spin_lock_init(&md->uevent_lock);
40505
40506 @@ -2033,7 +2033,7 @@ static void event_callback(void *context)
40507
40508 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
40509
40510 - atomic_inc(&md->event_nr);
40511 + atomic_inc_unchecked(&md->event_nr);
40512 wake_up(&md->eventq);
40513 }
40514
40515 @@ -2690,18 +2690,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
40516
40517 uint32_t dm_next_uevent_seq(struct mapped_device *md)
40518 {
40519 - return atomic_add_return(1, &md->uevent_seq);
40520 + return atomic_add_return_unchecked(1, &md->uevent_seq);
40521 }
40522
40523 uint32_t dm_get_event_nr(struct mapped_device *md)
40524 {
40525 - return atomic_read(&md->event_nr);
40526 + return atomic_read_unchecked(&md->event_nr);
40527 }
40528
40529 int dm_wait_event(struct mapped_device *md, int event_nr)
40530 {
40531 return wait_event_interruptible(md->eventq,
40532 - (event_nr != atomic_read(&md->event_nr)));
40533 + (event_nr != atomic_read_unchecked(&md->event_nr)));
40534 }
40535
40536 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
40537 diff --git a/drivers/md/md.c b/drivers/md/md.c
40538 index 51f0345..c77810e 100644
40539 --- a/drivers/md/md.c
40540 +++ b/drivers/md/md.c
40541 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
40542 * start build, activate spare
40543 */
40544 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
40545 -static atomic_t md_event_count;
40546 +static atomic_unchecked_t md_event_count;
40547 void md_new_event(struct mddev *mddev)
40548 {
40549 - atomic_inc(&md_event_count);
40550 + atomic_inc_unchecked(&md_event_count);
40551 wake_up(&md_event_waiters);
40552 }
40553 EXPORT_SYMBOL_GPL(md_new_event);
40554 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
40555 */
40556 static void md_new_event_inintr(struct mddev *mddev)
40557 {
40558 - atomic_inc(&md_event_count);
40559 + atomic_inc_unchecked(&md_event_count);
40560 wake_up(&md_event_waiters);
40561 }
40562
40563 @@ -1501,7 +1501,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
40564 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
40565 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
40566 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
40567 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
40568 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
40569
40570 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
40571 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
40572 @@ -1745,7 +1745,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
40573 else
40574 sb->resync_offset = cpu_to_le64(0);
40575
40576 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
40577 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
40578
40579 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
40580 sb->size = cpu_to_le64(mddev->dev_sectors);
40581 @@ -2750,7 +2750,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
40582 static ssize_t
40583 errors_show(struct md_rdev *rdev, char *page)
40584 {
40585 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
40586 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
40587 }
40588
40589 static ssize_t
40590 @@ -2759,7 +2759,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
40591 char *e;
40592 unsigned long n = simple_strtoul(buf, &e, 10);
40593 if (*buf && (*e == 0 || *e == '\n')) {
40594 - atomic_set(&rdev->corrected_errors, n);
40595 + atomic_set_unchecked(&rdev->corrected_errors, n);
40596 return len;
40597 }
40598 return -EINVAL;
40599 @@ -3207,8 +3207,8 @@ int md_rdev_init(struct md_rdev *rdev)
40600 rdev->sb_loaded = 0;
40601 rdev->bb_page = NULL;
40602 atomic_set(&rdev->nr_pending, 0);
40603 - atomic_set(&rdev->read_errors, 0);
40604 - atomic_set(&rdev->corrected_errors, 0);
40605 + atomic_set_unchecked(&rdev->read_errors, 0);
40606 + atomic_set_unchecked(&rdev->corrected_errors, 0);
40607
40608 INIT_LIST_HEAD(&rdev->same_set);
40609 init_waitqueue_head(&rdev->blocked_wait);
40610 @@ -7009,7 +7009,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
40611
40612 spin_unlock(&pers_lock);
40613 seq_printf(seq, "\n");
40614 - seq->poll_event = atomic_read(&md_event_count);
40615 + seq->poll_event = atomic_read_unchecked(&md_event_count);
40616 return 0;
40617 }
40618 if (v == (void*)2) {
40619 @@ -7112,7 +7112,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
40620 return error;
40621
40622 seq = file->private_data;
40623 - seq->poll_event = atomic_read(&md_event_count);
40624 + seq->poll_event = atomic_read_unchecked(&md_event_count);
40625 return error;
40626 }
40627
40628 @@ -7126,7 +7126,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
40629 /* always allow read */
40630 mask = POLLIN | POLLRDNORM;
40631
40632 - if (seq->poll_event != atomic_read(&md_event_count))
40633 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
40634 mask |= POLLERR | POLLPRI;
40635 return mask;
40636 }
40637 @@ -7170,7 +7170,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
40638 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
40639 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
40640 (int)part_stat_read(&disk->part0, sectors[1]) -
40641 - atomic_read(&disk->sync_io);
40642 + atomic_read_unchecked(&disk->sync_io);
40643 /* sync IO will cause sync_io to increase before the disk_stats
40644 * as sync_io is counted when a request starts, and
40645 * disk_stats is counted when it completes.
40646 diff --git a/drivers/md/md.h b/drivers/md/md.h
40647 index 653f992b6..6af6c40 100644
40648 --- a/drivers/md/md.h
40649 +++ b/drivers/md/md.h
40650 @@ -94,13 +94,13 @@ struct md_rdev {
40651 * only maintained for arrays that
40652 * support hot removal
40653 */
40654 - atomic_t read_errors; /* number of consecutive read errors that
40655 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
40656 * we have tried to ignore.
40657 */
40658 struct timespec last_read_error; /* monotonic time since our
40659 * last read error
40660 */
40661 - atomic_t corrected_errors; /* number of corrected read errors,
40662 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
40663 * for reporting to userspace and storing
40664 * in superblock.
40665 */
40666 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
40667
40668 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
40669 {
40670 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
40671 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
40672 }
40673
40674 struct md_personality
40675 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
40676 index 3e6d115..ffecdeb 100644
40677 --- a/drivers/md/persistent-data/dm-space-map.h
40678 +++ b/drivers/md/persistent-data/dm-space-map.h
40679 @@ -71,6 +71,7 @@ struct dm_space_map {
40680 dm_sm_threshold_fn fn,
40681 void *context);
40682 };
40683 +typedef struct dm_space_map __no_const dm_space_map_no_const;
40684
40685 /*----------------------------------------------------------------*/
40686
40687 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
40688 index 6f48244..7d29145 100644
40689 --- a/drivers/md/raid1.c
40690 +++ b/drivers/md/raid1.c
40691 @@ -1822,7 +1822,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
40692 if (r1_sync_page_io(rdev, sect, s,
40693 bio->bi_io_vec[idx].bv_page,
40694 READ) != 0)
40695 - atomic_add(s, &rdev->corrected_errors);
40696 + atomic_add_unchecked(s, &rdev->corrected_errors);
40697 }
40698 sectors -= s;
40699 sect += s;
40700 @@ -2049,7 +2049,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
40701 test_bit(In_sync, &rdev->flags)) {
40702 if (r1_sync_page_io(rdev, sect, s,
40703 conf->tmppage, READ)) {
40704 - atomic_add(s, &rdev->corrected_errors);
40705 + atomic_add_unchecked(s, &rdev->corrected_errors);
40706 printk(KERN_INFO
40707 "md/raid1:%s: read error corrected "
40708 "(%d sectors at %llu on %s)\n",
40709 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
40710 index 081bb33..3c4b287 100644
40711 --- a/drivers/md/raid10.c
40712 +++ b/drivers/md/raid10.c
40713 @@ -1940,7 +1940,7 @@ static void end_sync_read(struct bio *bio, int error)
40714 /* The write handler will notice the lack of
40715 * R10BIO_Uptodate and record any errors etc
40716 */
40717 - atomic_add(r10_bio->sectors,
40718 + atomic_add_unchecked(r10_bio->sectors,
40719 &conf->mirrors[d].rdev->corrected_errors);
40720
40721 /* for reconstruct, we always reschedule after a read.
40722 @@ -2298,7 +2298,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
40723 {
40724 struct timespec cur_time_mon;
40725 unsigned long hours_since_last;
40726 - unsigned int read_errors = atomic_read(&rdev->read_errors);
40727 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
40728
40729 ktime_get_ts(&cur_time_mon);
40730
40731 @@ -2320,9 +2320,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
40732 * overflowing the shift of read_errors by hours_since_last.
40733 */
40734 if (hours_since_last >= 8 * sizeof(read_errors))
40735 - atomic_set(&rdev->read_errors, 0);
40736 + atomic_set_unchecked(&rdev->read_errors, 0);
40737 else
40738 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
40739 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
40740 }
40741
40742 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
40743 @@ -2376,8 +2376,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
40744 return;
40745
40746 check_decay_read_errors(mddev, rdev);
40747 - atomic_inc(&rdev->read_errors);
40748 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
40749 + atomic_inc_unchecked(&rdev->read_errors);
40750 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
40751 char b[BDEVNAME_SIZE];
40752 bdevname(rdev->bdev, b);
40753
40754 @@ -2385,7 +2385,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
40755 "md/raid10:%s: %s: Raid device exceeded "
40756 "read_error threshold [cur %d:max %d]\n",
40757 mdname(mddev), b,
40758 - atomic_read(&rdev->read_errors), max_read_errors);
40759 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
40760 printk(KERN_NOTICE
40761 "md/raid10:%s: %s: Failing raid device\n",
40762 mdname(mddev), b);
40763 @@ -2540,7 +2540,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
40764 sect +
40765 choose_data_offset(r10_bio, rdev)),
40766 bdevname(rdev->bdev, b));
40767 - atomic_add(s, &rdev->corrected_errors);
40768 + atomic_add_unchecked(s, &rdev->corrected_errors);
40769 }
40770
40771 rdev_dec_pending(rdev, mddev);
40772 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
40773 index a35b846..e295c6d 100644
40774 --- a/drivers/md/raid5.c
40775 +++ b/drivers/md/raid5.c
40776 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
40777 mdname(conf->mddev), STRIPE_SECTORS,
40778 (unsigned long long)s,
40779 bdevname(rdev->bdev, b));
40780 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
40781 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
40782 clear_bit(R5_ReadError, &sh->dev[i].flags);
40783 clear_bit(R5_ReWrite, &sh->dev[i].flags);
40784 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
40785 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
40786
40787 - if (atomic_read(&rdev->read_errors))
40788 - atomic_set(&rdev->read_errors, 0);
40789 + if (atomic_read_unchecked(&rdev->read_errors))
40790 + atomic_set_unchecked(&rdev->read_errors, 0);
40791 } else {
40792 const char *bdn = bdevname(rdev->bdev, b);
40793 int retry = 0;
40794 int set_bad = 0;
40795
40796 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
40797 - atomic_inc(&rdev->read_errors);
40798 + atomic_inc_unchecked(&rdev->read_errors);
40799 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
40800 printk_ratelimited(
40801 KERN_WARNING
40802 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
40803 mdname(conf->mddev),
40804 (unsigned long long)s,
40805 bdn);
40806 - } else if (atomic_read(&rdev->read_errors)
40807 + } else if (atomic_read_unchecked(&rdev->read_errors)
40808 > conf->max_nr_stripes)
40809 printk(KERN_WARNING
40810 "md/raid:%s: Too many read errors, failing device %s.\n",
40811 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
40812 index 401ef64..836e563 100644
40813 --- a/drivers/media/dvb-core/dvbdev.c
40814 +++ b/drivers/media/dvb-core/dvbdev.c
40815 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
40816 const struct dvb_device *template, void *priv, int type)
40817 {
40818 struct dvb_device *dvbdev;
40819 - struct file_operations *dvbdevfops;
40820 + file_operations_no_const *dvbdevfops;
40821 struct device *clsdev;
40822 int minor;
40823 int id;
40824 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
40825 index 9b6c3bb..baeb5c7 100644
40826 --- a/drivers/media/dvb-frontends/dib3000.h
40827 +++ b/drivers/media/dvb-frontends/dib3000.h
40828 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
40829 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
40830 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
40831 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
40832 -};
40833 +} __no_const;
40834
40835 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
40836 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
40837 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
40838 index c7a9be1..683f6f8 100644
40839 --- a/drivers/media/pci/cx88/cx88-video.c
40840 +++ b/drivers/media/pci/cx88/cx88-video.c
40841 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
40842
40843 /* ------------------------------------------------------------------ */
40844
40845 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40846 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40847 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40848 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40849 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40850 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40851
40852 module_param_array(video_nr, int, NULL, 0444);
40853 module_param_array(vbi_nr, int, NULL, 0444);
40854 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
40855 index d338b19..aae4f9e 100644
40856 --- a/drivers/media/platform/omap/omap_vout.c
40857 +++ b/drivers/media/platform/omap/omap_vout.c
40858 @@ -63,7 +63,6 @@ enum omap_vout_channels {
40859 OMAP_VIDEO2,
40860 };
40861
40862 -static struct videobuf_queue_ops video_vbq_ops;
40863 /* Variables configurable through module params*/
40864 static u32 video1_numbuffers = 3;
40865 static u32 video2_numbuffers = 3;
40866 @@ -1015,6 +1014,12 @@ static int omap_vout_open(struct file *file)
40867 {
40868 struct videobuf_queue *q;
40869 struct omap_vout_device *vout = NULL;
40870 + static struct videobuf_queue_ops video_vbq_ops = {
40871 + .buf_setup = omap_vout_buffer_setup,
40872 + .buf_prepare = omap_vout_buffer_prepare,
40873 + .buf_release = omap_vout_buffer_release,
40874 + .buf_queue = omap_vout_buffer_queue,
40875 + };
40876
40877 vout = video_drvdata(file);
40878 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
40879 @@ -1032,10 +1037,6 @@ static int omap_vout_open(struct file *file)
40880 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
40881
40882 q = &vout->vbq;
40883 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
40884 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
40885 - video_vbq_ops.buf_release = omap_vout_buffer_release;
40886 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
40887 spin_lock_init(&vout->vbq_lock);
40888
40889 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
40890 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
40891 index 04e6490..2df65bf 100644
40892 --- a/drivers/media/platform/s5p-tv/mixer.h
40893 +++ b/drivers/media/platform/s5p-tv/mixer.h
40894 @@ -156,7 +156,7 @@ struct mxr_layer {
40895 /** layer index (unique identifier) */
40896 int idx;
40897 /** callbacks for layer methods */
40898 - struct mxr_layer_ops ops;
40899 + struct mxr_layer_ops *ops;
40900 /** format array */
40901 const struct mxr_format **fmt_array;
40902 /** size of format array */
40903 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
40904 index b93a21f..2535195 100644
40905 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
40906 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
40907 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
40908 {
40909 struct mxr_layer *layer;
40910 int ret;
40911 - struct mxr_layer_ops ops = {
40912 + static struct mxr_layer_ops ops = {
40913 .release = mxr_graph_layer_release,
40914 .buffer_set = mxr_graph_buffer_set,
40915 .stream_set = mxr_graph_stream_set,
40916 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
40917 index b713403..53cb5ad 100644
40918 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
40919 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
40920 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
40921 layer->update_buf = next;
40922 }
40923
40924 - layer->ops.buffer_set(layer, layer->update_buf);
40925 + layer->ops->buffer_set(layer, layer->update_buf);
40926
40927 if (done && done != layer->shadow_buf)
40928 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
40929 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
40930 index ef0efdf..8c78eb6 100644
40931 --- a/drivers/media/platform/s5p-tv/mixer_video.c
40932 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
40933 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
40934 layer->geo.src.height = layer->geo.src.full_height;
40935
40936 mxr_geometry_dump(mdev, &layer->geo);
40937 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
40938 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
40939 mxr_geometry_dump(mdev, &layer->geo);
40940 }
40941
40942 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
40943 layer->geo.dst.full_width = mbus_fmt.width;
40944 layer->geo.dst.full_height = mbus_fmt.height;
40945 layer->geo.dst.field = mbus_fmt.field;
40946 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
40947 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
40948
40949 mxr_geometry_dump(mdev, &layer->geo);
40950 }
40951 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
40952 /* set source size to highest accepted value */
40953 geo->src.full_width = max(geo->dst.full_width, pix->width);
40954 geo->src.full_height = max(geo->dst.full_height, pix->height);
40955 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
40956 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
40957 mxr_geometry_dump(mdev, &layer->geo);
40958 /* set cropping to total visible screen */
40959 geo->src.width = pix->width;
40960 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
40961 geo->src.x_offset = 0;
40962 geo->src.y_offset = 0;
40963 /* assure consistency of geometry */
40964 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
40965 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
40966 mxr_geometry_dump(mdev, &layer->geo);
40967 /* set full size to lowest possible value */
40968 geo->src.full_width = 0;
40969 geo->src.full_height = 0;
40970 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
40971 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
40972 mxr_geometry_dump(mdev, &layer->geo);
40973
40974 /* returning results */
40975 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
40976 target->width = s->r.width;
40977 target->height = s->r.height;
40978
40979 - layer->ops.fix_geometry(layer, stage, s->flags);
40980 + layer->ops->fix_geometry(layer, stage, s->flags);
40981
40982 /* retrieve update selection rectangle */
40983 res.left = target->x_offset;
40984 @@ -954,13 +954,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
40985 mxr_output_get(mdev);
40986
40987 mxr_layer_update_output(layer);
40988 - layer->ops.format_set(layer);
40989 + layer->ops->format_set(layer);
40990 /* enabling layer in hardware */
40991 spin_lock_irqsave(&layer->enq_slock, flags);
40992 layer->state = MXR_LAYER_STREAMING;
40993 spin_unlock_irqrestore(&layer->enq_slock, flags);
40994
40995 - layer->ops.stream_set(layer, MXR_ENABLE);
40996 + layer->ops->stream_set(layer, MXR_ENABLE);
40997 mxr_streamer_get(mdev);
40998
40999 return 0;
41000 @@ -1030,7 +1030,7 @@ static int stop_streaming(struct vb2_queue *vq)
41001 spin_unlock_irqrestore(&layer->enq_slock, flags);
41002
41003 /* disabling layer in hardware */
41004 - layer->ops.stream_set(layer, MXR_DISABLE);
41005 + layer->ops->stream_set(layer, MXR_DISABLE);
41006 /* remove one streamer */
41007 mxr_streamer_put(mdev);
41008 /* allow changes in output configuration */
41009 @@ -1069,8 +1069,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
41010
41011 void mxr_layer_release(struct mxr_layer *layer)
41012 {
41013 - if (layer->ops.release)
41014 - layer->ops.release(layer);
41015 + if (layer->ops->release)
41016 + layer->ops->release(layer);
41017 }
41018
41019 void mxr_base_layer_release(struct mxr_layer *layer)
41020 @@ -1096,7 +1096,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
41021
41022 layer->mdev = mdev;
41023 layer->idx = idx;
41024 - layer->ops = *ops;
41025 + layer->ops = ops;
41026
41027 spin_lock_init(&layer->enq_slock);
41028 INIT_LIST_HEAD(&layer->enq_list);
41029 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
41030 index 3d13a63..da31bf1 100644
41031 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
41032 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
41033 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
41034 {
41035 struct mxr_layer *layer;
41036 int ret;
41037 - struct mxr_layer_ops ops = {
41038 + static struct mxr_layer_ops ops = {
41039 .release = mxr_vp_layer_release,
41040 .buffer_set = mxr_vp_buffer_set,
41041 .stream_set = mxr_vp_stream_set,
41042 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
41043 index 545c04c..a14bded 100644
41044 --- a/drivers/media/radio/radio-cadet.c
41045 +++ b/drivers/media/radio/radio-cadet.c
41046 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
41047 unsigned char readbuf[RDS_BUFFER];
41048 int i = 0;
41049
41050 + if (count > RDS_BUFFER)
41051 + return -EFAULT;
41052 mutex_lock(&dev->lock);
41053 if (dev->rdsstat == 0)
41054 cadet_start_rds(dev);
41055 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
41056 while (i < count && dev->rdsin != dev->rdsout)
41057 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
41058
41059 - if (i && copy_to_user(data, readbuf, i))
41060 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
41061 i = -EFAULT;
41062 unlock:
41063 mutex_unlock(&dev->lock);
41064 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
41065 index 3940bb0..fb3952a 100644
41066 --- a/drivers/media/usb/dvb-usb/cxusb.c
41067 +++ b/drivers/media/usb/dvb-usb/cxusb.c
41068 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
41069
41070 struct dib0700_adapter_state {
41071 int (*set_param_save) (struct dvb_frontend *);
41072 -};
41073 +} __no_const;
41074
41075 static int dib7070_set_param_override(struct dvb_frontend *fe)
41076 {
41077 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
41078 index 6e237b6..dc25556 100644
41079 --- a/drivers/media/usb/dvb-usb/dw2102.c
41080 +++ b/drivers/media/usb/dvb-usb/dw2102.c
41081 @@ -118,7 +118,7 @@ struct su3000_state {
41082
41083 struct s6x0_state {
41084 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
41085 -};
41086 +} __no_const;
41087
41088 /* debug */
41089 static int dvb_usb_dw2102_debug;
41090 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
41091 index f129551..ecf6514 100644
41092 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
41093 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
41094 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
41095 __u32 reserved;
41096 };
41097
41098 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
41099 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
41100 enum v4l2_memory memory)
41101 {
41102 void __user *up_pln;
41103 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
41104 return 0;
41105 }
41106
41107 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
41108 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
41109 enum v4l2_memory memory)
41110 {
41111 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
41112 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
41113 put_user(kp->start_block, &up->start_block) ||
41114 put_user(kp->blocks, &up->blocks) ||
41115 put_user(tmp, &up->edid) ||
41116 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
41117 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
41118 return -EFAULT;
41119 return 0;
41120 }
41121 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
41122 index 7658586..1079260 100644
41123 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
41124 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
41125 @@ -1995,7 +1995,8 @@ struct v4l2_ioctl_info {
41126 struct file *file, void *fh, void *p);
41127 } u;
41128 void (*debug)(const void *arg, bool write_only);
41129 -};
41130 +} __do_const;
41131 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
41132
41133 /* This control needs a priority check */
41134 #define INFO_FL_PRIO (1 << 0)
41135 @@ -2177,7 +2178,7 @@ static long __video_do_ioctl(struct file *file,
41136 struct video_device *vfd = video_devdata(file);
41137 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
41138 bool write_only = false;
41139 - struct v4l2_ioctl_info default_info;
41140 + v4l2_ioctl_info_no_const default_info;
41141 const struct v4l2_ioctl_info *info;
41142 void *fh = file->private_data;
41143 struct v4l2_fh *vfh = NULL;
41144 @@ -2251,7 +2252,7 @@ done:
41145 }
41146
41147 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
41148 - void * __user *user_ptr, void ***kernel_ptr)
41149 + void __user **user_ptr, void ***kernel_ptr)
41150 {
41151 int ret = 0;
41152
41153 @@ -2267,7 +2268,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
41154 ret = -EINVAL;
41155 break;
41156 }
41157 - *user_ptr = (void __user *)buf->m.planes;
41158 + *user_ptr = (void __force_user *)buf->m.planes;
41159 *kernel_ptr = (void *)&buf->m.planes;
41160 *array_size = sizeof(struct v4l2_plane) * buf->length;
41161 ret = 1;
41162 @@ -2302,7 +2303,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
41163 ret = -EINVAL;
41164 break;
41165 }
41166 - *user_ptr = (void __user *)ctrls->controls;
41167 + *user_ptr = (void __force_user *)ctrls->controls;
41168 *kernel_ptr = (void *)&ctrls->controls;
41169 *array_size = sizeof(struct v4l2_ext_control)
41170 * ctrls->count;
41171 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
41172 index 767ff4d..c69d259 100644
41173 --- a/drivers/message/fusion/mptbase.c
41174 +++ b/drivers/message/fusion/mptbase.c
41175 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
41176 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
41177 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
41178
41179 +#ifdef CONFIG_GRKERNSEC_HIDESYM
41180 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
41181 +#else
41182 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
41183 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
41184 +#endif
41185 +
41186 /*
41187 * Rounding UP to nearest 4-kB boundary here...
41188 */
41189 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
41190 ioc->facts.GlobalCredits);
41191
41192 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
41193 +#ifdef CONFIG_GRKERNSEC_HIDESYM
41194 + NULL, NULL);
41195 +#else
41196 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
41197 +#endif
41198 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
41199 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
41200 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
41201 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
41202 index dd239bd..689c4f7 100644
41203 --- a/drivers/message/fusion/mptsas.c
41204 +++ b/drivers/message/fusion/mptsas.c
41205 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
41206 return 0;
41207 }
41208
41209 +static inline void
41210 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
41211 +{
41212 + if (phy_info->port_details) {
41213 + phy_info->port_details->rphy = rphy;
41214 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
41215 + ioc->name, rphy));
41216 + }
41217 +
41218 + if (rphy) {
41219 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
41220 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
41221 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
41222 + ioc->name, rphy, rphy->dev.release));
41223 + }
41224 +}
41225 +
41226 /* no mutex */
41227 static void
41228 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
41229 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
41230 return NULL;
41231 }
41232
41233 -static inline void
41234 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
41235 -{
41236 - if (phy_info->port_details) {
41237 - phy_info->port_details->rphy = rphy;
41238 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
41239 - ioc->name, rphy));
41240 - }
41241 -
41242 - if (rphy) {
41243 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
41244 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
41245 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
41246 - ioc->name, rphy, rphy->dev.release));
41247 - }
41248 -}
41249 -
41250 static inline struct sas_port *
41251 mptsas_get_port(struct mptsas_phyinfo *phy_info)
41252 {
41253 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
41254 index 727819c..ad74694 100644
41255 --- a/drivers/message/fusion/mptscsih.c
41256 +++ b/drivers/message/fusion/mptscsih.c
41257 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
41258
41259 h = shost_priv(SChost);
41260
41261 - if (h) {
41262 - if (h->info_kbuf == NULL)
41263 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
41264 - return h->info_kbuf;
41265 - h->info_kbuf[0] = '\0';
41266 + if (!h)
41267 + return NULL;
41268
41269 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
41270 - h->info_kbuf[size-1] = '\0';
41271 - }
41272 + if (h->info_kbuf == NULL)
41273 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
41274 + return h->info_kbuf;
41275 + h->info_kbuf[0] = '\0';
41276 +
41277 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
41278 + h->info_kbuf[size-1] = '\0';
41279
41280 return h->info_kbuf;
41281 }
41282 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
41283 index b7d87cd..9890039 100644
41284 --- a/drivers/message/i2o/i2o_proc.c
41285 +++ b/drivers/message/i2o/i2o_proc.c
41286 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
41287 "Array Controller Device"
41288 };
41289
41290 -static char *chtostr(char *tmp, u8 *chars, int n)
41291 -{
41292 - tmp[0] = 0;
41293 - return strncat(tmp, (char *)chars, n);
41294 -}
41295 -
41296 static int i2o_report_query_status(struct seq_file *seq, int block_status,
41297 char *group)
41298 {
41299 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
41300 } *result;
41301
41302 i2o_exec_execute_ddm_table ddm_table;
41303 - char tmp[28 + 1];
41304
41305 result = kmalloc(sizeof(*result), GFP_KERNEL);
41306 if (!result)
41307 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
41308
41309 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
41310 seq_printf(seq, "%-#8x", ddm_table.module_id);
41311 - seq_printf(seq, "%-29s",
41312 - chtostr(tmp, ddm_table.module_name_version, 28));
41313 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
41314 seq_printf(seq, "%9d ", ddm_table.data_size);
41315 seq_printf(seq, "%8d", ddm_table.code_size);
41316
41317 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
41318
41319 i2o_driver_result_table *result;
41320 i2o_driver_store_table *dst;
41321 - char tmp[28 + 1];
41322
41323 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
41324 if (result == NULL)
41325 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
41326
41327 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
41328 seq_printf(seq, "%-#8x", dst->module_id);
41329 - seq_printf(seq, "%-29s",
41330 - chtostr(tmp, dst->module_name_version, 28));
41331 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
41332 + seq_printf(seq, "%-.28s", dst->module_name_version);
41333 + seq_printf(seq, "%-.8s", dst->date);
41334 seq_printf(seq, "%8d ", dst->module_size);
41335 seq_printf(seq, "%8d ", dst->mpb_size);
41336 seq_printf(seq, "0x%04x", dst->module_flags);
41337 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
41338 // == (allow) 512d bytes (max)
41339 static u16 *work16 = (u16 *) work32;
41340 int token;
41341 - char tmp[16 + 1];
41342
41343 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
41344
41345 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
41346 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
41347 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
41348 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
41349 - seq_printf(seq, "Vendor info : %s\n",
41350 - chtostr(tmp, (u8 *) (work32 + 2), 16));
41351 - seq_printf(seq, "Product info : %s\n",
41352 - chtostr(tmp, (u8 *) (work32 + 6), 16));
41353 - seq_printf(seq, "Description : %s\n",
41354 - chtostr(tmp, (u8 *) (work32 + 10), 16));
41355 - seq_printf(seq, "Product rev. : %s\n",
41356 - chtostr(tmp, (u8 *) (work32 + 14), 8));
41357 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
41358 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
41359 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
41360 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
41361
41362 seq_printf(seq, "Serial number : ");
41363 print_serial_number(seq, (u8 *) (work32 + 16),
41364 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
41365 u8 pad[256]; // allow up to 256 byte (max) serial number
41366 } result;
41367
41368 - char tmp[24 + 1];
41369 -
41370 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
41371
41372 if (token < 0) {
41373 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
41374 }
41375
41376 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
41377 - seq_printf(seq, "Module name : %s\n",
41378 - chtostr(tmp, result.module_name, 24));
41379 - seq_printf(seq, "Module revision : %s\n",
41380 - chtostr(tmp, result.module_rev, 8));
41381 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
41382 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
41383
41384 seq_printf(seq, "Serial number : ");
41385 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
41386 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
41387 u8 instance_number[4];
41388 } result;
41389
41390 - char tmp[64 + 1];
41391 -
41392 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
41393
41394 if (token < 0) {
41395 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
41396 return 0;
41397 }
41398
41399 - seq_printf(seq, "Device name : %s\n",
41400 - chtostr(tmp, result.device_name, 64));
41401 - seq_printf(seq, "Service name : %s\n",
41402 - chtostr(tmp, result.service_name, 64));
41403 - seq_printf(seq, "Physical name : %s\n",
41404 - chtostr(tmp, result.physical_location, 64));
41405 - seq_printf(seq, "Instance number : %s\n",
41406 - chtostr(tmp, result.instance_number, 4));
41407 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
41408 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
41409 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
41410 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
41411
41412 return 0;
41413 }
41414 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
41415 index a8c08f3..155fe3d 100644
41416 --- a/drivers/message/i2o/iop.c
41417 +++ b/drivers/message/i2o/iop.c
41418 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
41419
41420 spin_lock_irqsave(&c->context_list_lock, flags);
41421
41422 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
41423 - atomic_inc(&c->context_list_counter);
41424 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
41425 + atomic_inc_unchecked(&c->context_list_counter);
41426
41427 - entry->context = atomic_read(&c->context_list_counter);
41428 + entry->context = atomic_read_unchecked(&c->context_list_counter);
41429
41430 list_add(&entry->list, &c->context_list);
41431
41432 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
41433
41434 #if BITS_PER_LONG == 64
41435 spin_lock_init(&c->context_list_lock);
41436 - atomic_set(&c->context_list_counter, 0);
41437 + atomic_set_unchecked(&c->context_list_counter, 0);
41438 INIT_LIST_HEAD(&c->context_list);
41439 #endif
41440
41441 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
41442 index 45ece11..8efa218 100644
41443 --- a/drivers/mfd/janz-cmodio.c
41444 +++ b/drivers/mfd/janz-cmodio.c
41445 @@ -13,6 +13,7 @@
41446
41447 #include <linux/kernel.h>
41448 #include <linux/module.h>
41449 +#include <linux/slab.h>
41450 #include <linux/init.h>
41451 #include <linux/pci.h>
41452 #include <linux/interrupt.h>
41453 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
41454 index a5f9888..1c0ed56 100644
41455 --- a/drivers/mfd/twl4030-irq.c
41456 +++ b/drivers/mfd/twl4030-irq.c
41457 @@ -35,6 +35,7 @@
41458 #include <linux/of.h>
41459 #include <linux/irqdomain.h>
41460 #include <linux/i2c/twl.h>
41461 +#include <asm/pgtable.h>
41462
41463 #include "twl-core.h"
41464
41465 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
41466 * Install an irq handler for each of the SIH modules;
41467 * clone dummy irq_chip since PIH can't *do* anything
41468 */
41469 - twl4030_irq_chip = dummy_irq_chip;
41470 - twl4030_irq_chip.name = "twl4030";
41471 + pax_open_kernel();
41472 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
41473 + *(const char **)&twl4030_irq_chip.name = "twl4030";
41474
41475 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
41476 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
41477 + pax_close_kernel();
41478
41479 for (i = irq_base; i < irq_end; i++) {
41480 irq_set_chip_and_handler(i, &twl4030_irq_chip,
41481 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
41482 index 277a8db..0e0b754 100644
41483 --- a/drivers/mfd/twl6030-irq.c
41484 +++ b/drivers/mfd/twl6030-irq.c
41485 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
41486 * install an irq handler for each of the modules;
41487 * clone dummy irq_chip since PIH can't *do* anything
41488 */
41489 - twl6030_irq_chip = dummy_irq_chip;
41490 - twl6030_irq_chip.name = "twl6030";
41491 - twl6030_irq_chip.irq_set_type = NULL;
41492 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
41493 + pax_open_kernel();
41494 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
41495 + *(const char **)&twl6030_irq_chip.name = "twl6030";
41496 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
41497 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
41498 + pax_close_kernel();
41499
41500 for (i = irq_base; i < irq_end; i++) {
41501 irq_set_chip_and_handler(i, &twl6030_irq_chip,
41502 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
41503 index f32550a..e3e52a2 100644
41504 --- a/drivers/misc/c2port/core.c
41505 +++ b/drivers/misc/c2port/core.c
41506 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
41507 mutex_init(&c2dev->mutex);
41508
41509 /* Create binary file */
41510 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
41511 + pax_open_kernel();
41512 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
41513 + pax_close_kernel();
41514 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
41515 if (unlikely(ret))
41516 goto error_device_create_bin_file;
41517 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
41518 index 36f5d52..32311c3 100644
41519 --- a/drivers/misc/kgdbts.c
41520 +++ b/drivers/misc/kgdbts.c
41521 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
41522 char before[BREAK_INSTR_SIZE];
41523 char after[BREAK_INSTR_SIZE];
41524
41525 - probe_kernel_read(before, (char *)kgdbts_break_test,
41526 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
41527 BREAK_INSTR_SIZE);
41528 init_simple_test();
41529 ts.tst = plant_and_detach_test;
41530 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
41531 /* Activate test with initial breakpoint */
41532 if (!is_early)
41533 kgdb_breakpoint();
41534 - probe_kernel_read(after, (char *)kgdbts_break_test,
41535 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
41536 BREAK_INSTR_SIZE);
41537 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
41538 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
41539 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
41540 index 4cd4a3d..b48cbc7 100644
41541 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
41542 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
41543 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
41544 * the lid is closed. This leads to interrupts as soon as a little move
41545 * is done.
41546 */
41547 - atomic_inc(&lis3->count);
41548 + atomic_inc_unchecked(&lis3->count);
41549
41550 wake_up_interruptible(&lis3->misc_wait);
41551 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
41552 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
41553 if (lis3->pm_dev)
41554 pm_runtime_get_sync(lis3->pm_dev);
41555
41556 - atomic_set(&lis3->count, 0);
41557 + atomic_set_unchecked(&lis3->count, 0);
41558 return 0;
41559 }
41560
41561 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
41562 add_wait_queue(&lis3->misc_wait, &wait);
41563 while (true) {
41564 set_current_state(TASK_INTERRUPTIBLE);
41565 - data = atomic_xchg(&lis3->count, 0);
41566 + data = atomic_xchg_unchecked(&lis3->count, 0);
41567 if (data)
41568 break;
41569
41570 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
41571 struct lis3lv02d, miscdev);
41572
41573 poll_wait(file, &lis3->misc_wait, wait);
41574 - if (atomic_read(&lis3->count))
41575 + if (atomic_read_unchecked(&lis3->count))
41576 return POLLIN | POLLRDNORM;
41577 return 0;
41578 }
41579 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
41580 index c439c82..1f20f57 100644
41581 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
41582 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
41583 @@ -297,7 +297,7 @@ struct lis3lv02d {
41584 struct input_polled_dev *idev; /* input device */
41585 struct platform_device *pdev; /* platform device */
41586 struct regulator_bulk_data regulators[2];
41587 - atomic_t count; /* interrupt count after last read */
41588 + atomic_unchecked_t count; /* interrupt count after last read */
41589 union axis_conversion ac; /* hw -> logical axis */
41590 int mapped_btns[3];
41591
41592 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
41593 index 2f30bad..c4c13d0 100644
41594 --- a/drivers/misc/sgi-gru/gruhandles.c
41595 +++ b/drivers/misc/sgi-gru/gruhandles.c
41596 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
41597 unsigned long nsec;
41598
41599 nsec = CLKS2NSEC(clks);
41600 - atomic_long_inc(&mcs_op_statistics[op].count);
41601 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
41602 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
41603 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
41604 if (mcs_op_statistics[op].max < nsec)
41605 mcs_op_statistics[op].max = nsec;
41606 }
41607 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
41608 index 797d796..ae8f01e 100644
41609 --- a/drivers/misc/sgi-gru/gruprocfs.c
41610 +++ b/drivers/misc/sgi-gru/gruprocfs.c
41611 @@ -32,9 +32,9 @@
41612
41613 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
41614
41615 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
41616 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
41617 {
41618 - unsigned long val = atomic_long_read(v);
41619 + unsigned long val = atomic_long_read_unchecked(v);
41620
41621 seq_printf(s, "%16lu %s\n", val, id);
41622 }
41623 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
41624
41625 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
41626 for (op = 0; op < mcsop_last; op++) {
41627 - count = atomic_long_read(&mcs_op_statistics[op].count);
41628 - total = atomic_long_read(&mcs_op_statistics[op].total);
41629 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
41630 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
41631 max = mcs_op_statistics[op].max;
41632 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
41633 count ? total / count : 0, max);
41634 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
41635 index 5c3ce24..4915ccb 100644
41636 --- a/drivers/misc/sgi-gru/grutables.h
41637 +++ b/drivers/misc/sgi-gru/grutables.h
41638 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
41639 * GRU statistics.
41640 */
41641 struct gru_stats_s {
41642 - atomic_long_t vdata_alloc;
41643 - atomic_long_t vdata_free;
41644 - atomic_long_t gts_alloc;
41645 - atomic_long_t gts_free;
41646 - atomic_long_t gms_alloc;
41647 - atomic_long_t gms_free;
41648 - atomic_long_t gts_double_allocate;
41649 - atomic_long_t assign_context;
41650 - atomic_long_t assign_context_failed;
41651 - atomic_long_t free_context;
41652 - atomic_long_t load_user_context;
41653 - atomic_long_t load_kernel_context;
41654 - atomic_long_t lock_kernel_context;
41655 - atomic_long_t unlock_kernel_context;
41656 - atomic_long_t steal_user_context;
41657 - atomic_long_t steal_kernel_context;
41658 - atomic_long_t steal_context_failed;
41659 - atomic_long_t nopfn;
41660 - atomic_long_t asid_new;
41661 - atomic_long_t asid_next;
41662 - atomic_long_t asid_wrap;
41663 - atomic_long_t asid_reuse;
41664 - atomic_long_t intr;
41665 - atomic_long_t intr_cbr;
41666 - atomic_long_t intr_tfh;
41667 - atomic_long_t intr_spurious;
41668 - atomic_long_t intr_mm_lock_failed;
41669 - atomic_long_t call_os;
41670 - atomic_long_t call_os_wait_queue;
41671 - atomic_long_t user_flush_tlb;
41672 - atomic_long_t user_unload_context;
41673 - atomic_long_t user_exception;
41674 - atomic_long_t set_context_option;
41675 - atomic_long_t check_context_retarget_intr;
41676 - atomic_long_t check_context_unload;
41677 - atomic_long_t tlb_dropin;
41678 - atomic_long_t tlb_preload_page;
41679 - atomic_long_t tlb_dropin_fail_no_asid;
41680 - atomic_long_t tlb_dropin_fail_upm;
41681 - atomic_long_t tlb_dropin_fail_invalid;
41682 - atomic_long_t tlb_dropin_fail_range_active;
41683 - atomic_long_t tlb_dropin_fail_idle;
41684 - atomic_long_t tlb_dropin_fail_fmm;
41685 - atomic_long_t tlb_dropin_fail_no_exception;
41686 - atomic_long_t tfh_stale_on_fault;
41687 - atomic_long_t mmu_invalidate_range;
41688 - atomic_long_t mmu_invalidate_page;
41689 - atomic_long_t flush_tlb;
41690 - atomic_long_t flush_tlb_gru;
41691 - atomic_long_t flush_tlb_gru_tgh;
41692 - atomic_long_t flush_tlb_gru_zero_asid;
41693 + atomic_long_unchecked_t vdata_alloc;
41694 + atomic_long_unchecked_t vdata_free;
41695 + atomic_long_unchecked_t gts_alloc;
41696 + atomic_long_unchecked_t gts_free;
41697 + atomic_long_unchecked_t gms_alloc;
41698 + atomic_long_unchecked_t gms_free;
41699 + atomic_long_unchecked_t gts_double_allocate;
41700 + atomic_long_unchecked_t assign_context;
41701 + atomic_long_unchecked_t assign_context_failed;
41702 + atomic_long_unchecked_t free_context;
41703 + atomic_long_unchecked_t load_user_context;
41704 + atomic_long_unchecked_t load_kernel_context;
41705 + atomic_long_unchecked_t lock_kernel_context;
41706 + atomic_long_unchecked_t unlock_kernel_context;
41707 + atomic_long_unchecked_t steal_user_context;
41708 + atomic_long_unchecked_t steal_kernel_context;
41709 + atomic_long_unchecked_t steal_context_failed;
41710 + atomic_long_unchecked_t nopfn;
41711 + atomic_long_unchecked_t asid_new;
41712 + atomic_long_unchecked_t asid_next;
41713 + atomic_long_unchecked_t asid_wrap;
41714 + atomic_long_unchecked_t asid_reuse;
41715 + atomic_long_unchecked_t intr;
41716 + atomic_long_unchecked_t intr_cbr;
41717 + atomic_long_unchecked_t intr_tfh;
41718 + atomic_long_unchecked_t intr_spurious;
41719 + atomic_long_unchecked_t intr_mm_lock_failed;
41720 + atomic_long_unchecked_t call_os;
41721 + atomic_long_unchecked_t call_os_wait_queue;
41722 + atomic_long_unchecked_t user_flush_tlb;
41723 + atomic_long_unchecked_t user_unload_context;
41724 + atomic_long_unchecked_t user_exception;
41725 + atomic_long_unchecked_t set_context_option;
41726 + atomic_long_unchecked_t check_context_retarget_intr;
41727 + atomic_long_unchecked_t check_context_unload;
41728 + atomic_long_unchecked_t tlb_dropin;
41729 + atomic_long_unchecked_t tlb_preload_page;
41730 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
41731 + atomic_long_unchecked_t tlb_dropin_fail_upm;
41732 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
41733 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
41734 + atomic_long_unchecked_t tlb_dropin_fail_idle;
41735 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
41736 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
41737 + atomic_long_unchecked_t tfh_stale_on_fault;
41738 + atomic_long_unchecked_t mmu_invalidate_range;
41739 + atomic_long_unchecked_t mmu_invalidate_page;
41740 + atomic_long_unchecked_t flush_tlb;
41741 + atomic_long_unchecked_t flush_tlb_gru;
41742 + atomic_long_unchecked_t flush_tlb_gru_tgh;
41743 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
41744
41745 - atomic_long_t copy_gpa;
41746 - atomic_long_t read_gpa;
41747 + atomic_long_unchecked_t copy_gpa;
41748 + atomic_long_unchecked_t read_gpa;
41749
41750 - atomic_long_t mesq_receive;
41751 - atomic_long_t mesq_receive_none;
41752 - atomic_long_t mesq_send;
41753 - atomic_long_t mesq_send_failed;
41754 - atomic_long_t mesq_noop;
41755 - atomic_long_t mesq_send_unexpected_error;
41756 - atomic_long_t mesq_send_lb_overflow;
41757 - atomic_long_t mesq_send_qlimit_reached;
41758 - atomic_long_t mesq_send_amo_nacked;
41759 - atomic_long_t mesq_send_put_nacked;
41760 - atomic_long_t mesq_page_overflow;
41761 - atomic_long_t mesq_qf_locked;
41762 - atomic_long_t mesq_qf_noop_not_full;
41763 - atomic_long_t mesq_qf_switch_head_failed;
41764 - atomic_long_t mesq_qf_unexpected_error;
41765 - atomic_long_t mesq_noop_unexpected_error;
41766 - atomic_long_t mesq_noop_lb_overflow;
41767 - atomic_long_t mesq_noop_qlimit_reached;
41768 - atomic_long_t mesq_noop_amo_nacked;
41769 - atomic_long_t mesq_noop_put_nacked;
41770 - atomic_long_t mesq_noop_page_overflow;
41771 + atomic_long_unchecked_t mesq_receive;
41772 + atomic_long_unchecked_t mesq_receive_none;
41773 + atomic_long_unchecked_t mesq_send;
41774 + atomic_long_unchecked_t mesq_send_failed;
41775 + atomic_long_unchecked_t mesq_noop;
41776 + atomic_long_unchecked_t mesq_send_unexpected_error;
41777 + atomic_long_unchecked_t mesq_send_lb_overflow;
41778 + atomic_long_unchecked_t mesq_send_qlimit_reached;
41779 + atomic_long_unchecked_t mesq_send_amo_nacked;
41780 + atomic_long_unchecked_t mesq_send_put_nacked;
41781 + atomic_long_unchecked_t mesq_page_overflow;
41782 + atomic_long_unchecked_t mesq_qf_locked;
41783 + atomic_long_unchecked_t mesq_qf_noop_not_full;
41784 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
41785 + atomic_long_unchecked_t mesq_qf_unexpected_error;
41786 + atomic_long_unchecked_t mesq_noop_unexpected_error;
41787 + atomic_long_unchecked_t mesq_noop_lb_overflow;
41788 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
41789 + atomic_long_unchecked_t mesq_noop_amo_nacked;
41790 + atomic_long_unchecked_t mesq_noop_put_nacked;
41791 + atomic_long_unchecked_t mesq_noop_page_overflow;
41792
41793 };
41794
41795 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
41796 tghop_invalidate, mcsop_last};
41797
41798 struct mcs_op_statistic {
41799 - atomic_long_t count;
41800 - atomic_long_t total;
41801 + atomic_long_unchecked_t count;
41802 + atomic_long_unchecked_t total;
41803 unsigned long max;
41804 };
41805
41806 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
41807
41808 #define STAT(id) do { \
41809 if (gru_options & OPT_STATS) \
41810 - atomic_long_inc(&gru_stats.id); \
41811 + atomic_long_inc_unchecked(&gru_stats.id); \
41812 } while (0)
41813
41814 #ifdef CONFIG_SGI_GRU_DEBUG
41815 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
41816 index c862cd4..0d176fe 100644
41817 --- a/drivers/misc/sgi-xp/xp.h
41818 +++ b/drivers/misc/sgi-xp/xp.h
41819 @@ -288,7 +288,7 @@ struct xpc_interface {
41820 xpc_notify_func, void *);
41821 void (*received) (short, int, void *);
41822 enum xp_retval (*partid_to_nasids) (short, void *);
41823 -};
41824 +} __no_const;
41825
41826 extern struct xpc_interface xpc_interface;
41827
41828 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
41829 index b94d5f7..7f494c5 100644
41830 --- a/drivers/misc/sgi-xp/xpc.h
41831 +++ b/drivers/misc/sgi-xp/xpc.h
41832 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
41833 void (*received_payload) (struct xpc_channel *, void *);
41834 void (*notify_senders_of_disconnect) (struct xpc_channel *);
41835 };
41836 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
41837
41838 /* struct xpc_partition act_state values (for XPC HB) */
41839
41840 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
41841 /* found in xpc_main.c */
41842 extern struct device *xpc_part;
41843 extern struct device *xpc_chan;
41844 -extern struct xpc_arch_operations xpc_arch_ops;
41845 +extern xpc_arch_operations_no_const xpc_arch_ops;
41846 extern int xpc_disengage_timelimit;
41847 extern int xpc_disengage_timedout;
41848 extern int xpc_activate_IRQ_rcvd;
41849 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
41850 index d971817..33bdca5 100644
41851 --- a/drivers/misc/sgi-xp/xpc_main.c
41852 +++ b/drivers/misc/sgi-xp/xpc_main.c
41853 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
41854 .notifier_call = xpc_system_die,
41855 };
41856
41857 -struct xpc_arch_operations xpc_arch_ops;
41858 +xpc_arch_operations_no_const xpc_arch_ops;
41859
41860 /*
41861 * Timer function to enforce the timelimit on the partition disengage.
41862 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
41863
41864 if (((die_args->trapnr == X86_TRAP_MF) ||
41865 (die_args->trapnr == X86_TRAP_XF)) &&
41866 - !user_mode_vm(die_args->regs))
41867 + !user_mode(die_args->regs))
41868 xpc_die_deactivate();
41869
41870 break;
41871 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
41872 index 49f04bc..65660c2 100644
41873 --- a/drivers/mmc/core/mmc_ops.c
41874 +++ b/drivers/mmc/core/mmc_ops.c
41875 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
41876 void *data_buf;
41877 int is_on_stack;
41878
41879 - is_on_stack = object_is_on_stack(buf);
41880 + is_on_stack = object_starts_on_stack(buf);
41881 if (is_on_stack) {
41882 /*
41883 * dma onto stack is unsafe/nonportable, but callers to this
41884 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
41885 index 0b74189..818358f 100644
41886 --- a/drivers/mmc/host/dw_mmc.h
41887 +++ b/drivers/mmc/host/dw_mmc.h
41888 @@ -202,5 +202,5 @@ struct dw_mci_drv_data {
41889 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
41890 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
41891 int (*parse_dt)(struct dw_mci *host);
41892 -};
41893 +} __do_const;
41894 #endif /* _DW_MMC_H_ */
41895 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
41896 index c6f6246..60760a8 100644
41897 --- a/drivers/mmc/host/sdhci-s3c.c
41898 +++ b/drivers/mmc/host/sdhci-s3c.c
41899 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
41900 * we can use overriding functions instead of default.
41901 */
41902 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
41903 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
41904 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
41905 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
41906 + pax_open_kernel();
41907 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
41908 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
41909 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
41910 + pax_close_kernel();
41911 }
41912
41913 /* It supports additional host capabilities if needed */
41914 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
41915 index 0c8bb6b..6f35deb 100644
41916 --- a/drivers/mtd/nand/denali.c
41917 +++ b/drivers/mtd/nand/denali.c
41918 @@ -24,6 +24,7 @@
41919 #include <linux/slab.h>
41920 #include <linux/mtd/mtd.h>
41921 #include <linux/module.h>
41922 +#include <linux/slab.h>
41923
41924 #include "denali.h"
41925
41926 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
41927 index 51b9d6a..52af9a7 100644
41928 --- a/drivers/mtd/nftlmount.c
41929 +++ b/drivers/mtd/nftlmount.c
41930 @@ -24,6 +24,7 @@
41931 #include <asm/errno.h>
41932 #include <linux/delay.h>
41933 #include <linux/slab.h>
41934 +#include <linux/sched.h>
41935 #include <linux/mtd/mtd.h>
41936 #include <linux/mtd/nand.h>
41937 #include <linux/mtd/nftl.h>
41938 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
41939 index f9d5615..99dd95f 100644
41940 --- a/drivers/mtd/sm_ftl.c
41941 +++ b/drivers/mtd/sm_ftl.c
41942 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
41943 #define SM_CIS_VENDOR_OFFSET 0x59
41944 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
41945 {
41946 - struct attribute_group *attr_group;
41947 + attribute_group_no_const *attr_group;
41948 struct attribute **attributes;
41949 struct sm_sysfs_attribute *vendor_attribute;
41950
41951 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
41952 index f975696..4597e21 100644
41953 --- a/drivers/net/bonding/bond_main.c
41954 +++ b/drivers/net/bonding/bond_main.c
41955 @@ -4870,7 +4870,7 @@ static unsigned int bond_get_num_tx_queues(void)
41956 return tx_queues;
41957 }
41958
41959 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
41960 +static struct rtnl_link_ops bond_link_ops = {
41961 .kind = "bond",
41962 .priv_size = sizeof(struct bonding),
41963 .setup = bond_setup,
41964 @@ -4995,8 +4995,8 @@ static void __exit bonding_exit(void)
41965
41966 bond_destroy_debugfs();
41967
41968 - rtnl_link_unregister(&bond_link_ops);
41969 unregister_pernet_subsys(&bond_net_ops);
41970 + rtnl_link_unregister(&bond_link_ops);
41971
41972 #ifdef CONFIG_NET_POLL_CONTROLLER
41973 /*
41974 diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
41975 index 25723d8..925ab8e 100644
41976 --- a/drivers/net/can/usb/peak_usb/pcan_usb.c
41977 +++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
41978 @@ -649,7 +649,7 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
41979 if ((mc->ptr + rec_len) > mc->end)
41980 goto decode_failed;
41981
41982 - memcpy(cf->data, mc->ptr, rec_len);
41983 + memcpy(cf->data, mc->ptr, cf->can_dlc);
41984 mc->ptr += rec_len;
41985 }
41986
41987 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
41988 index e1d2643..7f4133b 100644
41989 --- a/drivers/net/ethernet/8390/ax88796.c
41990 +++ b/drivers/net/ethernet/8390/ax88796.c
41991 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
41992 if (ax->plat->reg_offsets)
41993 ei_local->reg_offset = ax->plat->reg_offsets;
41994 else {
41995 + resource_size_t _mem_size = mem_size;
41996 + do_div(_mem_size, 0x18);
41997 ei_local->reg_offset = ax->reg_offsets;
41998 for (ret = 0; ret < 0x18; ret++)
41999 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
42000 + ax->reg_offsets[ret] = _mem_size * ret;
42001 }
42002
42003 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
42004 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
42005 index 151675d..0139a9d 100644
42006 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
42007 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
42008 @@ -1112,7 +1112,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
42009 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
42010 {
42011 /* RX_MODE controlling object */
42012 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
42013 + bnx2x_init_rx_mode_obj(bp);
42014
42015 /* multicast configuration controlling object */
42016 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
42017 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
42018 index ce1a916..10b52b0 100644
42019 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
42020 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
42021 @@ -960,6 +960,9 @@ static int bnx2x_set_dump(struct net_device *dev, struct ethtool_dump *val)
42022 struct bnx2x *bp = netdev_priv(dev);
42023
42024 /* Use the ethtool_dump "flag" field as the dump preset index */
42025 + if (val->flag < 1 || val->flag > DUMP_MAX_PRESETS)
42026 + return -EINVAL;
42027 +
42028 bp->dump_preset_idx = val->flag;
42029 return 0;
42030 }
42031 @@ -986,8 +989,6 @@ static int bnx2x_get_dump_data(struct net_device *dev,
42032 struct bnx2x *bp = netdev_priv(dev);
42033 struct dump_header dump_hdr = {0};
42034
42035 - memset(p, 0, dump->len);
42036 -
42037 /* Disable parity attentions as long as following dump may
42038 * cause false alarms by reading never written registers. We
42039 * will re-enable parity attentions right after the dump.
42040 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
42041 index b4c9dea..2a9927f 100644
42042 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
42043 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
42044 @@ -11497,6 +11497,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
42045 bp->min_msix_vec_cnt = 2;
42046 BNX2X_DEV_INFO("bp->min_msix_vec_cnt %d", bp->min_msix_vec_cnt);
42047
42048 + bp->dump_preset_idx = 1;
42049 +
42050 return rc;
42051 }
42052
42053 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
42054 index 32a9609..0b1c53a 100644
42055 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
42056 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
42057 @@ -2387,15 +2387,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
42058 return rc;
42059 }
42060
42061 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
42062 - struct bnx2x_rx_mode_obj *o)
42063 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
42064 {
42065 if (CHIP_IS_E1x(bp)) {
42066 - o->wait_comp = bnx2x_empty_rx_mode_wait;
42067 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
42068 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
42069 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
42070 } else {
42071 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
42072 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
42073 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
42074 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
42075 }
42076 }
42077
42078 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
42079 index 43c00bc..dd1d03d 100644
42080 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
42081 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
42082 @@ -1321,8 +1321,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
42083
42084 /********************* RX MODE ****************/
42085
42086 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
42087 - struct bnx2x_rx_mode_obj *o);
42088 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
42089
42090 /**
42091 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
42092 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
42093 index ff6e30e..87e8452 100644
42094 --- a/drivers/net/ethernet/broadcom/tg3.h
42095 +++ b/drivers/net/ethernet/broadcom/tg3.h
42096 @@ -147,6 +147,7 @@
42097 #define CHIPREV_ID_5750_A0 0x4000
42098 #define CHIPREV_ID_5750_A1 0x4001
42099 #define CHIPREV_ID_5750_A3 0x4003
42100 +#define CHIPREV_ID_5750_C1 0x4201
42101 #define CHIPREV_ID_5750_C2 0x4202
42102 #define CHIPREV_ID_5752_A0_HW 0x5000
42103 #define CHIPREV_ID_5752_A0 0x6000
42104 diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
42105 index 71497e8..b650951 100644
42106 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
42107 +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
42108 @@ -3037,7 +3037,9 @@ static void t3_io_resume(struct pci_dev *pdev)
42109 CH_ALERT(adapter, "adapter recovering, PEX ERR 0x%x\n",
42110 t3_read_reg(adapter, A_PCIE_PEX_ERR));
42111
42112 + rtnl_lock();
42113 t3_resume_ports(adapter);
42114 + rtnl_unlock();
42115 }
42116
42117 static const struct pci_error_handlers t3_err_handler = {
42118 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
42119 index 8cffcdf..aadf043 100644
42120 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
42121 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
42122 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
42123 */
42124 struct l2t_skb_cb {
42125 arp_failure_handler_func arp_failure_handler;
42126 -};
42127 +} __no_const;
42128
42129 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
42130
42131 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
42132 index 4c83003..2a2a5b9 100644
42133 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
42134 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
42135 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
42136 for (i=0; i<ETH_ALEN; i++) {
42137 tmp.addr[i] = dev->dev_addr[i];
42138 }
42139 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
42140 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
42141 break;
42142
42143 case DE4X5_SET_HWADDR: /* Set the hardware address */
42144 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
42145 spin_lock_irqsave(&lp->lock, flags);
42146 memcpy(&statbuf, &lp->pktStats, ioc->len);
42147 spin_unlock_irqrestore(&lp->lock, flags);
42148 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
42149 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
42150 return -EFAULT;
42151 break;
42152 }
42153 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
42154 index 6e43426..1bd8365 100644
42155 --- a/drivers/net/ethernet/emulex/benet/be_main.c
42156 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
42157 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
42158
42159 if (wrapped)
42160 newacc += 65536;
42161 - ACCESS_ONCE(*acc) = newacc;
42162 + ACCESS_ONCE_RW(*acc) = newacc;
42163 }
42164
42165 void populate_erx_stats(struct be_adapter *adapter,
42166 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
42167 index 21b85fb..b49e5fc 100644
42168 --- a/drivers/net/ethernet/faraday/ftgmac100.c
42169 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
42170 @@ -31,6 +31,8 @@
42171 #include <linux/netdevice.h>
42172 #include <linux/phy.h>
42173 #include <linux/platform_device.h>
42174 +#include <linux/interrupt.h>
42175 +#include <linux/irqreturn.h>
42176 #include <net/ip.h>
42177
42178 #include "ftgmac100.h"
42179 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
42180 index a6eda8d..935d273 100644
42181 --- a/drivers/net/ethernet/faraday/ftmac100.c
42182 +++ b/drivers/net/ethernet/faraday/ftmac100.c
42183 @@ -31,6 +31,8 @@
42184 #include <linux/module.h>
42185 #include <linux/netdevice.h>
42186 #include <linux/platform_device.h>
42187 +#include <linux/interrupt.h>
42188 +#include <linux/irqreturn.h>
42189
42190 #include "ftmac100.h"
42191
42192 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
42193 index 331987d..3be1135 100644
42194 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
42195 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
42196 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
42197 }
42198
42199 /* update the base incval used to calculate frequency adjustment */
42200 - ACCESS_ONCE(adapter->base_incval) = incval;
42201 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
42202 smp_mb();
42203
42204 /* need lock to prevent incorrect read while modifying cyclecounter */
42205 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
42206 index fbe5363..266b4e3 100644
42207 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
42208 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
42209 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
42210 struct __vxge_hw_fifo *fifo;
42211 struct vxge_hw_fifo_config *config;
42212 u32 txdl_size, txdl_per_memblock;
42213 - struct vxge_hw_mempool_cbs fifo_mp_callback;
42214 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
42215 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
42216 + };
42217 +
42218 struct __vxge_hw_virtualpath *vpath;
42219
42220 if ((vp == NULL) || (attr == NULL)) {
42221 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
42222 goto exit;
42223 }
42224
42225 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
42226 -
42227 fifo->mempool =
42228 __vxge_hw_mempool_create(vpath->hldev,
42229 fifo->config->memblock_size,
42230 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
42231 index 5e7fb1d..f8d1810 100644
42232 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
42233 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
42234 @@ -1948,7 +1948,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
42235 op_mode = QLC_83XX_DEFAULT_OPMODE;
42236
42237 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
42238 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
42239 + pax_open_kernel();
42240 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
42241 + pax_close_kernel();
42242 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
42243 } else {
42244 return -EIO;
42245 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
42246 index b0c3de9..fc5857e 100644
42247 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
42248 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
42249 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
42250 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
42251 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
42252 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
42253 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
42254 + pax_open_kernel();
42255 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
42256 + pax_close_kernel();
42257 } else if (priv_level == QLCNIC_PRIV_FUNC) {
42258 ahw->op_mode = QLCNIC_PRIV_FUNC;
42259 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
42260 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
42261 + pax_open_kernel();
42262 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
42263 + pax_close_kernel();
42264 } else if (priv_level == QLCNIC_MGMT_FUNC) {
42265 ahw->op_mode = QLCNIC_MGMT_FUNC;
42266 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
42267 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
42268 + pax_open_kernel();
42269 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
42270 + pax_close_kernel();
42271 } else {
42272 return -EIO;
42273 }
42274 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
42275 index 6acf82b..14b097e 100644
42276 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
42277 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
42278 @@ -206,10 +206,10 @@ int qlcnic_fw_cmd_set_drv_version(struct qlcnic_adapter *adapter)
42279 if (err) {
42280 dev_info(&adapter->pdev->dev,
42281 "Failed to set driver version in firmware\n");
42282 - return -EIO;
42283 + err = -EIO;
42284 }
42285 -
42286 - return 0;
42287 + qlcnic_free_mbx_args(&cmd);
42288 + return err;
42289 }
42290
42291 int
42292 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
42293 index d3f8797..82a03d3 100644
42294 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
42295 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
42296 @@ -262,7 +262,7 @@ void qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter, u64 *uaddr,
42297
42298 mac_req = (struct qlcnic_mac_req *)&(req->words[0]);
42299 mac_req->op = vlan_id ? QLCNIC_MAC_VLAN_ADD : QLCNIC_MAC_ADD;
42300 - memcpy(mac_req->mac_addr, &uaddr, ETH_ALEN);
42301 + memcpy(mac_req->mac_addr, uaddr, ETH_ALEN);
42302
42303 vlan_req = (struct qlcnic_vlan_req *)&req->words[1];
42304 vlan_req->vlan_id = cpu_to_le16(vlan_id);
42305 diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
42306 index 887aebe..9095ff9 100644
42307 --- a/drivers/net/ethernet/realtek/8139cp.c
42308 +++ b/drivers/net/ethernet/realtek/8139cp.c
42309 @@ -524,6 +524,7 @@ rx_status_loop:
42310 PCI_DMA_FROMDEVICE);
42311 if (dma_mapping_error(&cp->pdev->dev, new_mapping)) {
42312 dev->stats.rx_dropped++;
42313 + kfree_skb(new_skb);
42314 goto rx_next;
42315 }
42316
42317 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
42318 index 393f961..d343034 100644
42319 --- a/drivers/net/ethernet/realtek/r8169.c
42320 +++ b/drivers/net/ethernet/realtek/r8169.c
42321 @@ -753,22 +753,22 @@ struct rtl8169_private {
42322 struct mdio_ops {
42323 void (*write)(struct rtl8169_private *, int, int);
42324 int (*read)(struct rtl8169_private *, int);
42325 - } mdio_ops;
42326 + } __no_const mdio_ops;
42327
42328 struct pll_power_ops {
42329 void (*down)(struct rtl8169_private *);
42330 void (*up)(struct rtl8169_private *);
42331 - } pll_power_ops;
42332 + } __no_const pll_power_ops;
42333
42334 struct jumbo_ops {
42335 void (*enable)(struct rtl8169_private *);
42336 void (*disable)(struct rtl8169_private *);
42337 - } jumbo_ops;
42338 + } __no_const jumbo_ops;
42339
42340 struct csi_ops {
42341 void (*write)(struct rtl8169_private *, int, int);
42342 u32 (*read)(struct rtl8169_private *, int);
42343 - } csi_ops;
42344 + } __no_const csi_ops;
42345
42346 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
42347 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
42348 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
42349 index 9a95abf..36df7f9 100644
42350 --- a/drivers/net/ethernet/sfc/ptp.c
42351 +++ b/drivers/net/ethernet/sfc/ptp.c
42352 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
42353 (u32)((u64)ptp->start.dma_addr >> 32));
42354
42355 /* Clear flag that signals MC ready */
42356 - ACCESS_ONCE(*start) = 0;
42357 + ACCESS_ONCE_RW(*start) = 0;
42358 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
42359 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
42360
42361 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
42362 index 50617c5..b13724c 100644
42363 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
42364 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
42365 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
42366
42367 writel(value, ioaddr + MMC_CNTRL);
42368
42369 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
42370 - MMC_CNTRL, value);
42371 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
42372 +// MMC_CNTRL, value);
42373 }
42374
42375 /* To mask all all interrupts.*/
42376 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
42377 index e6fe0d8..2b7d752 100644
42378 --- a/drivers/net/hyperv/hyperv_net.h
42379 +++ b/drivers/net/hyperv/hyperv_net.h
42380 @@ -101,7 +101,7 @@ struct rndis_device {
42381
42382 enum rndis_device_state state;
42383 bool link_state;
42384 - atomic_t new_req_id;
42385 + atomic_unchecked_t new_req_id;
42386
42387 spinlock_t request_lock;
42388 struct list_head req_list;
42389 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
42390 index 0775f0a..d4fb316 100644
42391 --- a/drivers/net/hyperv/rndis_filter.c
42392 +++ b/drivers/net/hyperv/rndis_filter.c
42393 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
42394 * template
42395 */
42396 set = &rndis_msg->msg.set_req;
42397 - set->req_id = atomic_inc_return(&dev->new_req_id);
42398 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
42399
42400 /* Add to the request list */
42401 spin_lock_irqsave(&dev->request_lock, flags);
42402 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
42403
42404 /* Setup the rndis set */
42405 halt = &request->request_msg.msg.halt_req;
42406 - halt->req_id = atomic_inc_return(&dev->new_req_id);
42407 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
42408
42409 /* Ignore return since this msg is optional. */
42410 rndis_filter_send_request(dev, request);
42411 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
42412 index bf0d55e..82bcfbd1 100644
42413 --- a/drivers/net/ieee802154/fakehard.c
42414 +++ b/drivers/net/ieee802154/fakehard.c
42415 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
42416 phy->transmit_power = 0xbf;
42417
42418 dev->netdev_ops = &fake_ops;
42419 - dev->ml_priv = &fake_mlme;
42420 + dev->ml_priv = (void *)&fake_mlme;
42421
42422 priv = netdev_priv(dev);
42423 priv->phy = phy;
42424 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
42425 index 6e91931..2b0ebe7 100644
42426 --- a/drivers/net/macvlan.c
42427 +++ b/drivers/net/macvlan.c
42428 @@ -905,13 +905,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
42429 int macvlan_link_register(struct rtnl_link_ops *ops)
42430 {
42431 /* common fields */
42432 - ops->priv_size = sizeof(struct macvlan_dev);
42433 - ops->validate = macvlan_validate;
42434 - ops->maxtype = IFLA_MACVLAN_MAX;
42435 - ops->policy = macvlan_policy;
42436 - ops->changelink = macvlan_changelink;
42437 - ops->get_size = macvlan_get_size;
42438 - ops->fill_info = macvlan_fill_info;
42439 + pax_open_kernel();
42440 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
42441 + *(void **)&ops->validate = macvlan_validate;
42442 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
42443 + *(const void **)&ops->policy = macvlan_policy;
42444 + *(void **)&ops->changelink = macvlan_changelink;
42445 + *(void **)&ops->get_size = macvlan_get_size;
42446 + *(void **)&ops->fill_info = macvlan_fill_info;
42447 + pax_close_kernel();
42448
42449 return rtnl_link_register(ops);
42450 };
42451 @@ -967,7 +969,7 @@ static int macvlan_device_event(struct notifier_block *unused,
42452 return NOTIFY_DONE;
42453 }
42454
42455 -static struct notifier_block macvlan_notifier_block __read_mostly = {
42456 +static struct notifier_block macvlan_notifier_block = {
42457 .notifier_call = macvlan_device_event,
42458 };
42459
42460 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
42461 index 523d6b2..5e16aa1 100644
42462 --- a/drivers/net/macvtap.c
42463 +++ b/drivers/net/macvtap.c
42464 @@ -1110,7 +1110,7 @@ static int macvtap_device_event(struct notifier_block *unused,
42465 return NOTIFY_DONE;
42466 }
42467
42468 -static struct notifier_block macvtap_notifier_block __read_mostly = {
42469 +static struct notifier_block macvtap_notifier_block = {
42470 .notifier_call = macvtap_device_event,
42471 };
42472
42473 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
42474 index daec9b0..6428fcb 100644
42475 --- a/drivers/net/phy/mdio-bitbang.c
42476 +++ b/drivers/net/phy/mdio-bitbang.c
42477 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
42478 struct mdiobb_ctrl *ctrl = bus->priv;
42479
42480 module_put(ctrl->ops->owner);
42481 + mdiobus_unregister(bus);
42482 mdiobus_free(bus);
42483 }
42484 EXPORT_SYMBOL(free_mdio_bitbang);
42485 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
42486 index 72ff14b..11d442d 100644
42487 --- a/drivers/net/ppp/ppp_generic.c
42488 +++ b/drivers/net/ppp/ppp_generic.c
42489 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42490 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
42491 struct ppp_stats stats;
42492 struct ppp_comp_stats cstats;
42493 - char *vers;
42494
42495 switch (cmd) {
42496 case SIOCGPPPSTATS:
42497 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42498 break;
42499
42500 case SIOCGPPPVER:
42501 - vers = PPP_VERSION;
42502 - if (copy_to_user(addr, vers, strlen(vers) + 1))
42503 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
42504 break;
42505 err = 0;
42506 break;
42507 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
42508 index 1252d9c..80e660b 100644
42509 --- a/drivers/net/slip/slhc.c
42510 +++ b/drivers/net/slip/slhc.c
42511 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
42512 register struct tcphdr *thp;
42513 register struct iphdr *ip;
42514 register struct cstate *cs;
42515 - int len, hdrlen;
42516 + long len, hdrlen;
42517 unsigned char *cp = icp;
42518
42519 /* We've got a compressed packet; read the change byte */
42520 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
42521 index b305105..8ead6df 100644
42522 --- a/drivers/net/team/team.c
42523 +++ b/drivers/net/team/team.c
42524 @@ -2682,7 +2682,7 @@ static int team_device_event(struct notifier_block *unused,
42525 return NOTIFY_DONE;
42526 }
42527
42528 -static struct notifier_block team_notifier_block __read_mostly = {
42529 +static struct notifier_block team_notifier_block = {
42530 .notifier_call = team_device_event,
42531 };
42532
42533 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
42534 index 2491eb2..1a453eb 100644
42535 --- a/drivers/net/tun.c
42536 +++ b/drivers/net/tun.c
42537 @@ -1076,8 +1076,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
42538 u32 rxhash;
42539
42540 if (!(tun->flags & TUN_NO_PI)) {
42541 - if ((len -= sizeof(pi)) > total_len)
42542 + if (len < sizeof(pi))
42543 return -EINVAL;
42544 + len -= sizeof(pi);
42545
42546 if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi)))
42547 return -EFAULT;
42548 @@ -1085,8 +1086,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
42549 }
42550
42551 if (tun->flags & TUN_VNET_HDR) {
42552 - if ((len -= tun->vnet_hdr_sz) > total_len)
42553 + if (len < tun->vnet_hdr_sz)
42554 return -EINVAL;
42555 + len -= tun->vnet_hdr_sz;
42556
42557 if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))
42558 return -EFAULT;
42559 @@ -1869,7 +1871,7 @@ unlock:
42560 }
42561
42562 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
42563 - unsigned long arg, int ifreq_len)
42564 + unsigned long arg, size_t ifreq_len)
42565 {
42566 struct tun_file *tfile = file->private_data;
42567 struct tun_struct *tun;
42568 @@ -1881,6 +1883,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
42569 int vnet_hdr_sz;
42570 int ret;
42571
42572 + if (ifreq_len > sizeof ifr)
42573 + return -EFAULT;
42574 +
42575 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
42576 if (copy_from_user(&ifr, argp, ifreq_len))
42577 return -EFAULT;
42578 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
42579 index cba1d46..f703766 100644
42580 --- a/drivers/net/usb/hso.c
42581 +++ b/drivers/net/usb/hso.c
42582 @@ -71,7 +71,7 @@
42583 #include <asm/byteorder.h>
42584 #include <linux/serial_core.h>
42585 #include <linux/serial.h>
42586 -
42587 +#include <asm/local.h>
42588
42589 #define MOD_AUTHOR "Option Wireless"
42590 #define MOD_DESCRIPTION "USB High Speed Option driver"
42591 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
42592 struct urb *urb;
42593
42594 urb = serial->rx_urb[0];
42595 - if (serial->port.count > 0) {
42596 + if (atomic_read(&serial->port.count) > 0) {
42597 count = put_rxbuf_data(urb, serial);
42598 if (count == -1)
42599 return;
42600 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
42601 DUMP1(urb->transfer_buffer, urb->actual_length);
42602
42603 /* Anyone listening? */
42604 - if (serial->port.count == 0)
42605 + if (atomic_read(&serial->port.count) == 0)
42606 return;
42607
42608 if (status == 0) {
42609 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
42610 tty_port_tty_set(&serial->port, tty);
42611
42612 /* check for port already opened, if not set the termios */
42613 - serial->port.count++;
42614 - if (serial->port.count == 1) {
42615 + if (atomic_inc_return(&serial->port.count) == 1) {
42616 serial->rx_state = RX_IDLE;
42617 /* Force default termio settings */
42618 _hso_serial_set_termios(tty, NULL);
42619 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
42620 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
42621 if (result) {
42622 hso_stop_serial_device(serial->parent);
42623 - serial->port.count--;
42624 + atomic_dec(&serial->port.count);
42625 kref_put(&serial->parent->ref, hso_serial_ref_free);
42626 }
42627 } else {
42628 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
42629
42630 /* reset the rts and dtr */
42631 /* do the actual close */
42632 - serial->port.count--;
42633 + atomic_dec(&serial->port.count);
42634
42635 - if (serial->port.count <= 0) {
42636 - serial->port.count = 0;
42637 + if (atomic_read(&serial->port.count) <= 0) {
42638 + atomic_set(&serial->port.count, 0);
42639 tty_port_tty_set(&serial->port, NULL);
42640 if (!usb_gone)
42641 hso_stop_serial_device(serial->parent);
42642 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
42643
42644 /* the actual setup */
42645 spin_lock_irqsave(&serial->serial_lock, flags);
42646 - if (serial->port.count)
42647 + if (atomic_read(&serial->port.count))
42648 _hso_serial_set_termios(tty, old);
42649 else
42650 tty->termios = *old;
42651 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
42652 D1("Pending read interrupt on port %d\n", i);
42653 spin_lock(&serial->serial_lock);
42654 if (serial->rx_state == RX_IDLE &&
42655 - serial->port.count > 0) {
42656 + atomic_read(&serial->port.count) > 0) {
42657 /* Setup and send a ctrl req read on
42658 * port i */
42659 if (!serial->rx_urb_filled[0]) {
42660 @@ -3057,7 +3056,7 @@ static int hso_resume(struct usb_interface *iface)
42661 /* Start all serial ports */
42662 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
42663 if (serial_table[i] && (serial_table[i]->interface == iface)) {
42664 - if (dev2ser(serial_table[i])->port.count) {
42665 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
42666 result =
42667 hso_start_serial_device(serial_table[i], GFP_NOIO);
42668 hso_kick_transmit(dev2ser(serial_table[i]));
42669 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
42670 index 57325f3..36b181f 100644
42671 --- a/drivers/net/vxlan.c
42672 +++ b/drivers/net/vxlan.c
42673 @@ -1579,7 +1579,7 @@ nla_put_failure:
42674 return -EMSGSIZE;
42675 }
42676
42677 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
42678 +static struct rtnl_link_ops vxlan_link_ops = {
42679 .kind = "vxlan",
42680 .maxtype = IFLA_VXLAN_MAX,
42681 .policy = vxlan_policy,
42682 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
42683 index 34c8a33..3261fdc 100644
42684 --- a/drivers/net/wireless/at76c50x-usb.c
42685 +++ b/drivers/net/wireless/at76c50x-usb.c
42686 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
42687 }
42688
42689 /* Convert timeout from the DFU status to jiffies */
42690 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
42691 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
42692 {
42693 return msecs_to_jiffies((s->poll_timeout[2] << 16)
42694 | (s->poll_timeout[1] << 8)
42695 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
42696 index 8d78253..bebbb68 100644
42697 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
42698 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
42699 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42700 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
42701 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
42702
42703 - ACCESS_ONCE(ads->ds_link) = i->link;
42704 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
42705 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
42706 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
42707
42708 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
42709 ctl6 = SM(i->keytype, AR_EncrType);
42710 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42711
42712 if ((i->is_first || i->is_last) &&
42713 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
42714 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
42715 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
42716 | set11nTries(i->rates, 1)
42717 | set11nTries(i->rates, 2)
42718 | set11nTries(i->rates, 3)
42719 | (i->dur_update ? AR_DurUpdateEna : 0)
42720 | SM(0, AR_BurstDur);
42721
42722 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
42723 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
42724 | set11nRate(i->rates, 1)
42725 | set11nRate(i->rates, 2)
42726 | set11nRate(i->rates, 3);
42727 } else {
42728 - ACCESS_ONCE(ads->ds_ctl2) = 0;
42729 - ACCESS_ONCE(ads->ds_ctl3) = 0;
42730 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
42731 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
42732 }
42733
42734 if (!i->is_first) {
42735 - ACCESS_ONCE(ads->ds_ctl0) = 0;
42736 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
42737 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
42738 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
42739 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
42740 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
42741 return;
42742 }
42743
42744 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42745 break;
42746 }
42747
42748 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
42749 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
42750 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
42751 | SM(i->txpower, AR_XmitPower)
42752 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
42753 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42754 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
42755 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
42756
42757 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
42758 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
42759 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
42760 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
42761
42762 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
42763 return;
42764
42765 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
42766 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
42767 | set11nPktDurRTSCTS(i->rates, 1);
42768
42769 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
42770 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
42771 | set11nPktDurRTSCTS(i->rates, 3);
42772
42773 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
42774 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
42775 | set11nRateFlags(i->rates, 1)
42776 | set11nRateFlags(i->rates, 2)
42777 | set11nRateFlags(i->rates, 3)
42778 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
42779 index 301bf72..3f5654f 100644
42780 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
42781 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
42782 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42783 (i->qcu << AR_TxQcuNum_S) | desc_len;
42784
42785 checksum += val;
42786 - ACCESS_ONCE(ads->info) = val;
42787 + ACCESS_ONCE_RW(ads->info) = val;
42788
42789 checksum += i->link;
42790 - ACCESS_ONCE(ads->link) = i->link;
42791 + ACCESS_ONCE_RW(ads->link) = i->link;
42792
42793 checksum += i->buf_addr[0];
42794 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
42795 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
42796 checksum += i->buf_addr[1];
42797 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
42798 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
42799 checksum += i->buf_addr[2];
42800 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
42801 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
42802 checksum += i->buf_addr[3];
42803 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
42804 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
42805
42806 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
42807 - ACCESS_ONCE(ads->ctl3) = val;
42808 + ACCESS_ONCE_RW(ads->ctl3) = val;
42809 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
42810 - ACCESS_ONCE(ads->ctl5) = val;
42811 + ACCESS_ONCE_RW(ads->ctl5) = val;
42812 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
42813 - ACCESS_ONCE(ads->ctl7) = val;
42814 + ACCESS_ONCE_RW(ads->ctl7) = val;
42815 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
42816 - ACCESS_ONCE(ads->ctl9) = val;
42817 + ACCESS_ONCE_RW(ads->ctl9) = val;
42818
42819 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
42820 - ACCESS_ONCE(ads->ctl10) = checksum;
42821 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
42822
42823 if (i->is_first || i->is_last) {
42824 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
42825 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
42826 | set11nTries(i->rates, 1)
42827 | set11nTries(i->rates, 2)
42828 | set11nTries(i->rates, 3)
42829 | (i->dur_update ? AR_DurUpdateEna : 0)
42830 | SM(0, AR_BurstDur);
42831
42832 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
42833 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
42834 | set11nRate(i->rates, 1)
42835 | set11nRate(i->rates, 2)
42836 | set11nRate(i->rates, 3);
42837 } else {
42838 - ACCESS_ONCE(ads->ctl13) = 0;
42839 - ACCESS_ONCE(ads->ctl14) = 0;
42840 + ACCESS_ONCE_RW(ads->ctl13) = 0;
42841 + ACCESS_ONCE_RW(ads->ctl14) = 0;
42842 }
42843
42844 ads->ctl20 = 0;
42845 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42846
42847 ctl17 = SM(i->keytype, AR_EncrType);
42848 if (!i->is_first) {
42849 - ACCESS_ONCE(ads->ctl11) = 0;
42850 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
42851 - ACCESS_ONCE(ads->ctl15) = 0;
42852 - ACCESS_ONCE(ads->ctl16) = 0;
42853 - ACCESS_ONCE(ads->ctl17) = ctl17;
42854 - ACCESS_ONCE(ads->ctl18) = 0;
42855 - ACCESS_ONCE(ads->ctl19) = 0;
42856 + ACCESS_ONCE_RW(ads->ctl11) = 0;
42857 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
42858 + ACCESS_ONCE_RW(ads->ctl15) = 0;
42859 + ACCESS_ONCE_RW(ads->ctl16) = 0;
42860 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
42861 + ACCESS_ONCE_RW(ads->ctl18) = 0;
42862 + ACCESS_ONCE_RW(ads->ctl19) = 0;
42863 return;
42864 }
42865
42866 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
42867 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
42868 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
42869 | SM(i->txpower, AR_XmitPower)
42870 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
42871 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42872 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
42873 ctl12 |= SM(val, AR_PAPRDChainMask);
42874
42875 - ACCESS_ONCE(ads->ctl12) = ctl12;
42876 - ACCESS_ONCE(ads->ctl17) = ctl17;
42877 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
42878 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
42879
42880 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
42881 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
42882 | set11nPktDurRTSCTS(i->rates, 1);
42883
42884 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
42885 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
42886 | set11nPktDurRTSCTS(i->rates, 3);
42887
42888 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
42889 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
42890 | set11nRateFlags(i->rates, 1)
42891 | set11nRateFlags(i->rates, 2)
42892 | set11nRateFlags(i->rates, 3)
42893 | SM(i->rtscts_rate, AR_RTSCTSRate);
42894
42895 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
42896 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
42897 }
42898
42899 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
42900 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
42901 index ae30343..a117806 100644
42902 --- a/drivers/net/wireless/ath/ath9k/hw.h
42903 +++ b/drivers/net/wireless/ath/ath9k/hw.h
42904 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
42905
42906 /* ANI */
42907 void (*ani_cache_ini_regs)(struct ath_hw *ah);
42908 -};
42909 +} __no_const;
42910
42911 /**
42912 * struct ath_spec_scan - parameters for Atheros spectral scan
42913 @@ -721,7 +721,7 @@ struct ath_hw_ops {
42914 struct ath_spec_scan *param);
42915 void (*spectral_scan_trigger)(struct ath_hw *ah);
42916 void (*spectral_scan_wait)(struct ath_hw *ah);
42917 -};
42918 +} __no_const;
42919
42920 struct ath_nf_limits {
42921 s16 max;
42922 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
42923 index b37a582..680835d 100644
42924 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
42925 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
42926 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
42927 */
42928 if (il3945_mod_params.disable_hw_scan) {
42929 D_INFO("Disabling hw_scan\n");
42930 - il3945_mac_ops.hw_scan = NULL;
42931 + pax_open_kernel();
42932 + *(void **)&il3945_mac_ops.hw_scan = NULL;
42933 + pax_close_kernel();
42934 }
42935
42936 D_INFO("*** LOAD DRIVER ***\n");
42937 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
42938 index d532948..e0d8bb1 100644
42939 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
42940 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
42941 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
42942 {
42943 struct iwl_priv *priv = file->private_data;
42944 char buf[64];
42945 - int buf_size;
42946 + size_t buf_size;
42947 u32 offset, len;
42948
42949 memset(buf, 0, sizeof(buf));
42950 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
42951 struct iwl_priv *priv = file->private_data;
42952
42953 char buf[8];
42954 - int buf_size;
42955 + size_t buf_size;
42956 u32 reset_flag;
42957
42958 memset(buf, 0, sizeof(buf));
42959 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
42960 {
42961 struct iwl_priv *priv = file->private_data;
42962 char buf[8];
42963 - int buf_size;
42964 + size_t buf_size;
42965 int ht40;
42966
42967 memset(buf, 0, sizeof(buf));
42968 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
42969 {
42970 struct iwl_priv *priv = file->private_data;
42971 char buf[8];
42972 - int buf_size;
42973 + size_t buf_size;
42974 int value;
42975
42976 memset(buf, 0, sizeof(buf));
42977 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
42978 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
42979 DEBUGFS_READ_FILE_OPS(current_sleep_command);
42980
42981 -static const char *fmt_value = " %-30s %10u\n";
42982 -static const char *fmt_hex = " %-30s 0x%02X\n";
42983 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
42984 -static const char *fmt_header =
42985 +static const char fmt_value[] = " %-30s %10u\n";
42986 +static const char fmt_hex[] = " %-30s 0x%02X\n";
42987 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
42988 +static const char fmt_header[] =
42989 "%-32s current cumulative delta max\n";
42990
42991 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
42992 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
42993 {
42994 struct iwl_priv *priv = file->private_data;
42995 char buf[8];
42996 - int buf_size;
42997 + size_t buf_size;
42998 int clear;
42999
43000 memset(buf, 0, sizeof(buf));
43001 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
43002 {
43003 struct iwl_priv *priv = file->private_data;
43004 char buf[8];
43005 - int buf_size;
43006 + size_t buf_size;
43007 int trace;
43008
43009 memset(buf, 0, sizeof(buf));
43010 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
43011 {
43012 struct iwl_priv *priv = file->private_data;
43013 char buf[8];
43014 - int buf_size;
43015 + size_t buf_size;
43016 int missed;
43017
43018 memset(buf, 0, sizeof(buf));
43019 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
43020
43021 struct iwl_priv *priv = file->private_data;
43022 char buf[8];
43023 - int buf_size;
43024 + size_t buf_size;
43025 int plcp;
43026
43027 memset(buf, 0, sizeof(buf));
43028 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
43029
43030 struct iwl_priv *priv = file->private_data;
43031 char buf[8];
43032 - int buf_size;
43033 + size_t buf_size;
43034 int flush;
43035
43036 memset(buf, 0, sizeof(buf));
43037 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
43038
43039 struct iwl_priv *priv = file->private_data;
43040 char buf[8];
43041 - int buf_size;
43042 + size_t buf_size;
43043 int rts;
43044
43045 if (!priv->cfg->ht_params)
43046 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
43047 {
43048 struct iwl_priv *priv = file->private_data;
43049 char buf[8];
43050 - int buf_size;
43051 + size_t buf_size;
43052
43053 memset(buf, 0, sizeof(buf));
43054 buf_size = min(count, sizeof(buf) - 1);
43055 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
43056 struct iwl_priv *priv = file->private_data;
43057 u32 event_log_flag;
43058 char buf[8];
43059 - int buf_size;
43060 + size_t buf_size;
43061
43062 /* check that the interface is up */
43063 if (!iwl_is_ready(priv))
43064 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
43065 struct iwl_priv *priv = file->private_data;
43066 char buf[8];
43067 u32 calib_disabled;
43068 - int buf_size;
43069 + size_t buf_size;
43070
43071 memset(buf, 0, sizeof(buf));
43072 buf_size = min(count, sizeof(buf) - 1);
43073 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
43074 index 50ba0a4..29424e7 100644
43075 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
43076 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
43077 @@ -1329,7 +1329,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
43078 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
43079
43080 char buf[8];
43081 - int buf_size;
43082 + size_t buf_size;
43083 u32 reset_flag;
43084
43085 memset(buf, 0, sizeof(buf));
43086 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
43087 {
43088 struct iwl_trans *trans = file->private_data;
43089 char buf[8];
43090 - int buf_size;
43091 + size_t buf_size;
43092 int csr;
43093
43094 memset(buf, 0, sizeof(buf));
43095 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
43096 index cb34c78..9fec0dc 100644
43097 --- a/drivers/net/wireless/mac80211_hwsim.c
43098 +++ b/drivers/net/wireless/mac80211_hwsim.c
43099 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
43100
43101 if (channels > 1) {
43102 hwsim_if_comb.num_different_channels = channels;
43103 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
43104 - mac80211_hwsim_ops.cancel_hw_scan =
43105 - mac80211_hwsim_cancel_hw_scan;
43106 - mac80211_hwsim_ops.sw_scan_start = NULL;
43107 - mac80211_hwsim_ops.sw_scan_complete = NULL;
43108 - mac80211_hwsim_ops.remain_on_channel =
43109 - mac80211_hwsim_roc;
43110 - mac80211_hwsim_ops.cancel_remain_on_channel =
43111 - mac80211_hwsim_croc;
43112 - mac80211_hwsim_ops.add_chanctx =
43113 - mac80211_hwsim_add_chanctx;
43114 - mac80211_hwsim_ops.remove_chanctx =
43115 - mac80211_hwsim_remove_chanctx;
43116 - mac80211_hwsim_ops.change_chanctx =
43117 - mac80211_hwsim_change_chanctx;
43118 - mac80211_hwsim_ops.assign_vif_chanctx =
43119 - mac80211_hwsim_assign_vif_chanctx;
43120 - mac80211_hwsim_ops.unassign_vif_chanctx =
43121 - mac80211_hwsim_unassign_vif_chanctx;
43122 + pax_open_kernel();
43123 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
43124 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
43125 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
43126 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
43127 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
43128 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
43129 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
43130 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
43131 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
43132 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
43133 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
43134 + pax_close_kernel();
43135 }
43136
43137 spin_lock_init(&hwsim_radio_lock);
43138 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
43139 index 8169a85..7fa3b47 100644
43140 --- a/drivers/net/wireless/rndis_wlan.c
43141 +++ b/drivers/net/wireless/rndis_wlan.c
43142 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
43143
43144 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
43145
43146 - if (rts_threshold < 0 || rts_threshold > 2347)
43147 + if (rts_threshold > 2347)
43148 rts_threshold = 2347;
43149
43150 tmp = cpu_to_le32(rts_threshold);
43151 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
43152 index 7510723..5ba37f5 100644
43153 --- a/drivers/net/wireless/rt2x00/rt2x00.h
43154 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
43155 @@ -386,7 +386,7 @@ struct rt2x00_intf {
43156 * for hardware which doesn't support hardware
43157 * sequence counting.
43158 */
43159 - atomic_t seqno;
43160 + atomic_unchecked_t seqno;
43161 };
43162
43163 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
43164 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
43165 index d955741..8730748 100644
43166 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
43167 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
43168 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
43169 * sequence counter given by mac80211.
43170 */
43171 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
43172 - seqno = atomic_add_return(0x10, &intf->seqno);
43173 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
43174 else
43175 - seqno = atomic_read(&intf->seqno);
43176 + seqno = atomic_read_unchecked(&intf->seqno);
43177
43178 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
43179 hdr->seq_ctrl |= cpu_to_le16(seqno);
43180 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
43181 index e2b3d9c..67a5184 100644
43182 --- a/drivers/net/wireless/ti/wl1251/sdio.c
43183 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
43184 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
43185
43186 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
43187
43188 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
43189 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
43190 + pax_open_kernel();
43191 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
43192 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
43193 + pax_close_kernel();
43194
43195 wl1251_info("using dedicated interrupt line");
43196 } else {
43197 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
43198 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
43199 + pax_open_kernel();
43200 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
43201 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
43202 + pax_close_kernel();
43203
43204 wl1251_info("using SDIO interrupt");
43205 }
43206 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
43207 index 1c627da..69f7d17 100644
43208 --- a/drivers/net/wireless/ti/wl12xx/main.c
43209 +++ b/drivers/net/wireless/ti/wl12xx/main.c
43210 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
43211 sizeof(wl->conf.mem));
43212
43213 /* read data preparation is only needed by wl127x */
43214 - wl->ops->prepare_read = wl127x_prepare_read;
43215 + pax_open_kernel();
43216 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
43217 + pax_close_kernel();
43218
43219 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
43220 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
43221 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
43222 sizeof(wl->conf.mem));
43223
43224 /* read data preparation is only needed by wl127x */
43225 - wl->ops->prepare_read = wl127x_prepare_read;
43226 + pax_open_kernel();
43227 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
43228 + pax_close_kernel();
43229
43230 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
43231 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
43232 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
43233 index 9fa692d..b31fee0 100644
43234 --- a/drivers/net/wireless/ti/wl18xx/main.c
43235 +++ b/drivers/net/wireless/ti/wl18xx/main.c
43236 @@ -1687,8 +1687,10 @@ static int wl18xx_setup(struct wl1271 *wl)
43237 }
43238
43239 if (!checksum_param) {
43240 - wl18xx_ops.set_rx_csum = NULL;
43241 - wl18xx_ops.init_vif = NULL;
43242 + pax_open_kernel();
43243 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
43244 + *(void **)&wl18xx_ops.init_vif = NULL;
43245 + pax_close_kernel();
43246 }
43247
43248 /* Enable 11a Band only if we have 5G antennas */
43249 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
43250 index 7ef0b4a..ff65c28 100644
43251 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
43252 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
43253 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
43254 {
43255 struct zd_usb *usb = urb->context;
43256 struct zd_usb_interrupt *intr = &usb->intr;
43257 - int len;
43258 + unsigned int len;
43259 u16 int_num;
43260
43261 ZD_ASSERT(in_interrupt());
43262 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
43263 index d93b2b6..ae50401 100644
43264 --- a/drivers/oprofile/buffer_sync.c
43265 +++ b/drivers/oprofile/buffer_sync.c
43266 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
43267 if (cookie == NO_COOKIE)
43268 offset = pc;
43269 if (cookie == INVALID_COOKIE) {
43270 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
43271 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
43272 offset = pc;
43273 }
43274 if (cookie != last_cookie) {
43275 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
43276 /* add userspace sample */
43277
43278 if (!mm) {
43279 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
43280 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
43281 return 0;
43282 }
43283
43284 cookie = lookup_dcookie(mm, s->eip, &offset);
43285
43286 if (cookie == INVALID_COOKIE) {
43287 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
43288 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
43289 return 0;
43290 }
43291
43292 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
43293 /* ignore backtraces if failed to add a sample */
43294 if (state == sb_bt_start) {
43295 state = sb_bt_ignore;
43296 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
43297 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
43298 }
43299 }
43300 release_mm(mm);
43301 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
43302 index c0cc4e7..44d4e54 100644
43303 --- a/drivers/oprofile/event_buffer.c
43304 +++ b/drivers/oprofile/event_buffer.c
43305 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
43306 }
43307
43308 if (buffer_pos == buffer_size) {
43309 - atomic_inc(&oprofile_stats.event_lost_overflow);
43310 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
43311 return;
43312 }
43313
43314 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
43315 index ed2c3ec..deda85a 100644
43316 --- a/drivers/oprofile/oprof.c
43317 +++ b/drivers/oprofile/oprof.c
43318 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
43319 if (oprofile_ops.switch_events())
43320 return;
43321
43322 - atomic_inc(&oprofile_stats.multiplex_counter);
43323 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
43324 start_switch_worker();
43325 }
43326
43327 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
43328 index 84a208d..d61b0a1 100644
43329 --- a/drivers/oprofile/oprofile_files.c
43330 +++ b/drivers/oprofile/oprofile_files.c
43331 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
43332
43333 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
43334
43335 -static ssize_t timeout_read(struct file *file, char __user *buf,
43336 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
43337 size_t count, loff_t *offset)
43338 {
43339 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
43340 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
43341 index 917d28e..d62d981 100644
43342 --- a/drivers/oprofile/oprofile_stats.c
43343 +++ b/drivers/oprofile/oprofile_stats.c
43344 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
43345 cpu_buf->sample_invalid_eip = 0;
43346 }
43347
43348 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
43349 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
43350 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
43351 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
43352 - atomic_set(&oprofile_stats.multiplex_counter, 0);
43353 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
43354 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
43355 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
43356 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
43357 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
43358 }
43359
43360
43361 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
43362 index 38b6fc0..b5cbfce 100644
43363 --- a/drivers/oprofile/oprofile_stats.h
43364 +++ b/drivers/oprofile/oprofile_stats.h
43365 @@ -13,11 +13,11 @@
43366 #include <linux/atomic.h>
43367
43368 struct oprofile_stat_struct {
43369 - atomic_t sample_lost_no_mm;
43370 - atomic_t sample_lost_no_mapping;
43371 - atomic_t bt_lost_no_mapping;
43372 - atomic_t event_lost_overflow;
43373 - atomic_t multiplex_counter;
43374 + atomic_unchecked_t sample_lost_no_mm;
43375 + atomic_unchecked_t sample_lost_no_mapping;
43376 + atomic_unchecked_t bt_lost_no_mapping;
43377 + atomic_unchecked_t event_lost_overflow;
43378 + atomic_unchecked_t multiplex_counter;
43379 };
43380
43381 extern struct oprofile_stat_struct oprofile_stats;
43382 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
43383 index 7c12d9c..558bf3bb 100644
43384 --- a/drivers/oprofile/oprofilefs.c
43385 +++ b/drivers/oprofile/oprofilefs.c
43386 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
43387
43388
43389 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
43390 - char const *name, atomic_t *val)
43391 + char const *name, atomic_unchecked_t *val)
43392 {
43393 return __oprofilefs_create_file(sb, root, name,
43394 &atomic_ro_fops, 0444, val);
43395 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
43396 index 93404f7..4a313d8 100644
43397 --- a/drivers/oprofile/timer_int.c
43398 +++ b/drivers/oprofile/timer_int.c
43399 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
43400 return NOTIFY_OK;
43401 }
43402
43403 -static struct notifier_block __refdata oprofile_cpu_notifier = {
43404 +static struct notifier_block oprofile_cpu_notifier = {
43405 .notifier_call = oprofile_cpu_notify,
43406 };
43407
43408 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
43409 index 92ed045..62d39bd7 100644
43410 --- a/drivers/parport/procfs.c
43411 +++ b/drivers/parport/procfs.c
43412 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
43413
43414 *ppos += len;
43415
43416 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
43417 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
43418 }
43419
43420 #ifdef CONFIG_PARPORT_1284
43421 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
43422
43423 *ppos += len;
43424
43425 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
43426 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
43427 }
43428 #endif /* IEEE1284.3 support. */
43429
43430 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
43431 index c35e8ad..fc33beb 100644
43432 --- a/drivers/pci/hotplug/acpiphp_ibm.c
43433 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
43434 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
43435 goto init_cleanup;
43436 }
43437
43438 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
43439 + pax_open_kernel();
43440 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
43441 + pax_close_kernel();
43442 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
43443
43444 return retval;
43445 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
43446 index a6a71c4..c91097b 100644
43447 --- a/drivers/pci/hotplug/cpcihp_generic.c
43448 +++ b/drivers/pci/hotplug/cpcihp_generic.c
43449 @@ -73,7 +73,6 @@ static u16 port;
43450 static unsigned int enum_bit;
43451 static u8 enum_mask;
43452
43453 -static struct cpci_hp_controller_ops generic_hpc_ops;
43454 static struct cpci_hp_controller generic_hpc;
43455
43456 static int __init validate_parameters(void)
43457 @@ -139,6 +138,10 @@ static int query_enum(void)
43458 return ((value & enum_mask) == enum_mask);
43459 }
43460
43461 +static struct cpci_hp_controller_ops generic_hpc_ops = {
43462 + .query_enum = query_enum,
43463 +};
43464 +
43465 static int __init cpcihp_generic_init(void)
43466 {
43467 int status;
43468 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
43469 pci_dev_put(dev);
43470
43471 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
43472 - generic_hpc_ops.query_enum = query_enum;
43473 generic_hpc.ops = &generic_hpc_ops;
43474
43475 status = cpci_hp_register_controller(&generic_hpc);
43476 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
43477 index 449b4bb..257e2e8 100644
43478 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
43479 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
43480 @@ -59,7 +59,6 @@
43481 /* local variables */
43482 static bool debug;
43483 static bool poll;
43484 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
43485 static struct cpci_hp_controller zt5550_hpc;
43486
43487 /* Primary cPCI bus bridge device */
43488 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
43489 return 0;
43490 }
43491
43492 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
43493 + .query_enum = zt5550_hc_query_enum,
43494 +};
43495 +
43496 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
43497 {
43498 int status;
43499 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
43500 dbg("returned from zt5550_hc_config");
43501
43502 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
43503 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
43504 zt5550_hpc.ops = &zt5550_hpc_ops;
43505 if(!poll) {
43506 zt5550_hpc.irq = hc_dev->irq;
43507 zt5550_hpc.irq_flags = IRQF_SHARED;
43508 zt5550_hpc.dev_id = hc_dev;
43509
43510 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
43511 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
43512 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
43513 + pax_open_kernel();
43514 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
43515 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
43516 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
43517 + pax_open_kernel();
43518 } else {
43519 info("using ENUM# polling mode");
43520 }
43521 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
43522 index 76ba8a1..20ca857 100644
43523 --- a/drivers/pci/hotplug/cpqphp_nvram.c
43524 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
43525 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
43526
43527 void compaq_nvram_init (void __iomem *rom_start)
43528 {
43529 +
43530 +#ifndef CONFIG_PAX_KERNEXEC
43531 if (rom_start) {
43532 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
43533 }
43534 +#endif
43535 +
43536 dbg("int15 entry = %p\n", compaq_int15_entry_point);
43537
43538 /* initialize our int15 lock */
43539 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
43540 index ec20f74..c1d961e 100644
43541 --- a/drivers/pci/hotplug/pci_hotplug_core.c
43542 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
43543 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
43544 return -EINVAL;
43545 }
43546
43547 - slot->ops->owner = owner;
43548 - slot->ops->mod_name = mod_name;
43549 + pax_open_kernel();
43550 + *(struct module **)&slot->ops->owner = owner;
43551 + *(const char **)&slot->ops->mod_name = mod_name;
43552 + pax_close_kernel();
43553
43554 mutex_lock(&pci_hp_mutex);
43555 /*
43556 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
43557 index 7d72c5e..edce02c 100644
43558 --- a/drivers/pci/hotplug/pciehp_core.c
43559 +++ b/drivers/pci/hotplug/pciehp_core.c
43560 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
43561 struct slot *slot = ctrl->slot;
43562 struct hotplug_slot *hotplug = NULL;
43563 struct hotplug_slot_info *info = NULL;
43564 - struct hotplug_slot_ops *ops = NULL;
43565 + hotplug_slot_ops_no_const *ops = NULL;
43566 char name[SLOT_NAME_SIZE];
43567 int retval = -ENOMEM;
43568
43569 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
43570 index 5b4a9d9..cd5ac1f 100644
43571 --- a/drivers/pci/pci-sysfs.c
43572 +++ b/drivers/pci/pci-sysfs.c
43573 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
43574 {
43575 /* allocate attribute structure, piggyback attribute name */
43576 int name_len = write_combine ? 13 : 10;
43577 - struct bin_attribute *res_attr;
43578 + bin_attribute_no_const *res_attr;
43579 int retval;
43580
43581 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
43582 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
43583 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
43584 {
43585 int retval;
43586 - struct bin_attribute *attr;
43587 + bin_attribute_no_const *attr;
43588
43589 /* If the device has VPD, try to expose it in sysfs. */
43590 if (dev->vpd) {
43591 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
43592 {
43593 int retval;
43594 int rom_size = 0;
43595 - struct bin_attribute *attr;
43596 + bin_attribute_no_const *attr;
43597
43598 if (!sysfs_initialized)
43599 return -EACCES;
43600 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
43601 index d1182c4..2a138ec 100644
43602 --- a/drivers/pci/pci.h
43603 +++ b/drivers/pci/pci.h
43604 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
43605 struct pci_vpd {
43606 unsigned int len;
43607 const struct pci_vpd_ops *ops;
43608 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
43609 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
43610 };
43611
43612 int pci_vpd_pci22_init(struct pci_dev *dev);
43613 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
43614 index d320df6..ca9a8f6 100644
43615 --- a/drivers/pci/pcie/aspm.c
43616 +++ b/drivers/pci/pcie/aspm.c
43617 @@ -27,9 +27,9 @@
43618 #define MODULE_PARAM_PREFIX "pcie_aspm."
43619
43620 /* Note: those are not register definitions */
43621 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
43622 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
43623 -#define ASPM_STATE_L1 (4) /* L1 state */
43624 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
43625 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
43626 +#define ASPM_STATE_L1 (4U) /* L1 state */
43627 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
43628 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
43629
43630 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
43631 index ea37072..10e58e56 100644
43632 --- a/drivers/pci/probe.c
43633 +++ b/drivers/pci/probe.c
43634 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
43635 struct pci_bus_region region;
43636 bool bar_too_big = false, bar_disabled = false;
43637
43638 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
43639 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
43640
43641 /* No printks while decoding is disabled! */
43642 if (!dev->mmio_always_on) {
43643 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
43644 index 0812608..b04018c4 100644
43645 --- a/drivers/pci/proc.c
43646 +++ b/drivers/pci/proc.c
43647 @@ -453,7 +453,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
43648 static int __init pci_proc_init(void)
43649 {
43650 struct pci_dev *dev = NULL;
43651 +
43652 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
43653 +#ifdef CONFIG_GRKERNSEC_PROC_USER
43654 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
43655 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
43656 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
43657 +#endif
43658 +#else
43659 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
43660 +#endif
43661 proc_create("devices", 0, proc_bus_pci_dir,
43662 &proc_bus_pci_dev_operations);
43663 proc_initialized = 1;
43664 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
43665 index 3e5b4497..dcdfb70 100644
43666 --- a/drivers/platform/x86/chromeos_laptop.c
43667 +++ b/drivers/platform/x86/chromeos_laptop.c
43668 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
43669 return 0;
43670 }
43671
43672 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
43673 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
43674 {
43675 .ident = "Samsung Series 5 550 - Touchpad",
43676 .matches = {
43677 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
43678 index 6b22938..bc9700e 100644
43679 --- a/drivers/platform/x86/msi-laptop.c
43680 +++ b/drivers/platform/x86/msi-laptop.c
43681 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
43682
43683 if (!quirks->ec_read_only) {
43684 /* allow userland write sysfs file */
43685 - dev_attr_bluetooth.store = store_bluetooth;
43686 - dev_attr_wlan.store = store_wlan;
43687 - dev_attr_threeg.store = store_threeg;
43688 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
43689 - dev_attr_wlan.attr.mode |= S_IWUSR;
43690 - dev_attr_threeg.attr.mode |= S_IWUSR;
43691 + pax_open_kernel();
43692 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
43693 + *(void **)&dev_attr_wlan.store = store_wlan;
43694 + *(void **)&dev_attr_threeg.store = store_threeg;
43695 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
43696 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
43697 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
43698 + pax_close_kernel();
43699 }
43700
43701 /* disable hardware control by fn key */
43702 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
43703 index 2ac045f..39c443d 100644
43704 --- a/drivers/platform/x86/sony-laptop.c
43705 +++ b/drivers/platform/x86/sony-laptop.c
43706 @@ -2483,7 +2483,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
43707 }
43708
43709 /* High speed charging function */
43710 -static struct device_attribute *hsc_handle;
43711 +static device_attribute_no_const *hsc_handle;
43712
43713 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
43714 struct device_attribute *attr,
43715 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
43716 index 54d31c0..3f896d3 100644
43717 --- a/drivers/platform/x86/thinkpad_acpi.c
43718 +++ b/drivers/platform/x86/thinkpad_acpi.c
43719 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
43720 return 0;
43721 }
43722
43723 -void static hotkey_mask_warn_incomplete_mask(void)
43724 +static void hotkey_mask_warn_incomplete_mask(void)
43725 {
43726 /* log only what the user can fix... */
43727 const u32 wantedmask = hotkey_driver_mask &
43728 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
43729 }
43730 }
43731
43732 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43733 - struct tp_nvram_state *newn,
43734 - const u32 event_mask)
43735 -{
43736 -
43737 #define TPACPI_COMPARE_KEY(__scancode, __member) \
43738 do { \
43739 if ((event_mask & (1 << __scancode)) && \
43740 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43741 tpacpi_hotkey_send_key(__scancode); \
43742 } while (0)
43743
43744 - void issue_volchange(const unsigned int oldvol,
43745 - const unsigned int newvol)
43746 - {
43747 - unsigned int i = oldvol;
43748 +static void issue_volchange(const unsigned int oldvol,
43749 + const unsigned int newvol,
43750 + const u32 event_mask)
43751 +{
43752 + unsigned int i = oldvol;
43753
43754 - while (i > newvol) {
43755 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
43756 - i--;
43757 - }
43758 - while (i < newvol) {
43759 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
43760 - i++;
43761 - }
43762 + while (i > newvol) {
43763 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
43764 + i--;
43765 }
43766 + while (i < newvol) {
43767 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
43768 + i++;
43769 + }
43770 +}
43771
43772 - void issue_brightnesschange(const unsigned int oldbrt,
43773 - const unsigned int newbrt)
43774 - {
43775 - unsigned int i = oldbrt;
43776 +static void issue_brightnesschange(const unsigned int oldbrt,
43777 + const unsigned int newbrt,
43778 + const u32 event_mask)
43779 +{
43780 + unsigned int i = oldbrt;
43781
43782 - while (i > newbrt) {
43783 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
43784 - i--;
43785 - }
43786 - while (i < newbrt) {
43787 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
43788 - i++;
43789 - }
43790 + while (i > newbrt) {
43791 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
43792 + i--;
43793 + }
43794 + while (i < newbrt) {
43795 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
43796 + i++;
43797 }
43798 +}
43799
43800 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43801 + struct tp_nvram_state *newn,
43802 + const u32 event_mask)
43803 +{
43804 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
43805 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
43806 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
43807 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43808 oldn->volume_level != newn->volume_level) {
43809 /* recently muted, or repeated mute keypress, or
43810 * multiple presses ending in mute */
43811 - issue_volchange(oldn->volume_level, newn->volume_level);
43812 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
43813 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
43814 }
43815 } else {
43816 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43817 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
43818 }
43819 if (oldn->volume_level != newn->volume_level) {
43820 - issue_volchange(oldn->volume_level, newn->volume_level);
43821 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
43822 } else if (oldn->volume_toggle != newn->volume_toggle) {
43823 /* repeated vol up/down keypress at end of scale ? */
43824 if (newn->volume_level == 0)
43825 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43826 /* handle brightness */
43827 if (oldn->brightness_level != newn->brightness_level) {
43828 issue_brightnesschange(oldn->brightness_level,
43829 - newn->brightness_level);
43830 + newn->brightness_level,
43831 + event_mask);
43832 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
43833 /* repeated key presses that didn't change state */
43834 if (newn->brightness_level == 0)
43835 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43836 && !tp_features.bright_unkfw)
43837 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
43838 }
43839 +}
43840
43841 #undef TPACPI_COMPARE_KEY
43842 #undef TPACPI_MAY_SEND_KEY
43843 -}
43844
43845 /*
43846 * Polling driver
43847 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
43848 index 769d265..a3a05ca 100644
43849 --- a/drivers/pnp/pnpbios/bioscalls.c
43850 +++ b/drivers/pnp/pnpbios/bioscalls.c
43851 @@ -58,7 +58,7 @@ do { \
43852 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
43853 } while(0)
43854
43855 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
43856 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
43857 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
43858
43859 /*
43860 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
43861
43862 cpu = get_cpu();
43863 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
43864 +
43865 + pax_open_kernel();
43866 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
43867 + pax_close_kernel();
43868
43869 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
43870 spin_lock_irqsave(&pnp_bios_lock, flags);
43871 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
43872 :"memory");
43873 spin_unlock_irqrestore(&pnp_bios_lock, flags);
43874
43875 + pax_open_kernel();
43876 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
43877 + pax_close_kernel();
43878 +
43879 put_cpu();
43880
43881 /* If we get here and this is set then the PnP BIOS faulted on us. */
43882 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
43883 return status;
43884 }
43885
43886 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
43887 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
43888 {
43889 int i;
43890
43891 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
43892 pnp_bios_callpoint.offset = header->fields.pm16offset;
43893 pnp_bios_callpoint.segment = PNP_CS16;
43894
43895 + pax_open_kernel();
43896 +
43897 for_each_possible_cpu(i) {
43898 struct desc_struct *gdt = get_cpu_gdt_table(i);
43899 if (!gdt)
43900 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
43901 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
43902 (unsigned long)__va(header->fields.pm16dseg));
43903 }
43904 +
43905 + pax_close_kernel();
43906 }
43907 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
43908 index 3e6db1c..1fbbdae 100644
43909 --- a/drivers/pnp/resource.c
43910 +++ b/drivers/pnp/resource.c
43911 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
43912 return 1;
43913
43914 /* check if the resource is valid */
43915 - if (*irq < 0 || *irq > 15)
43916 + if (*irq > 15)
43917 return 0;
43918
43919 /* check if the resource is reserved */
43920 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
43921 return 1;
43922
43923 /* check if the resource is valid */
43924 - if (*dma < 0 || *dma == 4 || *dma > 7)
43925 + if (*dma == 4 || *dma > 7)
43926 return 0;
43927
43928 /* check if the resource is reserved */
43929 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
43930 index 0c52e2a..3421ab7 100644
43931 --- a/drivers/power/pda_power.c
43932 +++ b/drivers/power/pda_power.c
43933 @@ -37,7 +37,11 @@ static int polling;
43934
43935 #if IS_ENABLED(CONFIG_USB_PHY)
43936 static struct usb_phy *transceiver;
43937 -static struct notifier_block otg_nb;
43938 +static int otg_handle_notification(struct notifier_block *nb,
43939 + unsigned long event, void *unused);
43940 +static struct notifier_block otg_nb = {
43941 + .notifier_call = otg_handle_notification
43942 +};
43943 #endif
43944
43945 static struct regulator *ac_draw;
43946 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
43947
43948 #if IS_ENABLED(CONFIG_USB_PHY)
43949 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
43950 - otg_nb.notifier_call = otg_handle_notification;
43951 ret = usb_register_notifier(transceiver, &otg_nb);
43952 if (ret) {
43953 dev_err(dev, "failure to register otg notifier\n");
43954 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
43955 index cc439fd..8fa30df 100644
43956 --- a/drivers/power/power_supply.h
43957 +++ b/drivers/power/power_supply.h
43958 @@ -16,12 +16,12 @@ struct power_supply;
43959
43960 #ifdef CONFIG_SYSFS
43961
43962 -extern void power_supply_init_attrs(struct device_type *dev_type);
43963 +extern void power_supply_init_attrs(void);
43964 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
43965
43966 #else
43967
43968 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
43969 +static inline void power_supply_init_attrs(void) {}
43970 #define power_supply_uevent NULL
43971
43972 #endif /* CONFIG_SYSFS */
43973 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
43974 index 1c517c3..ffa2f17 100644
43975 --- a/drivers/power/power_supply_core.c
43976 +++ b/drivers/power/power_supply_core.c
43977 @@ -24,7 +24,10 @@
43978 struct class *power_supply_class;
43979 EXPORT_SYMBOL_GPL(power_supply_class);
43980
43981 -static struct device_type power_supply_dev_type;
43982 +extern const struct attribute_group *power_supply_attr_groups[];
43983 +static struct device_type power_supply_dev_type = {
43984 + .groups = power_supply_attr_groups,
43985 +};
43986
43987 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
43988 struct power_supply *supply)
43989 @@ -554,7 +557,7 @@ static int __init power_supply_class_init(void)
43990 return PTR_ERR(power_supply_class);
43991
43992 power_supply_class->dev_uevent = power_supply_uevent;
43993 - power_supply_init_attrs(&power_supply_dev_type);
43994 + power_supply_init_attrs();
43995
43996 return 0;
43997 }
43998 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
43999 index 29178f7..c65f324 100644
44000 --- a/drivers/power/power_supply_sysfs.c
44001 +++ b/drivers/power/power_supply_sysfs.c
44002 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
44003 .is_visible = power_supply_attr_is_visible,
44004 };
44005
44006 -static const struct attribute_group *power_supply_attr_groups[] = {
44007 +const struct attribute_group *power_supply_attr_groups[] = {
44008 &power_supply_attr_group,
44009 NULL,
44010 };
44011
44012 -void power_supply_init_attrs(struct device_type *dev_type)
44013 +void power_supply_init_attrs(void)
44014 {
44015 int i;
44016
44017 - dev_type->groups = power_supply_attr_groups;
44018 -
44019 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
44020 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
44021 }
44022 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
44023 index d428ef9..fdc0357 100644
44024 --- a/drivers/regulator/max8660.c
44025 +++ b/drivers/regulator/max8660.c
44026 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
44027 max8660->shadow_regs[MAX8660_OVER1] = 5;
44028 } else {
44029 /* Otherwise devices can be toggled via software */
44030 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
44031 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
44032 + pax_open_kernel();
44033 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
44034 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
44035 + pax_close_kernel();
44036 }
44037
44038 /*
44039 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
44040 index adb1414..c13e0ce 100644
44041 --- a/drivers/regulator/max8973-regulator.c
44042 +++ b/drivers/regulator/max8973-regulator.c
44043 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
44044 if (!pdata->enable_ext_control) {
44045 max->desc.enable_reg = MAX8973_VOUT;
44046 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
44047 - max8973_dcdc_ops.enable = regulator_enable_regmap;
44048 - max8973_dcdc_ops.disable = regulator_disable_regmap;
44049 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
44050 + pax_open_kernel();
44051 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
44052 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
44053 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
44054 + pax_close_kernel();
44055 }
44056
44057 max->enable_external_control = pdata->enable_ext_control;
44058 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
44059 index b716283..3cc4349 100644
44060 --- a/drivers/regulator/mc13892-regulator.c
44061 +++ b/drivers/regulator/mc13892-regulator.c
44062 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
44063 }
44064 mc13xxx_unlock(mc13892);
44065
44066 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
44067 + pax_open_kernel();
44068 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
44069 = mc13892_vcam_set_mode;
44070 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
44071 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
44072 = mc13892_vcam_get_mode;
44073 + pax_close_kernel();
44074
44075 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
44076 ARRAY_SIZE(mc13892_regulators));
44077 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
44078 index f1cb706..4c7832a 100644
44079 --- a/drivers/rtc/rtc-cmos.c
44080 +++ b/drivers/rtc/rtc-cmos.c
44081 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
44082 hpet_rtc_timer_init();
44083
44084 /* export at least the first block of NVRAM */
44085 - nvram.size = address_space - NVRAM_OFFSET;
44086 + pax_open_kernel();
44087 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
44088 + pax_close_kernel();
44089 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
44090 if (retval < 0) {
44091 dev_dbg(dev, "can't create nvram file? %d\n", retval);
44092 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
44093 index d049393..bb20be0 100644
44094 --- a/drivers/rtc/rtc-dev.c
44095 +++ b/drivers/rtc/rtc-dev.c
44096 @@ -16,6 +16,7 @@
44097 #include <linux/module.h>
44098 #include <linux/rtc.h>
44099 #include <linux/sched.h>
44100 +#include <linux/grsecurity.h>
44101 #include "rtc-core.h"
44102
44103 static dev_t rtc_devt;
44104 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
44105 if (copy_from_user(&tm, uarg, sizeof(tm)))
44106 return -EFAULT;
44107
44108 + gr_log_timechange();
44109 +
44110 return rtc_set_time(rtc, &tm);
44111
44112 case RTC_PIE_ON:
44113 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
44114 index b53992a..776df84 100644
44115 --- a/drivers/rtc/rtc-ds1307.c
44116 +++ b/drivers/rtc/rtc-ds1307.c
44117 @@ -107,7 +107,7 @@ struct ds1307 {
44118 u8 offset; /* register's offset */
44119 u8 regs[11];
44120 u16 nvram_offset;
44121 - struct bin_attribute *nvram;
44122 + bin_attribute_no_const *nvram;
44123 enum ds_type type;
44124 unsigned long flags;
44125 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
44126 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
44127 index 130f29a..6179d03 100644
44128 --- a/drivers/rtc/rtc-m48t59.c
44129 +++ b/drivers/rtc/rtc-m48t59.c
44130 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
44131 goto out;
44132 }
44133
44134 - m48t59_nvram_attr.size = pdata->offset;
44135 + pax_open_kernel();
44136 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
44137 + pax_close_kernel();
44138
44139 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
44140 if (ret) {
44141 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
44142 index e693af6..2e525b6 100644
44143 --- a/drivers/scsi/bfa/bfa_fcpim.h
44144 +++ b/drivers/scsi/bfa/bfa_fcpim.h
44145 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
44146
44147 struct bfa_itn_s {
44148 bfa_isr_func_t isr;
44149 -};
44150 +} __no_const;
44151
44152 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
44153 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
44154 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
44155 index 23a90e7..9cf04ee 100644
44156 --- a/drivers/scsi/bfa/bfa_ioc.h
44157 +++ b/drivers/scsi/bfa/bfa_ioc.h
44158 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
44159 bfa_ioc_disable_cbfn_t disable_cbfn;
44160 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
44161 bfa_ioc_reset_cbfn_t reset_cbfn;
44162 -};
44163 +} __no_const;
44164
44165 /*
44166 * IOC event notification mechanism.
44167 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
44168 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
44169 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
44170 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
44171 -};
44172 +} __no_const;
44173
44174 /*
44175 * Queue element to wait for room in request queue. FIFO order is
44176 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
44177 index df0c3c7..b00e1d0 100644
44178 --- a/drivers/scsi/hosts.c
44179 +++ b/drivers/scsi/hosts.c
44180 @@ -42,7 +42,7 @@
44181 #include "scsi_logging.h"
44182
44183
44184 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
44185 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
44186
44187
44188 static void scsi_host_cls_release(struct device *dev)
44189 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
44190 * subtract one because we increment first then return, but we need to
44191 * know what the next host number was before increment
44192 */
44193 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
44194 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
44195 shost->dma_channel = 0xff;
44196
44197 /* These three are default values which can be overridden */
44198 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
44199 index 7f4f790..b75b92a 100644
44200 --- a/drivers/scsi/hpsa.c
44201 +++ b/drivers/scsi/hpsa.c
44202 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
44203 unsigned long flags;
44204
44205 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
44206 - return h->access.command_completed(h, q);
44207 + return h->access->command_completed(h, q);
44208
44209 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
44210 a = rq->head[rq->current_entry];
44211 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
44212 while (!list_empty(&h->reqQ)) {
44213 c = list_entry(h->reqQ.next, struct CommandList, list);
44214 /* can't do anything if fifo is full */
44215 - if ((h->access.fifo_full(h))) {
44216 + if ((h->access->fifo_full(h))) {
44217 dev_warn(&h->pdev->dev, "fifo full\n");
44218 break;
44219 }
44220 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
44221
44222 /* Tell the controller execute command */
44223 spin_unlock_irqrestore(&h->lock, flags);
44224 - h->access.submit_command(h, c);
44225 + h->access->submit_command(h, c);
44226 spin_lock_irqsave(&h->lock, flags);
44227 }
44228 spin_unlock_irqrestore(&h->lock, flags);
44229 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
44230
44231 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
44232 {
44233 - return h->access.command_completed(h, q);
44234 + return h->access->command_completed(h, q);
44235 }
44236
44237 static inline bool interrupt_pending(struct ctlr_info *h)
44238 {
44239 - return h->access.intr_pending(h);
44240 + return h->access->intr_pending(h);
44241 }
44242
44243 static inline long interrupt_not_for_us(struct ctlr_info *h)
44244 {
44245 - return (h->access.intr_pending(h) == 0) ||
44246 + return (h->access->intr_pending(h) == 0) ||
44247 (h->interrupts_enabled == 0);
44248 }
44249
44250 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
44251 if (prod_index < 0)
44252 return -ENODEV;
44253 h->product_name = products[prod_index].product_name;
44254 - h->access = *(products[prod_index].access);
44255 + h->access = products[prod_index].access;
44256
44257 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
44258 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
44259 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
44260
44261 assert_spin_locked(&lockup_detector_lock);
44262 remove_ctlr_from_lockup_detector_list(h);
44263 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
44264 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
44265 spin_lock_irqsave(&h->lock, flags);
44266 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
44267 spin_unlock_irqrestore(&h->lock, flags);
44268 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
44269 }
44270
44271 /* make sure the board interrupts are off */
44272 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
44273 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
44274
44275 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
44276 goto clean2;
44277 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
44278 * fake ones to scoop up any residual completions.
44279 */
44280 spin_lock_irqsave(&h->lock, flags);
44281 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
44282 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
44283 spin_unlock_irqrestore(&h->lock, flags);
44284 free_irqs(h);
44285 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
44286 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
44287 dev_info(&h->pdev->dev, "Board READY.\n");
44288 dev_info(&h->pdev->dev,
44289 "Waiting for stale completions to drain.\n");
44290 - h->access.set_intr_mask(h, HPSA_INTR_ON);
44291 + h->access->set_intr_mask(h, HPSA_INTR_ON);
44292 msleep(10000);
44293 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
44294 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
44295
44296 rc = controller_reset_failed(h->cfgtable);
44297 if (rc)
44298 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
44299 }
44300
44301 /* Turn the interrupts on so we can service requests */
44302 - h->access.set_intr_mask(h, HPSA_INTR_ON);
44303 + h->access->set_intr_mask(h, HPSA_INTR_ON);
44304
44305 hpsa_hba_inquiry(h);
44306 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
44307 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
44308 * To write all data in the battery backed cache to disks
44309 */
44310 hpsa_flush_cache(h);
44311 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
44312 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
44313 hpsa_free_irqs_and_disable_msix(h);
44314 }
44315
44316 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
44317 return;
44318 }
44319 /* Change the access methods to the performant access methods */
44320 - h->access = SA5_performant_access;
44321 + h->access = &SA5_performant_access;
44322 h->transMethod = CFGTBL_Trans_Performant;
44323 }
44324
44325 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
44326 index 9816479..c5d4e97 100644
44327 --- a/drivers/scsi/hpsa.h
44328 +++ b/drivers/scsi/hpsa.h
44329 @@ -79,7 +79,7 @@ struct ctlr_info {
44330 unsigned int msix_vector;
44331 unsigned int msi_vector;
44332 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
44333 - struct access_method access;
44334 + struct access_method *access;
44335
44336 /* queue and queue Info */
44337 struct list_head reqQ;
44338 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
44339 index 8b928c6..9c76300 100644
44340 --- a/drivers/scsi/libfc/fc_exch.c
44341 +++ b/drivers/scsi/libfc/fc_exch.c
44342 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
44343 u16 pool_max_index;
44344
44345 struct {
44346 - atomic_t no_free_exch;
44347 - atomic_t no_free_exch_xid;
44348 - atomic_t xid_not_found;
44349 - atomic_t xid_busy;
44350 - atomic_t seq_not_found;
44351 - atomic_t non_bls_resp;
44352 + atomic_unchecked_t no_free_exch;
44353 + atomic_unchecked_t no_free_exch_xid;
44354 + atomic_unchecked_t xid_not_found;
44355 + atomic_unchecked_t xid_busy;
44356 + atomic_unchecked_t seq_not_found;
44357 + atomic_unchecked_t non_bls_resp;
44358 } stats;
44359 };
44360
44361 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
44362 /* allocate memory for exchange */
44363 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
44364 if (!ep) {
44365 - atomic_inc(&mp->stats.no_free_exch);
44366 + atomic_inc_unchecked(&mp->stats.no_free_exch);
44367 goto out;
44368 }
44369 memset(ep, 0, sizeof(*ep));
44370 @@ -797,7 +797,7 @@ out:
44371 return ep;
44372 err:
44373 spin_unlock_bh(&pool->lock);
44374 - atomic_inc(&mp->stats.no_free_exch_xid);
44375 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
44376 mempool_free(ep, mp->ep_pool);
44377 return NULL;
44378 }
44379 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
44380 xid = ntohs(fh->fh_ox_id); /* we originated exch */
44381 ep = fc_exch_find(mp, xid);
44382 if (!ep) {
44383 - atomic_inc(&mp->stats.xid_not_found);
44384 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44385 reject = FC_RJT_OX_ID;
44386 goto out;
44387 }
44388 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
44389 ep = fc_exch_find(mp, xid);
44390 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
44391 if (ep) {
44392 - atomic_inc(&mp->stats.xid_busy);
44393 + atomic_inc_unchecked(&mp->stats.xid_busy);
44394 reject = FC_RJT_RX_ID;
44395 goto rel;
44396 }
44397 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
44398 }
44399 xid = ep->xid; /* get our XID */
44400 } else if (!ep) {
44401 - atomic_inc(&mp->stats.xid_not_found);
44402 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44403 reject = FC_RJT_RX_ID; /* XID not found */
44404 goto out;
44405 }
44406 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
44407 } else {
44408 sp = &ep->seq;
44409 if (sp->id != fh->fh_seq_id) {
44410 - atomic_inc(&mp->stats.seq_not_found);
44411 + atomic_inc_unchecked(&mp->stats.seq_not_found);
44412 if (f_ctl & FC_FC_END_SEQ) {
44413 /*
44414 * Update sequence_id based on incoming last
44415 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
44416
44417 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
44418 if (!ep) {
44419 - atomic_inc(&mp->stats.xid_not_found);
44420 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44421 goto out;
44422 }
44423 if (ep->esb_stat & ESB_ST_COMPLETE) {
44424 - atomic_inc(&mp->stats.xid_not_found);
44425 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44426 goto rel;
44427 }
44428 if (ep->rxid == FC_XID_UNKNOWN)
44429 ep->rxid = ntohs(fh->fh_rx_id);
44430 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
44431 - atomic_inc(&mp->stats.xid_not_found);
44432 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44433 goto rel;
44434 }
44435 if (ep->did != ntoh24(fh->fh_s_id) &&
44436 ep->did != FC_FID_FLOGI) {
44437 - atomic_inc(&mp->stats.xid_not_found);
44438 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44439 goto rel;
44440 }
44441 sof = fr_sof(fp);
44442 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
44443 sp->ssb_stat |= SSB_ST_RESP;
44444 sp->id = fh->fh_seq_id;
44445 } else if (sp->id != fh->fh_seq_id) {
44446 - atomic_inc(&mp->stats.seq_not_found);
44447 + atomic_inc_unchecked(&mp->stats.seq_not_found);
44448 goto rel;
44449 }
44450
44451 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
44452 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
44453
44454 if (!sp)
44455 - atomic_inc(&mp->stats.xid_not_found);
44456 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44457 else
44458 - atomic_inc(&mp->stats.non_bls_resp);
44459 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
44460
44461 fc_frame_free(fp);
44462 }
44463 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
44464
44465 list_for_each_entry(ema, &lport->ema_list, ema_list) {
44466 mp = ema->mp;
44467 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
44468 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
44469 st->fc_no_free_exch_xid +=
44470 - atomic_read(&mp->stats.no_free_exch_xid);
44471 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
44472 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
44473 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
44474 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
44475 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
44476 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
44477 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
44478 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
44479 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
44480 }
44481 }
44482 EXPORT_SYMBOL(fc_exch_update_stats);
44483 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
44484 index 161c98e..6d563b3 100644
44485 --- a/drivers/scsi/libsas/sas_ata.c
44486 +++ b/drivers/scsi/libsas/sas_ata.c
44487 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
44488 .postreset = ata_std_postreset,
44489 .error_handler = ata_std_error_handler,
44490 .post_internal_cmd = sas_ata_post_internal,
44491 - .qc_defer = ata_std_qc_defer,
44492 + .qc_defer = ata_std_qc_defer,
44493 .qc_prep = ata_noop_qc_prep,
44494 .qc_issue = sas_ata_qc_issue,
44495 .qc_fill_rtf = sas_ata_qc_fill_rtf,
44496 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
44497 index bcc56ca..6f4174a 100644
44498 --- a/drivers/scsi/lpfc/lpfc.h
44499 +++ b/drivers/scsi/lpfc/lpfc.h
44500 @@ -431,7 +431,7 @@ struct lpfc_vport {
44501 struct dentry *debug_nodelist;
44502 struct dentry *vport_debugfs_root;
44503 struct lpfc_debugfs_trc *disc_trc;
44504 - atomic_t disc_trc_cnt;
44505 + atomic_unchecked_t disc_trc_cnt;
44506 #endif
44507 uint8_t stat_data_enabled;
44508 uint8_t stat_data_blocked;
44509 @@ -865,8 +865,8 @@ struct lpfc_hba {
44510 struct timer_list fabric_block_timer;
44511 unsigned long bit_flags;
44512 #define FABRIC_COMANDS_BLOCKED 0
44513 - atomic_t num_rsrc_err;
44514 - atomic_t num_cmd_success;
44515 + atomic_unchecked_t num_rsrc_err;
44516 + atomic_unchecked_t num_cmd_success;
44517 unsigned long last_rsrc_error_time;
44518 unsigned long last_ramp_down_time;
44519 unsigned long last_ramp_up_time;
44520 @@ -902,7 +902,7 @@ struct lpfc_hba {
44521
44522 struct dentry *debug_slow_ring_trc;
44523 struct lpfc_debugfs_trc *slow_ring_trc;
44524 - atomic_t slow_ring_trc_cnt;
44525 + atomic_unchecked_t slow_ring_trc_cnt;
44526 /* iDiag debugfs sub-directory */
44527 struct dentry *idiag_root;
44528 struct dentry *idiag_pci_cfg;
44529 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
44530 index f525ecb..32549a4 100644
44531 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
44532 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
44533 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
44534
44535 #include <linux/debugfs.h>
44536
44537 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
44538 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
44539 static unsigned long lpfc_debugfs_start_time = 0L;
44540
44541 /* iDiag */
44542 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
44543 lpfc_debugfs_enable = 0;
44544
44545 len = 0;
44546 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
44547 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
44548 (lpfc_debugfs_max_disc_trc - 1);
44549 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
44550 dtp = vport->disc_trc + i;
44551 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
44552 lpfc_debugfs_enable = 0;
44553
44554 len = 0;
44555 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
44556 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
44557 (lpfc_debugfs_max_slow_ring_trc - 1);
44558 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
44559 dtp = phba->slow_ring_trc + i;
44560 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
44561 !vport || !vport->disc_trc)
44562 return;
44563
44564 - index = atomic_inc_return(&vport->disc_trc_cnt) &
44565 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
44566 (lpfc_debugfs_max_disc_trc - 1);
44567 dtp = vport->disc_trc + index;
44568 dtp->fmt = fmt;
44569 dtp->data1 = data1;
44570 dtp->data2 = data2;
44571 dtp->data3 = data3;
44572 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
44573 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
44574 dtp->jif = jiffies;
44575 #endif
44576 return;
44577 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
44578 !phba || !phba->slow_ring_trc)
44579 return;
44580
44581 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
44582 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
44583 (lpfc_debugfs_max_slow_ring_trc - 1);
44584 dtp = phba->slow_ring_trc + index;
44585 dtp->fmt = fmt;
44586 dtp->data1 = data1;
44587 dtp->data2 = data2;
44588 dtp->data3 = data3;
44589 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
44590 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
44591 dtp->jif = jiffies;
44592 #endif
44593 return;
44594 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
44595 "slow_ring buffer\n");
44596 goto debug_failed;
44597 }
44598 - atomic_set(&phba->slow_ring_trc_cnt, 0);
44599 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
44600 memset(phba->slow_ring_trc, 0,
44601 (sizeof(struct lpfc_debugfs_trc) *
44602 lpfc_debugfs_max_slow_ring_trc));
44603 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
44604 "buffer\n");
44605 goto debug_failed;
44606 }
44607 - atomic_set(&vport->disc_trc_cnt, 0);
44608 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
44609
44610 snprintf(name, sizeof(name), "discovery_trace");
44611 vport->debug_disc_trc =
44612 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
44613 index cb465b2..2e7b25f 100644
44614 --- a/drivers/scsi/lpfc/lpfc_init.c
44615 +++ b/drivers/scsi/lpfc/lpfc_init.c
44616 @@ -10950,8 +10950,10 @@ lpfc_init(void)
44617 "misc_register returned with status %d", error);
44618
44619 if (lpfc_enable_npiv) {
44620 - lpfc_transport_functions.vport_create = lpfc_vport_create;
44621 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
44622 + pax_open_kernel();
44623 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
44624 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
44625 + pax_close_kernel();
44626 }
44627 lpfc_transport_template =
44628 fc_attach_transport(&lpfc_transport_functions);
44629 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
44630 index 8523b278e..ce1d812 100644
44631 --- a/drivers/scsi/lpfc/lpfc_scsi.c
44632 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
44633 @@ -331,7 +331,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
44634 uint32_t evt_posted;
44635
44636 spin_lock_irqsave(&phba->hbalock, flags);
44637 - atomic_inc(&phba->num_rsrc_err);
44638 + atomic_inc_unchecked(&phba->num_rsrc_err);
44639 phba->last_rsrc_error_time = jiffies;
44640
44641 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
44642 @@ -372,7 +372,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
44643 unsigned long flags;
44644 struct lpfc_hba *phba = vport->phba;
44645 uint32_t evt_posted;
44646 - atomic_inc(&phba->num_cmd_success);
44647 + atomic_inc_unchecked(&phba->num_cmd_success);
44648
44649 if (vport->cfg_lun_queue_depth <= queue_depth)
44650 return;
44651 @@ -416,8 +416,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
44652 unsigned long num_rsrc_err, num_cmd_success;
44653 int i;
44654
44655 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
44656 - num_cmd_success = atomic_read(&phba->num_cmd_success);
44657 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
44658 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
44659
44660 /*
44661 * The error and success command counters are global per
44662 @@ -445,8 +445,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
44663 }
44664 }
44665 lpfc_destroy_vport_work_array(phba, vports);
44666 - atomic_set(&phba->num_rsrc_err, 0);
44667 - atomic_set(&phba->num_cmd_success, 0);
44668 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
44669 + atomic_set_unchecked(&phba->num_cmd_success, 0);
44670 }
44671
44672 /**
44673 @@ -480,8 +480,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
44674 }
44675 }
44676 lpfc_destroy_vport_work_array(phba, vports);
44677 - atomic_set(&phba->num_rsrc_err, 0);
44678 - atomic_set(&phba->num_cmd_success, 0);
44679 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
44680 + atomic_set_unchecked(&phba->num_cmd_success, 0);
44681 }
44682
44683 /**
44684 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
44685 index 8e1b737..50ff510 100644
44686 --- a/drivers/scsi/pmcraid.c
44687 +++ b/drivers/scsi/pmcraid.c
44688 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
44689 res->scsi_dev = scsi_dev;
44690 scsi_dev->hostdata = res;
44691 res->change_detected = 0;
44692 - atomic_set(&res->read_failures, 0);
44693 - atomic_set(&res->write_failures, 0);
44694 + atomic_set_unchecked(&res->read_failures, 0);
44695 + atomic_set_unchecked(&res->write_failures, 0);
44696 rc = 0;
44697 }
44698 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
44699 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
44700
44701 /* If this was a SCSI read/write command keep count of errors */
44702 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
44703 - atomic_inc(&res->read_failures);
44704 + atomic_inc_unchecked(&res->read_failures);
44705 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
44706 - atomic_inc(&res->write_failures);
44707 + atomic_inc_unchecked(&res->write_failures);
44708
44709 if (!RES_IS_GSCSI(res->cfg_entry) &&
44710 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
44711 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
44712 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
44713 * hrrq_id assigned here in queuecommand
44714 */
44715 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
44716 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
44717 pinstance->num_hrrq;
44718 cmd->cmd_done = pmcraid_io_done;
44719
44720 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
44721 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
44722 * hrrq_id assigned here in queuecommand
44723 */
44724 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
44725 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
44726 pinstance->num_hrrq;
44727
44728 if (request_size) {
44729 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
44730
44731 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
44732 /* add resources only after host is added into system */
44733 - if (!atomic_read(&pinstance->expose_resources))
44734 + if (!atomic_read_unchecked(&pinstance->expose_resources))
44735 return;
44736
44737 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
44738 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
44739 init_waitqueue_head(&pinstance->reset_wait_q);
44740
44741 atomic_set(&pinstance->outstanding_cmds, 0);
44742 - atomic_set(&pinstance->last_message_id, 0);
44743 - atomic_set(&pinstance->expose_resources, 0);
44744 + atomic_set_unchecked(&pinstance->last_message_id, 0);
44745 + atomic_set_unchecked(&pinstance->expose_resources, 0);
44746
44747 INIT_LIST_HEAD(&pinstance->free_res_q);
44748 INIT_LIST_HEAD(&pinstance->used_res_q);
44749 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
44750 /* Schedule worker thread to handle CCN and take care of adding and
44751 * removing devices to OS
44752 */
44753 - atomic_set(&pinstance->expose_resources, 1);
44754 + atomic_set_unchecked(&pinstance->expose_resources, 1);
44755 schedule_work(&pinstance->worker_q);
44756 return rc;
44757
44758 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
44759 index e1d150f..6c6df44 100644
44760 --- a/drivers/scsi/pmcraid.h
44761 +++ b/drivers/scsi/pmcraid.h
44762 @@ -748,7 +748,7 @@ struct pmcraid_instance {
44763 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
44764
44765 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
44766 - atomic_t last_message_id;
44767 + atomic_unchecked_t last_message_id;
44768
44769 /* configuration table */
44770 struct pmcraid_config_table *cfg_table;
44771 @@ -777,7 +777,7 @@ struct pmcraid_instance {
44772 atomic_t outstanding_cmds;
44773
44774 /* should add/delete resources to mid-layer now ?*/
44775 - atomic_t expose_resources;
44776 + atomic_unchecked_t expose_resources;
44777
44778
44779
44780 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
44781 struct pmcraid_config_table_entry_ext cfg_entry_ext;
44782 };
44783 struct scsi_device *scsi_dev; /* Link scsi_device structure */
44784 - atomic_t read_failures; /* count of failed READ commands */
44785 - atomic_t write_failures; /* count of failed WRITE commands */
44786 + atomic_unchecked_t read_failures; /* count of failed READ commands */
44787 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
44788
44789 /* To indicate add/delete/modify during CCN */
44790 u8 change_detected;
44791 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
44792 index bf60c63..74d4dce 100644
44793 --- a/drivers/scsi/qla2xxx/qla_attr.c
44794 +++ b/drivers/scsi/qla2xxx/qla_attr.c
44795 @@ -2001,7 +2001,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
44796 return 0;
44797 }
44798
44799 -struct fc_function_template qla2xxx_transport_functions = {
44800 +fc_function_template_no_const qla2xxx_transport_functions = {
44801
44802 .show_host_node_name = 1,
44803 .show_host_port_name = 1,
44804 @@ -2048,7 +2048,7 @@ struct fc_function_template qla2xxx_transport_functions = {
44805 .bsg_timeout = qla24xx_bsg_timeout,
44806 };
44807
44808 -struct fc_function_template qla2xxx_transport_vport_functions = {
44809 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
44810
44811 .show_host_node_name = 1,
44812 .show_host_port_name = 1,
44813 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
44814 index 026bfde..90c4018 100644
44815 --- a/drivers/scsi/qla2xxx/qla_gbl.h
44816 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
44817 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
44818 struct device_attribute;
44819 extern struct device_attribute *qla2x00_host_attrs[];
44820 struct fc_function_template;
44821 -extern struct fc_function_template qla2xxx_transport_functions;
44822 -extern struct fc_function_template qla2xxx_transport_vport_functions;
44823 +extern fc_function_template_no_const qla2xxx_transport_functions;
44824 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
44825 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
44826 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
44827 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
44828 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
44829 index ad72c1d..afc9a98 100644
44830 --- a/drivers/scsi/qla2xxx/qla_os.c
44831 +++ b/drivers/scsi/qla2xxx/qla_os.c
44832 @@ -1571,8 +1571,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
44833 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
44834 /* Ok, a 64bit DMA mask is applicable. */
44835 ha->flags.enable_64bit_addressing = 1;
44836 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
44837 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
44838 + pax_open_kernel();
44839 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
44840 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
44841 + pax_close_kernel();
44842 return;
44843 }
44844 }
44845 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
44846 index ddf16a8..80f4dd0 100644
44847 --- a/drivers/scsi/qla4xxx/ql4_def.h
44848 +++ b/drivers/scsi/qla4xxx/ql4_def.h
44849 @@ -291,7 +291,7 @@ struct ddb_entry {
44850 * (4000 only) */
44851 atomic_t relogin_timer; /* Max Time to wait for
44852 * relogin to complete */
44853 - atomic_t relogin_retry_count; /* Num of times relogin has been
44854 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
44855 * retried */
44856 uint32_t default_time2wait; /* Default Min time between
44857 * relogins (+aens) */
44858 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
44859 index 4d231c1..2892c37 100644
44860 --- a/drivers/scsi/qla4xxx/ql4_os.c
44861 +++ b/drivers/scsi/qla4xxx/ql4_os.c
44862 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
44863 */
44864 if (!iscsi_is_session_online(cls_sess)) {
44865 /* Reset retry relogin timer */
44866 - atomic_inc(&ddb_entry->relogin_retry_count);
44867 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
44868 DEBUG2(ql4_printk(KERN_INFO, ha,
44869 "%s: index[%d] relogin timed out-retrying"
44870 " relogin (%d), retry (%d)\n", __func__,
44871 ddb_entry->fw_ddb_index,
44872 - atomic_read(&ddb_entry->relogin_retry_count),
44873 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
44874 ddb_entry->default_time2wait + 4));
44875 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
44876 atomic_set(&ddb_entry->retry_relogin_timer,
44877 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
44878
44879 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
44880 atomic_set(&ddb_entry->relogin_timer, 0);
44881 - atomic_set(&ddb_entry->relogin_retry_count, 0);
44882 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
44883 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
44884 ddb_entry->default_relogin_timeout =
44885 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
44886 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
44887 index eaa808e..95f8841 100644
44888 --- a/drivers/scsi/scsi.c
44889 +++ b/drivers/scsi/scsi.c
44890 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
44891 unsigned long timeout;
44892 int rtn = 0;
44893
44894 - atomic_inc(&cmd->device->iorequest_cnt);
44895 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
44896
44897 /* check if the device is still usable */
44898 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
44899 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
44900 index 86d5220..f22c51a 100644
44901 --- a/drivers/scsi/scsi_lib.c
44902 +++ b/drivers/scsi/scsi_lib.c
44903 @@ -1458,7 +1458,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
44904 shost = sdev->host;
44905 scsi_init_cmd_errh(cmd);
44906 cmd->result = DID_NO_CONNECT << 16;
44907 - atomic_inc(&cmd->device->iorequest_cnt);
44908 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
44909
44910 /*
44911 * SCSI request completion path will do scsi_device_unbusy(),
44912 @@ -1484,9 +1484,9 @@ static void scsi_softirq_done(struct request *rq)
44913
44914 INIT_LIST_HEAD(&cmd->eh_entry);
44915
44916 - atomic_inc(&cmd->device->iodone_cnt);
44917 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
44918 if (cmd->result)
44919 - atomic_inc(&cmd->device->ioerr_cnt);
44920 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
44921
44922 disposition = scsi_decide_disposition(cmd);
44923 if (disposition != SUCCESS &&
44924 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
44925 index 931a7d9..0c2a754 100644
44926 --- a/drivers/scsi/scsi_sysfs.c
44927 +++ b/drivers/scsi/scsi_sysfs.c
44928 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
44929 char *buf) \
44930 { \
44931 struct scsi_device *sdev = to_scsi_device(dev); \
44932 - unsigned long long count = atomic_read(&sdev->field); \
44933 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
44934 return snprintf(buf, 20, "0x%llx\n", count); \
44935 } \
44936 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
44937 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
44938 index 84a1fdf..693b0d6 100644
44939 --- a/drivers/scsi/scsi_tgt_lib.c
44940 +++ b/drivers/scsi/scsi_tgt_lib.c
44941 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
44942 int err;
44943
44944 dprintk("%lx %u\n", uaddr, len);
44945 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
44946 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
44947 if (err) {
44948 /*
44949 * TODO: need to fixup sg_tablesize, max_segment_size,
44950 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
44951 index e106c27..11a380e 100644
44952 --- a/drivers/scsi/scsi_transport_fc.c
44953 +++ b/drivers/scsi/scsi_transport_fc.c
44954 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
44955 * Netlink Infrastructure
44956 */
44957
44958 -static atomic_t fc_event_seq;
44959 +static atomic_unchecked_t fc_event_seq;
44960
44961 /**
44962 * fc_get_event_number - Obtain the next sequential FC event number
44963 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
44964 u32
44965 fc_get_event_number(void)
44966 {
44967 - return atomic_add_return(1, &fc_event_seq);
44968 + return atomic_add_return_unchecked(1, &fc_event_seq);
44969 }
44970 EXPORT_SYMBOL(fc_get_event_number);
44971
44972 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
44973 {
44974 int error;
44975
44976 - atomic_set(&fc_event_seq, 0);
44977 + atomic_set_unchecked(&fc_event_seq, 0);
44978
44979 error = transport_class_register(&fc_host_class);
44980 if (error)
44981 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
44982 char *cp;
44983
44984 *val = simple_strtoul(buf, &cp, 0);
44985 - if ((*cp && (*cp != '\n')) || (*val < 0))
44986 + if (*cp && (*cp != '\n'))
44987 return -EINVAL;
44988 /*
44989 * Check for overflow; dev_loss_tmo is u32
44990 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
44991 index 133926b..903000d 100644
44992 --- a/drivers/scsi/scsi_transport_iscsi.c
44993 +++ b/drivers/scsi/scsi_transport_iscsi.c
44994 @@ -80,7 +80,7 @@ struct iscsi_internal {
44995 struct transport_container session_cont;
44996 };
44997
44998 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
44999 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
45000 static struct workqueue_struct *iscsi_eh_timer_workq;
45001
45002 static DEFINE_IDA(iscsi_sess_ida);
45003 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
45004 int err;
45005
45006 ihost = shost->shost_data;
45007 - session->sid = atomic_add_return(1, &iscsi_session_nr);
45008 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
45009
45010 if (target_id == ISCSI_MAX_TARGET) {
45011 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
45012 @@ -3944,7 +3944,7 @@ static __init int iscsi_transport_init(void)
45013 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
45014 ISCSI_TRANSPORT_VERSION);
45015
45016 - atomic_set(&iscsi_session_nr, 0);
45017 + atomic_set_unchecked(&iscsi_session_nr, 0);
45018
45019 err = class_register(&iscsi_transport_class);
45020 if (err)
45021 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
45022 index f379c7f..e8fc69c 100644
45023 --- a/drivers/scsi/scsi_transport_srp.c
45024 +++ b/drivers/scsi/scsi_transport_srp.c
45025 @@ -33,7 +33,7 @@
45026 #include "scsi_transport_srp_internal.h"
45027
45028 struct srp_host_attrs {
45029 - atomic_t next_port_id;
45030 + atomic_unchecked_t next_port_id;
45031 };
45032 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
45033
45034 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
45035 struct Scsi_Host *shost = dev_to_shost(dev);
45036 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
45037
45038 - atomic_set(&srp_host->next_port_id, 0);
45039 + atomic_set_unchecked(&srp_host->next_port_id, 0);
45040 return 0;
45041 }
45042
45043 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
45044 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
45045 rport->roles = ids->roles;
45046
45047 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
45048 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
45049 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
45050
45051 transport_setup_device(&rport->dev);
45052 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
45053 index 610417e..1544fa9 100644
45054 --- a/drivers/scsi/sd.c
45055 +++ b/drivers/scsi/sd.c
45056 @@ -2928,7 +2928,7 @@ static int sd_probe(struct device *dev)
45057 sdkp->disk = gd;
45058 sdkp->index = index;
45059 atomic_set(&sdkp->openers, 0);
45060 - atomic_set(&sdkp->device->ioerr_cnt, 0);
45061 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
45062
45063 if (!sdp->request_queue->rq_timeout) {
45064 if (sdp->type != TYPE_MOD)
45065 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
45066 index df5e961..df6b97f 100644
45067 --- a/drivers/scsi/sg.c
45068 +++ b/drivers/scsi/sg.c
45069 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
45070 sdp->disk->disk_name,
45071 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
45072 NULL,
45073 - (char *)arg);
45074 + (char __user *)arg);
45075 case BLKTRACESTART:
45076 return blk_trace_startstop(sdp->device->request_queue, 1);
45077 case BLKTRACESTOP:
45078 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
45079 index 32b7bb1..2f1c4bd 100644
45080 --- a/drivers/spi/spi.c
45081 +++ b/drivers/spi/spi.c
45082 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
45083 EXPORT_SYMBOL_GPL(spi_bus_unlock);
45084
45085 /* portable code must never pass more than 32 bytes */
45086 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
45087 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
45088
45089 static u8 *buf;
45090
45091 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
45092 index 3675020..e80d92c 100644
45093 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
45094 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
45095 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
45096
45097 static int solo_sysfs_init(struct solo_dev *solo_dev)
45098 {
45099 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
45100 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
45101 struct device *dev = &solo_dev->dev;
45102 const char *driver;
45103 int i;
45104 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
45105 index 34afc16..ffe44dd 100644
45106 --- a/drivers/staging/octeon/ethernet-rx.c
45107 +++ b/drivers/staging/octeon/ethernet-rx.c
45108 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
45109 /* Increment RX stats for virtual ports */
45110 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
45111 #ifdef CONFIG_64BIT
45112 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
45113 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
45114 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
45115 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
45116 #else
45117 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
45118 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
45119 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
45120 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
45121 #endif
45122 }
45123 netif_receive_skb(skb);
45124 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
45125 dev->name);
45126 */
45127 #ifdef CONFIG_64BIT
45128 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
45129 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
45130 #else
45131 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
45132 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
45133 #endif
45134 dev_kfree_skb_irq(skb);
45135 }
45136 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
45137 index c3a90e7..023619a 100644
45138 --- a/drivers/staging/octeon/ethernet.c
45139 +++ b/drivers/staging/octeon/ethernet.c
45140 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
45141 * since the RX tasklet also increments it.
45142 */
45143 #ifdef CONFIG_64BIT
45144 - atomic64_add(rx_status.dropped_packets,
45145 - (atomic64_t *)&priv->stats.rx_dropped);
45146 + atomic64_add_unchecked(rx_status.dropped_packets,
45147 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
45148 #else
45149 - atomic_add(rx_status.dropped_packets,
45150 - (atomic_t *)&priv->stats.rx_dropped);
45151 + atomic_add_unchecked(rx_status.dropped_packets,
45152 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
45153 #endif
45154 }
45155
45156 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
45157 index dc23395..cf7e9b1 100644
45158 --- a/drivers/staging/rtl8712/rtl871x_io.h
45159 +++ b/drivers/staging/rtl8712/rtl871x_io.h
45160 @@ -108,7 +108,7 @@ struct _io_ops {
45161 u8 *pmem);
45162 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
45163 u8 *pmem);
45164 -};
45165 +} __no_const;
45166
45167 struct io_req {
45168 struct list_head list;
45169 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
45170 index 1f5088b..0e59820 100644
45171 --- a/drivers/staging/sbe-2t3e3/netdev.c
45172 +++ b/drivers/staging/sbe-2t3e3/netdev.c
45173 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
45174 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
45175
45176 if (rlen)
45177 - if (copy_to_user(data, &resp, rlen))
45178 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
45179 return -EFAULT;
45180
45181 return 0;
45182 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
45183 index a863a98..d272795 100644
45184 --- a/drivers/staging/usbip/vhci.h
45185 +++ b/drivers/staging/usbip/vhci.h
45186 @@ -83,7 +83,7 @@ struct vhci_hcd {
45187 unsigned resuming:1;
45188 unsigned long re_timeout;
45189
45190 - atomic_t seqnum;
45191 + atomic_unchecked_t seqnum;
45192
45193 /*
45194 * NOTE:
45195 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
45196 index d7974cb..d78076b 100644
45197 --- a/drivers/staging/usbip/vhci_hcd.c
45198 +++ b/drivers/staging/usbip/vhci_hcd.c
45199 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
45200
45201 spin_lock(&vdev->priv_lock);
45202
45203 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
45204 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
45205 if (priv->seqnum == 0xffff)
45206 dev_info(&urb->dev->dev, "seqnum max\n");
45207
45208 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
45209 return -ENOMEM;
45210 }
45211
45212 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
45213 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
45214 if (unlink->seqnum == 0xffff)
45215 pr_info("seqnum max\n");
45216
45217 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
45218 vdev->rhport = rhport;
45219 }
45220
45221 - atomic_set(&vhci->seqnum, 0);
45222 + atomic_set_unchecked(&vhci->seqnum, 0);
45223 spin_lock_init(&vhci->lock);
45224
45225 hcd->power_budget = 0; /* no limit */
45226 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
45227 index d07fcb5..358e1e1 100644
45228 --- a/drivers/staging/usbip/vhci_rx.c
45229 +++ b/drivers/staging/usbip/vhci_rx.c
45230 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
45231 if (!urb) {
45232 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
45233 pr_info("max seqnum %d\n",
45234 - atomic_read(&the_controller->seqnum));
45235 + atomic_read_unchecked(&the_controller->seqnum));
45236 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
45237 return;
45238 }
45239 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
45240 index 8417c2f..ef5ebd6 100644
45241 --- a/drivers/staging/vt6655/hostap.c
45242 +++ b/drivers/staging/vt6655/hostap.c
45243 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
45244 *
45245 */
45246
45247 +static net_device_ops_no_const apdev_netdev_ops;
45248 +
45249 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
45250 {
45251 PSDevice apdev_priv;
45252 struct net_device *dev = pDevice->dev;
45253 int ret;
45254 - const struct net_device_ops apdev_netdev_ops = {
45255 - .ndo_start_xmit = pDevice->tx_80211,
45256 - };
45257
45258 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
45259
45260 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
45261 *apdev_priv = *pDevice;
45262 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
45263
45264 + /* only half broken now */
45265 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
45266 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
45267
45268 pDevice->apdev->type = ARPHRD_IEEE80211;
45269 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
45270 index c699a30..b90a5fd 100644
45271 --- a/drivers/staging/vt6656/hostap.c
45272 +++ b/drivers/staging/vt6656/hostap.c
45273 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
45274 *
45275 */
45276
45277 +static net_device_ops_no_const apdev_netdev_ops;
45278 +
45279 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
45280 {
45281 struct vnt_private *apdev_priv;
45282 struct net_device *dev = pDevice->dev;
45283 int ret;
45284 - const struct net_device_ops apdev_netdev_ops = {
45285 - .ndo_start_xmit = pDevice->tx_80211,
45286 - };
45287
45288 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
45289
45290 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
45291 *apdev_priv = *pDevice;
45292 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
45293
45294 + /* only half broken now */
45295 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
45296 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
45297
45298 pDevice->apdev->type = ARPHRD_IEEE80211;
45299 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
45300 index d7e51e4..d07eaab 100644
45301 --- a/drivers/staging/zcache/tmem.c
45302 +++ b/drivers/staging/zcache/tmem.c
45303 @@ -51,7 +51,7 @@
45304 * A tmem host implementation must use this function to register callbacks
45305 * for memory allocation.
45306 */
45307 -static struct tmem_hostops tmem_hostops;
45308 +static tmem_hostops_no_const tmem_hostops;
45309
45310 static void tmem_objnode_tree_init(void);
45311
45312 @@ -65,7 +65,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
45313 * A tmem host implementation must use this function to register
45314 * callbacks for a page-accessible memory (PAM) implementation.
45315 */
45316 -static struct tmem_pamops tmem_pamops;
45317 +static tmem_pamops_no_const tmem_pamops;
45318
45319 void tmem_register_pamops(struct tmem_pamops *m)
45320 {
45321 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
45322 index d128ce2..a43980c 100644
45323 --- a/drivers/staging/zcache/tmem.h
45324 +++ b/drivers/staging/zcache/tmem.h
45325 @@ -226,6 +226,7 @@ struct tmem_pamops {
45326 int (*replace_in_obj)(void *, struct tmem_obj *);
45327 #endif
45328 };
45329 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
45330 extern void tmem_register_pamops(struct tmem_pamops *m);
45331
45332 /* memory allocation methods provided by the host implementation */
45333 @@ -235,6 +236,7 @@ struct tmem_hostops {
45334 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
45335 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
45336 };
45337 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
45338 extern void tmem_register_hostops(struct tmem_hostops *m);
45339
45340 /* core tmem accessor functions */
45341 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
45342 index 4630481..c26782a 100644
45343 --- a/drivers/target/target_core_device.c
45344 +++ b/drivers/target/target_core_device.c
45345 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
45346 spin_lock_init(&dev->se_port_lock);
45347 spin_lock_init(&dev->se_tmr_lock);
45348 spin_lock_init(&dev->qf_cmd_lock);
45349 - atomic_set(&dev->dev_ordered_id, 0);
45350 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
45351 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
45352 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
45353 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
45354 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
45355 index 21e3158..43c6004 100644
45356 --- a/drivers/target/target_core_transport.c
45357 +++ b/drivers/target/target_core_transport.c
45358 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
45359 * Used to determine when ORDERED commands should go from
45360 * Dormant to Active status.
45361 */
45362 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
45363 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
45364 smp_mb__after_atomic_inc();
45365 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
45366 cmd->se_ordered_id, cmd->sam_task_attr,
45367 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
45368 index 33f83fe..d80f8e1 100644
45369 --- a/drivers/tty/cyclades.c
45370 +++ b/drivers/tty/cyclades.c
45371 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
45372 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
45373 info->port.count);
45374 #endif
45375 - info->port.count++;
45376 + atomic_inc(&info->port.count);
45377 #ifdef CY_DEBUG_COUNT
45378 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
45379 - current->pid, info->port.count);
45380 + current->pid, atomic_read(&info->port.count));
45381 #endif
45382
45383 /*
45384 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
45385 for (j = 0; j < cy_card[i].nports; j++) {
45386 info = &cy_card[i].ports[j];
45387
45388 - if (info->port.count) {
45389 + if (atomic_read(&info->port.count)) {
45390 /* XXX is the ldisc num worth this? */
45391 struct tty_struct *tty;
45392 struct tty_ldisc *ld;
45393 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
45394 index eb255e8..f637a57 100644
45395 --- a/drivers/tty/hvc/hvc_console.c
45396 +++ b/drivers/tty/hvc/hvc_console.c
45397 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
45398
45399 spin_lock_irqsave(&hp->port.lock, flags);
45400 /* Check and then increment for fast path open. */
45401 - if (hp->port.count++ > 0) {
45402 + if (atomic_inc_return(&hp->port.count) > 1) {
45403 spin_unlock_irqrestore(&hp->port.lock, flags);
45404 hvc_kick();
45405 return 0;
45406 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
45407
45408 spin_lock_irqsave(&hp->port.lock, flags);
45409
45410 - if (--hp->port.count == 0) {
45411 + if (atomic_dec_return(&hp->port.count) == 0) {
45412 spin_unlock_irqrestore(&hp->port.lock, flags);
45413 /* We are done with the tty pointer now. */
45414 tty_port_tty_set(&hp->port, NULL);
45415 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
45416 */
45417 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
45418 } else {
45419 - if (hp->port.count < 0)
45420 + if (atomic_read(&hp->port.count) < 0)
45421 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
45422 - hp->vtermno, hp->port.count);
45423 + hp->vtermno, atomic_read(&hp->port.count));
45424 spin_unlock_irqrestore(&hp->port.lock, flags);
45425 }
45426 }
45427 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
45428 * open->hangup case this can be called after the final close so prevent
45429 * that from happening for now.
45430 */
45431 - if (hp->port.count <= 0) {
45432 + if (atomic_read(&hp->port.count) <= 0) {
45433 spin_unlock_irqrestore(&hp->port.lock, flags);
45434 return;
45435 }
45436
45437 - hp->port.count = 0;
45438 + atomic_set(&hp->port.count, 0);
45439 spin_unlock_irqrestore(&hp->port.lock, flags);
45440 tty_port_tty_set(&hp->port, NULL);
45441
45442 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
45443 return -EPIPE;
45444
45445 /* FIXME what's this (unprotected) check for? */
45446 - if (hp->port.count <= 0)
45447 + if (atomic_read(&hp->port.count) <= 0)
45448 return -EIO;
45449
45450 spin_lock_irqsave(&hp->lock, flags);
45451 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
45452 index 81e939e..95ead10 100644
45453 --- a/drivers/tty/hvc/hvcs.c
45454 +++ b/drivers/tty/hvc/hvcs.c
45455 @@ -83,6 +83,7 @@
45456 #include <asm/hvcserver.h>
45457 #include <asm/uaccess.h>
45458 #include <asm/vio.h>
45459 +#include <asm/local.h>
45460
45461 /*
45462 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
45463 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
45464
45465 spin_lock_irqsave(&hvcsd->lock, flags);
45466
45467 - if (hvcsd->port.count > 0) {
45468 + if (atomic_read(&hvcsd->port.count) > 0) {
45469 spin_unlock_irqrestore(&hvcsd->lock, flags);
45470 printk(KERN_INFO "HVCS: vterm state unchanged. "
45471 "The hvcs device node is still in use.\n");
45472 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
45473 }
45474 }
45475
45476 - hvcsd->port.count = 0;
45477 + atomic_set(&hvcsd->port.count, 0);
45478 hvcsd->port.tty = tty;
45479 tty->driver_data = hvcsd;
45480
45481 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
45482 unsigned long flags;
45483
45484 spin_lock_irqsave(&hvcsd->lock, flags);
45485 - hvcsd->port.count++;
45486 + atomic_inc(&hvcsd->port.count);
45487 hvcsd->todo_mask |= HVCS_SCHED_READ;
45488 spin_unlock_irqrestore(&hvcsd->lock, flags);
45489
45490 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
45491 hvcsd = tty->driver_data;
45492
45493 spin_lock_irqsave(&hvcsd->lock, flags);
45494 - if (--hvcsd->port.count == 0) {
45495 + if (atomic_dec_and_test(&hvcsd->port.count)) {
45496
45497 vio_disable_interrupts(hvcsd->vdev);
45498
45499 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
45500
45501 free_irq(irq, hvcsd);
45502 return;
45503 - } else if (hvcsd->port.count < 0) {
45504 + } else if (atomic_read(&hvcsd->port.count) < 0) {
45505 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
45506 " is missmanaged.\n",
45507 - hvcsd->vdev->unit_address, hvcsd->port.count);
45508 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
45509 }
45510
45511 spin_unlock_irqrestore(&hvcsd->lock, flags);
45512 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
45513
45514 spin_lock_irqsave(&hvcsd->lock, flags);
45515 /* Preserve this so that we know how many kref refs to put */
45516 - temp_open_count = hvcsd->port.count;
45517 + temp_open_count = atomic_read(&hvcsd->port.count);
45518
45519 /*
45520 * Don't kref put inside the spinlock because the destruction
45521 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
45522 tty->driver_data = NULL;
45523 hvcsd->port.tty = NULL;
45524
45525 - hvcsd->port.count = 0;
45526 + atomic_set(&hvcsd->port.count, 0);
45527
45528 /* This will drop any buffered data on the floor which is OK in a hangup
45529 * scenario. */
45530 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
45531 * the middle of a write operation? This is a crummy place to do this
45532 * but we want to keep it all in the spinlock.
45533 */
45534 - if (hvcsd->port.count <= 0) {
45535 + if (atomic_read(&hvcsd->port.count) <= 0) {
45536 spin_unlock_irqrestore(&hvcsd->lock, flags);
45537 return -ENODEV;
45538 }
45539 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
45540 {
45541 struct hvcs_struct *hvcsd = tty->driver_data;
45542
45543 - if (!hvcsd || hvcsd->port.count <= 0)
45544 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
45545 return 0;
45546
45547 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
45548 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
45549 index 8fd72ff..34a0bed 100644
45550 --- a/drivers/tty/ipwireless/tty.c
45551 +++ b/drivers/tty/ipwireless/tty.c
45552 @@ -29,6 +29,7 @@
45553 #include <linux/tty_driver.h>
45554 #include <linux/tty_flip.h>
45555 #include <linux/uaccess.h>
45556 +#include <asm/local.h>
45557
45558 #include "tty.h"
45559 #include "network.h"
45560 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
45561 mutex_unlock(&tty->ipw_tty_mutex);
45562 return -ENODEV;
45563 }
45564 - if (tty->port.count == 0)
45565 + if (atomic_read(&tty->port.count) == 0)
45566 tty->tx_bytes_queued = 0;
45567
45568 - tty->port.count++;
45569 + atomic_inc(&tty->port.count);
45570
45571 tty->port.tty = linux_tty;
45572 linux_tty->driver_data = tty;
45573 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
45574
45575 static void do_ipw_close(struct ipw_tty *tty)
45576 {
45577 - tty->port.count--;
45578 -
45579 - if (tty->port.count == 0) {
45580 + if (atomic_dec_return(&tty->port.count) == 0) {
45581 struct tty_struct *linux_tty = tty->port.tty;
45582
45583 if (linux_tty != NULL) {
45584 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
45585 return;
45586
45587 mutex_lock(&tty->ipw_tty_mutex);
45588 - if (tty->port.count == 0) {
45589 + if (atomic_read(&tty->port.count) == 0) {
45590 mutex_unlock(&tty->ipw_tty_mutex);
45591 return;
45592 }
45593 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
45594
45595 mutex_lock(&tty->ipw_tty_mutex);
45596
45597 - if (!tty->port.count) {
45598 + if (!atomic_read(&tty->port.count)) {
45599 mutex_unlock(&tty->ipw_tty_mutex);
45600 return;
45601 }
45602 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
45603 return -ENODEV;
45604
45605 mutex_lock(&tty->ipw_tty_mutex);
45606 - if (!tty->port.count) {
45607 + if (!atomic_read(&tty->port.count)) {
45608 mutex_unlock(&tty->ipw_tty_mutex);
45609 return -EINVAL;
45610 }
45611 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
45612 if (!tty)
45613 return -ENODEV;
45614
45615 - if (!tty->port.count)
45616 + if (!atomic_read(&tty->port.count))
45617 return -EINVAL;
45618
45619 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
45620 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
45621 if (!tty)
45622 return 0;
45623
45624 - if (!tty->port.count)
45625 + if (!atomic_read(&tty->port.count))
45626 return 0;
45627
45628 return tty->tx_bytes_queued;
45629 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
45630 if (!tty)
45631 return -ENODEV;
45632
45633 - if (!tty->port.count)
45634 + if (!atomic_read(&tty->port.count))
45635 return -EINVAL;
45636
45637 return get_control_lines(tty);
45638 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
45639 if (!tty)
45640 return -ENODEV;
45641
45642 - if (!tty->port.count)
45643 + if (!atomic_read(&tty->port.count))
45644 return -EINVAL;
45645
45646 return set_control_lines(tty, set, clear);
45647 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
45648 if (!tty)
45649 return -ENODEV;
45650
45651 - if (!tty->port.count)
45652 + if (!atomic_read(&tty->port.count))
45653 return -EINVAL;
45654
45655 /* FIXME: Exactly how is the tty object locked here .. */
45656 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
45657 * are gone */
45658 mutex_lock(&ttyj->ipw_tty_mutex);
45659 }
45660 - while (ttyj->port.count)
45661 + while (atomic_read(&ttyj->port.count))
45662 do_ipw_close(ttyj);
45663 ipwireless_disassociate_network_ttys(network,
45664 ttyj->channel_idx);
45665 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
45666 index 1deaca4..c8582d4 100644
45667 --- a/drivers/tty/moxa.c
45668 +++ b/drivers/tty/moxa.c
45669 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
45670 }
45671
45672 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
45673 - ch->port.count++;
45674 + atomic_inc(&ch->port.count);
45675 tty->driver_data = ch;
45676 tty_port_tty_set(&ch->port, tty);
45677 mutex_lock(&ch->port.mutex);
45678 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
45679 index 6422390..49003ac8 100644
45680 --- a/drivers/tty/n_gsm.c
45681 +++ b/drivers/tty/n_gsm.c
45682 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
45683 spin_lock_init(&dlci->lock);
45684 mutex_init(&dlci->mutex);
45685 dlci->fifo = &dlci->_fifo;
45686 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
45687 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
45688 kfree(dlci);
45689 return NULL;
45690 }
45691 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
45692 struct gsm_dlci *dlci = tty->driver_data;
45693 struct tty_port *port = &dlci->port;
45694
45695 - port->count++;
45696 + atomic_inc(&port->count);
45697 dlci_get(dlci);
45698 dlci_get(dlci->gsm->dlci[0]);
45699 mux_get(dlci->gsm);
45700 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
45701 index 6c7fe90..9241dab 100644
45702 --- a/drivers/tty/n_tty.c
45703 +++ b/drivers/tty/n_tty.c
45704 @@ -2203,6 +2203,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
45705 {
45706 *ops = tty_ldisc_N_TTY;
45707 ops->owner = NULL;
45708 - ops->refcount = ops->flags = 0;
45709 + atomic_set(&ops->refcount, 0);
45710 + ops->flags = 0;
45711 }
45712 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
45713 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
45714 index abfd990..5ab5da9 100644
45715 --- a/drivers/tty/pty.c
45716 +++ b/drivers/tty/pty.c
45717 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
45718 panic("Couldn't register Unix98 pts driver");
45719
45720 /* Now create the /dev/ptmx special device */
45721 + pax_open_kernel();
45722 tty_default_fops(&ptmx_fops);
45723 - ptmx_fops.open = ptmx_open;
45724 + *(void **)&ptmx_fops.open = ptmx_open;
45725 + pax_close_kernel();
45726
45727 cdev_init(&ptmx_cdev, &ptmx_fops);
45728 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
45729 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
45730 index 354564e..fe50d9a 100644
45731 --- a/drivers/tty/rocket.c
45732 +++ b/drivers/tty/rocket.c
45733 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
45734 tty->driver_data = info;
45735 tty_port_tty_set(port, tty);
45736
45737 - if (port->count++ == 0) {
45738 + if (atomic_inc_return(&port->count) == 1) {
45739 atomic_inc(&rp_num_ports_open);
45740
45741 #ifdef ROCKET_DEBUG_OPEN
45742 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
45743 #endif
45744 }
45745 #ifdef ROCKET_DEBUG_OPEN
45746 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
45747 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
45748 #endif
45749
45750 /*
45751 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
45752 spin_unlock_irqrestore(&info->port.lock, flags);
45753 return;
45754 }
45755 - if (info->port.count)
45756 + if (atomic_read(&info->port.count))
45757 atomic_dec(&rp_num_ports_open);
45758 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
45759 spin_unlock_irqrestore(&info->port.lock, flags);
45760 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
45761 index 1002054..dd644a8 100644
45762 --- a/drivers/tty/serial/kgdboc.c
45763 +++ b/drivers/tty/serial/kgdboc.c
45764 @@ -24,8 +24,9 @@
45765 #define MAX_CONFIG_LEN 40
45766
45767 static struct kgdb_io kgdboc_io_ops;
45768 +static struct kgdb_io kgdboc_io_ops_console;
45769
45770 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
45771 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
45772 static int configured = -1;
45773
45774 static char config[MAX_CONFIG_LEN];
45775 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
45776 kgdboc_unregister_kbd();
45777 if (configured == 1)
45778 kgdb_unregister_io_module(&kgdboc_io_ops);
45779 + else if (configured == 2)
45780 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
45781 }
45782
45783 static int configure_kgdboc(void)
45784 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
45785 int err;
45786 char *cptr = config;
45787 struct console *cons;
45788 + int is_console = 0;
45789
45790 err = kgdboc_option_setup(config);
45791 if (err || !strlen(config) || isspace(config[0]))
45792 goto noconfig;
45793
45794 err = -ENODEV;
45795 - kgdboc_io_ops.is_console = 0;
45796 kgdb_tty_driver = NULL;
45797
45798 kgdboc_use_kms = 0;
45799 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
45800 int idx;
45801 if (cons->device && cons->device(cons, &idx) == p &&
45802 idx == tty_line) {
45803 - kgdboc_io_ops.is_console = 1;
45804 + is_console = 1;
45805 break;
45806 }
45807 cons = cons->next;
45808 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
45809 kgdb_tty_line = tty_line;
45810
45811 do_register:
45812 - err = kgdb_register_io_module(&kgdboc_io_ops);
45813 + if (is_console) {
45814 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
45815 + configured = 2;
45816 + } else {
45817 + err = kgdb_register_io_module(&kgdboc_io_ops);
45818 + configured = 1;
45819 + }
45820 if (err)
45821 goto noconfig;
45822
45823 @@ -205,8 +214,6 @@ do_register:
45824 if (err)
45825 goto nmi_con_failed;
45826
45827 - configured = 1;
45828 -
45829 return 0;
45830
45831 nmi_con_failed:
45832 @@ -223,7 +230,7 @@ noconfig:
45833 static int __init init_kgdboc(void)
45834 {
45835 /* Already configured? */
45836 - if (configured == 1)
45837 + if (configured >= 1)
45838 return 0;
45839
45840 return configure_kgdboc();
45841 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
45842 if (config[len - 1] == '\n')
45843 config[len - 1] = '\0';
45844
45845 - if (configured == 1)
45846 + if (configured >= 1)
45847 cleanup_kgdboc();
45848
45849 /* Go and configure with the new params. */
45850 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
45851 .post_exception = kgdboc_post_exp_handler,
45852 };
45853
45854 +static struct kgdb_io kgdboc_io_ops_console = {
45855 + .name = "kgdboc",
45856 + .read_char = kgdboc_get_char,
45857 + .write_char = kgdboc_put_char,
45858 + .pre_exception = kgdboc_pre_exp_handler,
45859 + .post_exception = kgdboc_post_exp_handler,
45860 + .is_console = 1
45861 +};
45862 +
45863 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
45864 /* This is only available if kgdboc is a built in for early debugging */
45865 static int __init kgdboc_early_init(char *opt)
45866 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
45867 index 0c8a9fa..234a95f 100644
45868 --- a/drivers/tty/serial/samsung.c
45869 +++ b/drivers/tty/serial/samsung.c
45870 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
45871 }
45872 }
45873
45874 +static int s3c64xx_serial_startup(struct uart_port *port);
45875 static int s3c24xx_serial_startup(struct uart_port *port)
45876 {
45877 struct s3c24xx_uart_port *ourport = to_ourport(port);
45878 int ret;
45879
45880 + /* Startup sequence is different for s3c64xx and higher SoC's */
45881 + if (s3c24xx_serial_has_interrupt_mask(port))
45882 + return s3c64xx_serial_startup(port);
45883 +
45884 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
45885 port->mapbase, port->membase);
45886
45887 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
45888 /* setup info for port */
45889 port->dev = &platdev->dev;
45890
45891 - /* Startup sequence is different for s3c64xx and higher SoC's */
45892 - if (s3c24xx_serial_has_interrupt_mask(port))
45893 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
45894 -
45895 port->uartclk = 1;
45896
45897 if (cfg->uart_flags & UPF_CONS_FLOW) {
45898 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
45899 index f87dbfd..42ad4b1 100644
45900 --- a/drivers/tty/serial/serial_core.c
45901 +++ b/drivers/tty/serial/serial_core.c
45902 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
45903 uart_flush_buffer(tty);
45904 uart_shutdown(tty, state);
45905 spin_lock_irqsave(&port->lock, flags);
45906 - port->count = 0;
45907 + atomic_set(&port->count, 0);
45908 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
45909 spin_unlock_irqrestore(&port->lock, flags);
45910 tty_port_tty_set(port, NULL);
45911 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
45912 goto end;
45913 }
45914
45915 - port->count++;
45916 + atomic_inc(&port->count);
45917 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
45918 retval = -ENXIO;
45919 goto err_dec_count;
45920 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
45921 /*
45922 * Make sure the device is in D0 state.
45923 */
45924 - if (port->count == 1)
45925 + if (atomic_read(&port->count) == 1)
45926 uart_change_pm(state, UART_PM_STATE_ON);
45927
45928 /*
45929 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
45930 end:
45931 return retval;
45932 err_dec_count:
45933 - port->count--;
45934 + atomic_inc(&port->count);
45935 mutex_unlock(&port->mutex);
45936 goto end;
45937 }
45938 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
45939 index 8eaf1ab..85c030d 100644
45940 --- a/drivers/tty/synclink.c
45941 +++ b/drivers/tty/synclink.c
45942 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
45943
45944 if (debug_level >= DEBUG_LEVEL_INFO)
45945 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
45946 - __FILE__,__LINE__, info->device_name, info->port.count);
45947 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
45948
45949 if (tty_port_close_start(&info->port, tty, filp) == 0)
45950 goto cleanup;
45951 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
45952 cleanup:
45953 if (debug_level >= DEBUG_LEVEL_INFO)
45954 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
45955 - tty->driver->name, info->port.count);
45956 + tty->driver->name, atomic_read(&info->port.count));
45957
45958 } /* end of mgsl_close() */
45959
45960 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
45961
45962 mgsl_flush_buffer(tty);
45963 shutdown(info);
45964 -
45965 - info->port.count = 0;
45966 +
45967 + atomic_set(&info->port.count, 0);
45968 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
45969 info->port.tty = NULL;
45970
45971 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
45972
45973 if (debug_level >= DEBUG_LEVEL_INFO)
45974 printk("%s(%d):block_til_ready before block on %s count=%d\n",
45975 - __FILE__,__LINE__, tty->driver->name, port->count );
45976 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
45977
45978 spin_lock_irqsave(&info->irq_spinlock, flags);
45979 if (!tty_hung_up_p(filp)) {
45980 extra_count = true;
45981 - port->count--;
45982 + atomic_dec(&port->count);
45983 }
45984 spin_unlock_irqrestore(&info->irq_spinlock, flags);
45985 port->blocked_open++;
45986 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
45987
45988 if (debug_level >= DEBUG_LEVEL_INFO)
45989 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
45990 - __FILE__,__LINE__, tty->driver->name, port->count );
45991 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
45992
45993 tty_unlock(tty);
45994 schedule();
45995 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
45996
45997 /* FIXME: Racy on hangup during close wait */
45998 if (extra_count)
45999 - port->count++;
46000 + atomic_inc(&port->count);
46001 port->blocked_open--;
46002
46003 if (debug_level >= DEBUG_LEVEL_INFO)
46004 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
46005 - __FILE__,__LINE__, tty->driver->name, port->count );
46006 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
46007
46008 if (!retval)
46009 port->flags |= ASYNC_NORMAL_ACTIVE;
46010 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
46011
46012 if (debug_level >= DEBUG_LEVEL_INFO)
46013 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
46014 - __FILE__,__LINE__,tty->driver->name, info->port.count);
46015 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
46016
46017 /* If port is closing, signal caller to try again */
46018 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
46019 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
46020 spin_unlock_irqrestore(&info->netlock, flags);
46021 goto cleanup;
46022 }
46023 - info->port.count++;
46024 + atomic_inc(&info->port.count);
46025 spin_unlock_irqrestore(&info->netlock, flags);
46026
46027 - if (info->port.count == 1) {
46028 + if (atomic_read(&info->port.count) == 1) {
46029 /* 1st open on this device, init hardware */
46030 retval = startup(info);
46031 if (retval < 0)
46032 @@ -3446,8 +3446,8 @@ cleanup:
46033 if (retval) {
46034 if (tty->count == 1)
46035 info->port.tty = NULL; /* tty layer will release tty struct */
46036 - if(info->port.count)
46037 - info->port.count--;
46038 + if (atomic_read(&info->port.count))
46039 + atomic_dec(&info->port.count);
46040 }
46041
46042 return retval;
46043 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
46044 unsigned short new_crctype;
46045
46046 /* return error if TTY interface open */
46047 - if (info->port.count)
46048 + if (atomic_read(&info->port.count))
46049 return -EBUSY;
46050
46051 switch (encoding)
46052 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
46053
46054 /* arbitrate between network and tty opens */
46055 spin_lock_irqsave(&info->netlock, flags);
46056 - if (info->port.count != 0 || info->netcount != 0) {
46057 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
46058 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
46059 spin_unlock_irqrestore(&info->netlock, flags);
46060 return -EBUSY;
46061 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
46062 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
46063
46064 /* return error if TTY interface open */
46065 - if (info->port.count)
46066 + if (atomic_read(&info->port.count))
46067 return -EBUSY;
46068
46069 if (cmd != SIOCWANDEV)
46070 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
46071 index 1abf946..1ee34fc 100644
46072 --- a/drivers/tty/synclink_gt.c
46073 +++ b/drivers/tty/synclink_gt.c
46074 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
46075 tty->driver_data = info;
46076 info->port.tty = tty;
46077
46078 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
46079 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
46080
46081 /* If port is closing, signal caller to try again */
46082 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
46083 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
46084 mutex_unlock(&info->port.mutex);
46085 goto cleanup;
46086 }
46087 - info->port.count++;
46088 + atomic_inc(&info->port.count);
46089 spin_unlock_irqrestore(&info->netlock, flags);
46090
46091 - if (info->port.count == 1) {
46092 + if (atomic_read(&info->port.count) == 1) {
46093 /* 1st open on this device, init hardware */
46094 retval = startup(info);
46095 if (retval < 0) {
46096 @@ -715,8 +715,8 @@ cleanup:
46097 if (retval) {
46098 if (tty->count == 1)
46099 info->port.tty = NULL; /* tty layer will release tty struct */
46100 - if(info->port.count)
46101 - info->port.count--;
46102 + if(atomic_read(&info->port.count))
46103 + atomic_dec(&info->port.count);
46104 }
46105
46106 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
46107 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
46108
46109 if (sanity_check(info, tty->name, "close"))
46110 return;
46111 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
46112 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
46113
46114 if (tty_port_close_start(&info->port, tty, filp) == 0)
46115 goto cleanup;
46116 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
46117 tty_port_close_end(&info->port, tty);
46118 info->port.tty = NULL;
46119 cleanup:
46120 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
46121 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
46122 }
46123
46124 static void hangup(struct tty_struct *tty)
46125 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
46126 shutdown(info);
46127
46128 spin_lock_irqsave(&info->port.lock, flags);
46129 - info->port.count = 0;
46130 + atomic_set(&info->port.count, 0);
46131 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
46132 info->port.tty = NULL;
46133 spin_unlock_irqrestore(&info->port.lock, flags);
46134 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
46135 unsigned short new_crctype;
46136
46137 /* return error if TTY interface open */
46138 - if (info->port.count)
46139 + if (atomic_read(&info->port.count))
46140 return -EBUSY;
46141
46142 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
46143 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
46144
46145 /* arbitrate between network and tty opens */
46146 spin_lock_irqsave(&info->netlock, flags);
46147 - if (info->port.count != 0 || info->netcount != 0) {
46148 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
46149 DBGINFO(("%s hdlc_open busy\n", dev->name));
46150 spin_unlock_irqrestore(&info->netlock, flags);
46151 return -EBUSY;
46152 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
46153 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
46154
46155 /* return error if TTY interface open */
46156 - if (info->port.count)
46157 + if (atomic_read(&info->port.count))
46158 return -EBUSY;
46159
46160 if (cmd != SIOCWANDEV)
46161 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
46162 if (port == NULL)
46163 continue;
46164 spin_lock(&port->lock);
46165 - if ((port->port.count || port->netcount) &&
46166 + if ((atomic_read(&port->port.count) || port->netcount) &&
46167 port->pending_bh && !port->bh_running &&
46168 !port->bh_requested) {
46169 DBGISR(("%s bh queued\n", port->device_name));
46170 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
46171 spin_lock_irqsave(&info->lock, flags);
46172 if (!tty_hung_up_p(filp)) {
46173 extra_count = true;
46174 - port->count--;
46175 + atomic_dec(&port->count);
46176 }
46177 spin_unlock_irqrestore(&info->lock, flags);
46178 port->blocked_open++;
46179 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
46180 remove_wait_queue(&port->open_wait, &wait);
46181
46182 if (extra_count)
46183 - port->count++;
46184 + atomic_inc(&port->count);
46185 port->blocked_open--;
46186
46187 if (!retval)
46188 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
46189 index ff17138..e38b41e 100644
46190 --- a/drivers/tty/synclinkmp.c
46191 +++ b/drivers/tty/synclinkmp.c
46192 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
46193
46194 if (debug_level >= DEBUG_LEVEL_INFO)
46195 printk("%s(%d):%s open(), old ref count = %d\n",
46196 - __FILE__,__LINE__,tty->driver->name, info->port.count);
46197 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
46198
46199 /* If port is closing, signal caller to try again */
46200 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
46201 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
46202 spin_unlock_irqrestore(&info->netlock, flags);
46203 goto cleanup;
46204 }
46205 - info->port.count++;
46206 + atomic_inc(&info->port.count);
46207 spin_unlock_irqrestore(&info->netlock, flags);
46208
46209 - if (info->port.count == 1) {
46210 + if (atomic_read(&info->port.count) == 1) {
46211 /* 1st open on this device, init hardware */
46212 retval = startup(info);
46213 if (retval < 0)
46214 @@ -796,8 +796,8 @@ cleanup:
46215 if (retval) {
46216 if (tty->count == 1)
46217 info->port.tty = NULL; /* tty layer will release tty struct */
46218 - if(info->port.count)
46219 - info->port.count--;
46220 + if(atomic_read(&info->port.count))
46221 + atomic_dec(&info->port.count);
46222 }
46223
46224 return retval;
46225 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
46226
46227 if (debug_level >= DEBUG_LEVEL_INFO)
46228 printk("%s(%d):%s close() entry, count=%d\n",
46229 - __FILE__,__LINE__, info->device_name, info->port.count);
46230 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
46231
46232 if (tty_port_close_start(&info->port, tty, filp) == 0)
46233 goto cleanup;
46234 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
46235 cleanup:
46236 if (debug_level >= DEBUG_LEVEL_INFO)
46237 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
46238 - tty->driver->name, info->port.count);
46239 + tty->driver->name, atomic_read(&info->port.count));
46240 }
46241
46242 /* Called by tty_hangup() when a hangup is signaled.
46243 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
46244 shutdown(info);
46245
46246 spin_lock_irqsave(&info->port.lock, flags);
46247 - info->port.count = 0;
46248 + atomic_set(&info->port.count, 0);
46249 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
46250 info->port.tty = NULL;
46251 spin_unlock_irqrestore(&info->port.lock, flags);
46252 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
46253 unsigned short new_crctype;
46254
46255 /* return error if TTY interface open */
46256 - if (info->port.count)
46257 + if (atomic_read(&info->port.count))
46258 return -EBUSY;
46259
46260 switch (encoding)
46261 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
46262
46263 /* arbitrate between network and tty opens */
46264 spin_lock_irqsave(&info->netlock, flags);
46265 - if (info->port.count != 0 || info->netcount != 0) {
46266 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
46267 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
46268 spin_unlock_irqrestore(&info->netlock, flags);
46269 return -EBUSY;
46270 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
46271 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
46272
46273 /* return error if TTY interface open */
46274 - if (info->port.count)
46275 + if (atomic_read(&info->port.count))
46276 return -EBUSY;
46277
46278 if (cmd != SIOCWANDEV)
46279 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
46280 * do not request bottom half processing if the
46281 * device is not open in a normal mode.
46282 */
46283 - if ( port && (port->port.count || port->netcount) &&
46284 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
46285 port->pending_bh && !port->bh_running &&
46286 !port->bh_requested ) {
46287 if ( debug_level >= DEBUG_LEVEL_ISR )
46288 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
46289
46290 if (debug_level >= DEBUG_LEVEL_INFO)
46291 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
46292 - __FILE__,__LINE__, tty->driver->name, port->count );
46293 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
46294
46295 spin_lock_irqsave(&info->lock, flags);
46296 if (!tty_hung_up_p(filp)) {
46297 extra_count = true;
46298 - port->count--;
46299 + atomic_dec(&port->count);
46300 }
46301 spin_unlock_irqrestore(&info->lock, flags);
46302 port->blocked_open++;
46303 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
46304
46305 if (debug_level >= DEBUG_LEVEL_INFO)
46306 printk("%s(%d):%s block_til_ready() count=%d\n",
46307 - __FILE__,__LINE__, tty->driver->name, port->count );
46308 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
46309
46310 tty_unlock(tty);
46311 schedule();
46312 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
46313 remove_wait_queue(&port->open_wait, &wait);
46314
46315 if (extra_count)
46316 - port->count++;
46317 + atomic_inc(&port->count);
46318 port->blocked_open--;
46319
46320 if (debug_level >= DEBUG_LEVEL_INFO)
46321 printk("%s(%d):%s block_til_ready() after, count=%d\n",
46322 - __FILE__,__LINE__, tty->driver->name, port->count );
46323 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
46324
46325 if (!retval)
46326 port->flags |= ASYNC_NORMAL_ACTIVE;
46327 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
46328 index b51c154..17d55d1 100644
46329 --- a/drivers/tty/sysrq.c
46330 +++ b/drivers/tty/sysrq.c
46331 @@ -1022,7 +1022,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
46332 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
46333 size_t count, loff_t *ppos)
46334 {
46335 - if (count) {
46336 + if (count && capable(CAP_SYS_ADMIN)) {
46337 char c;
46338
46339 if (get_user(c, buf))
46340 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
46341 index 4476682..d77e748 100644
46342 --- a/drivers/tty/tty_io.c
46343 +++ b/drivers/tty/tty_io.c
46344 @@ -3466,7 +3466,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
46345
46346 void tty_default_fops(struct file_operations *fops)
46347 {
46348 - *fops = tty_fops;
46349 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
46350 }
46351
46352 /*
46353 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
46354 index 1afe192..73d2c20 100644
46355 --- a/drivers/tty/tty_ldisc.c
46356 +++ b/drivers/tty/tty_ldisc.c
46357 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
46358 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
46359 tty_ldiscs[disc] = new_ldisc;
46360 new_ldisc->num = disc;
46361 - new_ldisc->refcount = 0;
46362 + atomic_set(&new_ldisc->refcount, 0);
46363 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
46364
46365 return ret;
46366 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
46367 return -EINVAL;
46368
46369 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
46370 - if (tty_ldiscs[disc]->refcount)
46371 + if (atomic_read(&tty_ldiscs[disc]->refcount))
46372 ret = -EBUSY;
46373 else
46374 tty_ldiscs[disc] = NULL;
46375 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
46376 if (ldops) {
46377 ret = ERR_PTR(-EAGAIN);
46378 if (try_module_get(ldops->owner)) {
46379 - ldops->refcount++;
46380 + atomic_inc(&ldops->refcount);
46381 ret = ldops;
46382 }
46383 }
46384 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
46385 unsigned long flags;
46386
46387 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
46388 - ldops->refcount--;
46389 + atomic_dec(&ldops->refcount);
46390 module_put(ldops->owner);
46391 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
46392 }
46393 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
46394 /* unreleased reader reference(s) will cause this WARN */
46395 WARN_ON(!atomic_dec_and_test(&ld->users));
46396
46397 - ld->ops->refcount--;
46398 + atomic_dec(&ld->ops->refcount);
46399 module_put(ld->ops->owner);
46400 kfree(ld);
46401 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
46402 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
46403 index f597e88..b7f68ed 100644
46404 --- a/drivers/tty/tty_port.c
46405 +++ b/drivers/tty/tty_port.c
46406 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
46407 unsigned long flags;
46408
46409 spin_lock_irqsave(&port->lock, flags);
46410 - port->count = 0;
46411 + atomic_set(&port->count, 0);
46412 port->flags &= ~ASYNC_NORMAL_ACTIVE;
46413 tty = port->tty;
46414 if (tty)
46415 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
46416 /* The port lock protects the port counts */
46417 spin_lock_irqsave(&port->lock, flags);
46418 if (!tty_hung_up_p(filp))
46419 - port->count--;
46420 + atomic_dec(&port->count);
46421 port->blocked_open++;
46422 spin_unlock_irqrestore(&port->lock, flags);
46423
46424 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
46425 we must not mess that up further */
46426 spin_lock_irqsave(&port->lock, flags);
46427 if (!tty_hung_up_p(filp))
46428 - port->count++;
46429 + atomic_inc(&port->count);
46430 port->blocked_open--;
46431 if (retval == 0)
46432 port->flags |= ASYNC_NORMAL_ACTIVE;
46433 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
46434 return 0;
46435 }
46436
46437 - if (tty->count == 1 && port->count != 1) {
46438 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
46439 printk(KERN_WARNING
46440 "tty_port_close_start: tty->count = 1 port count = %d.\n",
46441 - port->count);
46442 - port->count = 1;
46443 + atomic_read(&port->count));
46444 + atomic_set(&port->count, 1);
46445 }
46446 - if (--port->count < 0) {
46447 + if (atomic_dec_return(&port->count) < 0) {
46448 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
46449 - port->count);
46450 - port->count = 0;
46451 + atomic_read(&port->count));
46452 + atomic_set(&port->count, 0);
46453 }
46454
46455 - if (port->count) {
46456 + if (atomic_read(&port->count)) {
46457 spin_unlock_irqrestore(&port->lock, flags);
46458 if (port->ops->drop)
46459 port->ops->drop(port);
46460 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
46461 {
46462 spin_lock_irq(&port->lock);
46463 if (!tty_hung_up_p(filp))
46464 - ++port->count;
46465 + atomic_inc(&port->count);
46466 spin_unlock_irq(&port->lock);
46467 tty_port_tty_set(port, tty);
46468
46469 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
46470 index a9af1b9a..1e08e7f 100644
46471 --- a/drivers/tty/vt/keyboard.c
46472 +++ b/drivers/tty/vt/keyboard.c
46473 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
46474 kbd->kbdmode == VC_OFF) &&
46475 value != KVAL(K_SAK))
46476 return; /* SAK is allowed even in raw mode */
46477 +
46478 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
46479 + {
46480 + void *func = fn_handler[value];
46481 + if (func == fn_show_state || func == fn_show_ptregs ||
46482 + func == fn_show_mem)
46483 + return;
46484 + }
46485 +#endif
46486 +
46487 fn_handler[value](vc);
46488 }
46489
46490 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
46491 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
46492 return -EFAULT;
46493
46494 - if (!capable(CAP_SYS_TTY_CONFIG))
46495 - perm = 0;
46496 -
46497 switch (cmd) {
46498 case KDGKBENT:
46499 /* Ensure another thread doesn't free it under us */
46500 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
46501 spin_unlock_irqrestore(&kbd_event_lock, flags);
46502 return put_user(val, &user_kbe->kb_value);
46503 case KDSKBENT:
46504 + if (!capable(CAP_SYS_TTY_CONFIG))
46505 + perm = 0;
46506 +
46507 if (!perm)
46508 return -EPERM;
46509 if (!i && v == K_NOSUCHMAP) {
46510 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
46511 int i, j, k;
46512 int ret;
46513
46514 - if (!capable(CAP_SYS_TTY_CONFIG))
46515 - perm = 0;
46516 -
46517 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
46518 if (!kbs) {
46519 ret = -ENOMEM;
46520 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
46521 kfree(kbs);
46522 return ((p && *p) ? -EOVERFLOW : 0);
46523 case KDSKBSENT:
46524 + if (!capable(CAP_SYS_TTY_CONFIG))
46525 + perm = 0;
46526 +
46527 if (!perm) {
46528 ret = -EPERM;
46529 goto reterr;
46530 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
46531 index b645c47..a55c182 100644
46532 --- a/drivers/uio/uio.c
46533 +++ b/drivers/uio/uio.c
46534 @@ -25,6 +25,7 @@
46535 #include <linux/kobject.h>
46536 #include <linux/cdev.h>
46537 #include <linux/uio_driver.h>
46538 +#include <asm/local.h>
46539
46540 #define UIO_MAX_DEVICES (1U << MINORBITS)
46541
46542 @@ -32,10 +33,10 @@ struct uio_device {
46543 struct module *owner;
46544 struct device *dev;
46545 int minor;
46546 - atomic_t event;
46547 + atomic_unchecked_t event;
46548 struct fasync_struct *async_queue;
46549 wait_queue_head_t wait;
46550 - int vma_count;
46551 + local_t vma_count;
46552 struct uio_info *info;
46553 struct kobject *map_dir;
46554 struct kobject *portio_dir;
46555 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
46556 struct device_attribute *attr, char *buf)
46557 {
46558 struct uio_device *idev = dev_get_drvdata(dev);
46559 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
46560 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
46561 }
46562
46563 static struct device_attribute uio_class_attributes[] = {
46564 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
46565 {
46566 struct uio_device *idev = info->uio_dev;
46567
46568 - atomic_inc(&idev->event);
46569 + atomic_inc_unchecked(&idev->event);
46570 wake_up_interruptible(&idev->wait);
46571 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
46572 }
46573 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
46574 }
46575
46576 listener->dev = idev;
46577 - listener->event_count = atomic_read(&idev->event);
46578 + listener->event_count = atomic_read_unchecked(&idev->event);
46579 filep->private_data = listener;
46580
46581 if (idev->info->open) {
46582 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
46583 return -EIO;
46584
46585 poll_wait(filep, &idev->wait, wait);
46586 - if (listener->event_count != atomic_read(&idev->event))
46587 + if (listener->event_count != atomic_read_unchecked(&idev->event))
46588 return POLLIN | POLLRDNORM;
46589 return 0;
46590 }
46591 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
46592 do {
46593 set_current_state(TASK_INTERRUPTIBLE);
46594
46595 - event_count = atomic_read(&idev->event);
46596 + event_count = atomic_read_unchecked(&idev->event);
46597 if (event_count != listener->event_count) {
46598 if (copy_to_user(buf, &event_count, count))
46599 retval = -EFAULT;
46600 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
46601 static void uio_vma_open(struct vm_area_struct *vma)
46602 {
46603 struct uio_device *idev = vma->vm_private_data;
46604 - idev->vma_count++;
46605 + local_inc(&idev->vma_count);
46606 }
46607
46608 static void uio_vma_close(struct vm_area_struct *vma)
46609 {
46610 struct uio_device *idev = vma->vm_private_data;
46611 - idev->vma_count--;
46612 + local_dec(&idev->vma_count);
46613 }
46614
46615 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
46616 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
46617 idev->owner = owner;
46618 idev->info = info;
46619 init_waitqueue_head(&idev->wait);
46620 - atomic_set(&idev->event, 0);
46621 + atomic_set_unchecked(&idev->event, 0);
46622
46623 ret = uio_get_minor(idev);
46624 if (ret)
46625 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
46626 index 8a7eb77..c00402f 100644
46627 --- a/drivers/usb/atm/cxacru.c
46628 +++ b/drivers/usb/atm/cxacru.c
46629 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
46630 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
46631 if (ret < 2)
46632 return -EINVAL;
46633 - if (index < 0 || index > 0x7f)
46634 + if (index > 0x7f)
46635 return -EINVAL;
46636 pos += tmp;
46637
46638 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
46639 index d3527dd..26effa2 100644
46640 --- a/drivers/usb/atm/usbatm.c
46641 +++ b/drivers/usb/atm/usbatm.c
46642 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
46643 if (printk_ratelimit())
46644 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
46645 __func__, vpi, vci);
46646 - atomic_inc(&vcc->stats->rx_err);
46647 + atomic_inc_unchecked(&vcc->stats->rx_err);
46648 return;
46649 }
46650
46651 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
46652 if (length > ATM_MAX_AAL5_PDU) {
46653 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
46654 __func__, length, vcc);
46655 - atomic_inc(&vcc->stats->rx_err);
46656 + atomic_inc_unchecked(&vcc->stats->rx_err);
46657 goto out;
46658 }
46659
46660 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
46661 if (sarb->len < pdu_length) {
46662 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
46663 __func__, pdu_length, sarb->len, vcc);
46664 - atomic_inc(&vcc->stats->rx_err);
46665 + atomic_inc_unchecked(&vcc->stats->rx_err);
46666 goto out;
46667 }
46668
46669 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
46670 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
46671 __func__, vcc);
46672 - atomic_inc(&vcc->stats->rx_err);
46673 + atomic_inc_unchecked(&vcc->stats->rx_err);
46674 goto out;
46675 }
46676
46677 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
46678 if (printk_ratelimit())
46679 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
46680 __func__, length);
46681 - atomic_inc(&vcc->stats->rx_drop);
46682 + atomic_inc_unchecked(&vcc->stats->rx_drop);
46683 goto out;
46684 }
46685
46686 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
46687
46688 vcc->push(vcc, skb);
46689
46690 - atomic_inc(&vcc->stats->rx);
46691 + atomic_inc_unchecked(&vcc->stats->rx);
46692 out:
46693 skb_trim(sarb, 0);
46694 }
46695 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
46696 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
46697
46698 usbatm_pop(vcc, skb);
46699 - atomic_inc(&vcc->stats->tx);
46700 + atomic_inc_unchecked(&vcc->stats->tx);
46701
46702 skb = skb_dequeue(&instance->sndqueue);
46703 }
46704 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
46705 if (!left--)
46706 return sprintf(page,
46707 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
46708 - atomic_read(&atm_dev->stats.aal5.tx),
46709 - atomic_read(&atm_dev->stats.aal5.tx_err),
46710 - atomic_read(&atm_dev->stats.aal5.rx),
46711 - atomic_read(&atm_dev->stats.aal5.rx_err),
46712 - atomic_read(&atm_dev->stats.aal5.rx_drop));
46713 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
46714 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
46715 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
46716 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
46717 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
46718
46719 if (!left--) {
46720 if (instance->disconnected)
46721 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
46722 index 2a3bbdf..91d72cf 100644
46723 --- a/drivers/usb/core/devices.c
46724 +++ b/drivers/usb/core/devices.c
46725 @@ -126,7 +126,7 @@ static const char format_endpt[] =
46726 * time it gets called.
46727 */
46728 static struct device_connect_event {
46729 - atomic_t count;
46730 + atomic_unchecked_t count;
46731 wait_queue_head_t wait;
46732 } device_event = {
46733 .count = ATOMIC_INIT(1),
46734 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
46735
46736 void usbfs_conn_disc_event(void)
46737 {
46738 - atomic_add(2, &device_event.count);
46739 + atomic_add_unchecked(2, &device_event.count);
46740 wake_up(&device_event.wait);
46741 }
46742
46743 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
46744
46745 poll_wait(file, &device_event.wait, wait);
46746
46747 - event_count = atomic_read(&device_event.count);
46748 + event_count = atomic_read_unchecked(&device_event.count);
46749 if (file->f_version != event_count) {
46750 file->f_version = event_count;
46751 return POLLIN | POLLRDNORM;
46752 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
46753 index d53547d..6a22d02 100644
46754 --- a/drivers/usb/core/hcd.c
46755 +++ b/drivers/usb/core/hcd.c
46756 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
46757 */
46758 usb_get_urb(urb);
46759 atomic_inc(&urb->use_count);
46760 - atomic_inc(&urb->dev->urbnum);
46761 + atomic_inc_unchecked(&urb->dev->urbnum);
46762 usbmon_urb_submit(&hcd->self, urb);
46763
46764 /* NOTE requirements on root-hub callers (usbfs and the hub
46765 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
46766 urb->hcpriv = NULL;
46767 INIT_LIST_HEAD(&urb->urb_list);
46768 atomic_dec(&urb->use_count);
46769 - atomic_dec(&urb->dev->urbnum);
46770 + atomic_dec_unchecked(&urb->dev->urbnum);
46771 if (atomic_read(&urb->reject))
46772 wake_up(&usb_kill_urb_queue);
46773 usb_put_urb(urb);
46774 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
46775 index 444d30e..f15c850 100644
46776 --- a/drivers/usb/core/message.c
46777 +++ b/drivers/usb/core/message.c
46778 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
46779 * method can wait for it to complete. Since you don't have a handle on the
46780 * URB used, you can't cancel the request.
46781 */
46782 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
46783 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
46784 __u8 requesttype, __u16 value, __u16 index, void *data,
46785 __u16 size, int timeout)
46786 {
46787 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
46788 index aa38db4..0a08682 100644
46789 --- a/drivers/usb/core/sysfs.c
46790 +++ b/drivers/usb/core/sysfs.c
46791 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
46792 struct usb_device *udev;
46793
46794 udev = to_usb_device(dev);
46795 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
46796 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
46797 }
46798 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
46799
46800 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
46801 index b10da72..43aa0b2 100644
46802 --- a/drivers/usb/core/usb.c
46803 +++ b/drivers/usb/core/usb.c
46804 @@ -389,7 +389,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
46805 set_dev_node(&dev->dev, dev_to_node(bus->controller));
46806 dev->state = USB_STATE_ATTACHED;
46807 dev->lpm_disable_count = 1;
46808 - atomic_set(&dev->urbnum, 0);
46809 + atomic_set_unchecked(&dev->urbnum, 0);
46810
46811 INIT_LIST_HEAD(&dev->ep0.urb_list);
46812 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
46813 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
46814 index 5e29dde..eca992f 100644
46815 --- a/drivers/usb/early/ehci-dbgp.c
46816 +++ b/drivers/usb/early/ehci-dbgp.c
46817 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
46818
46819 #ifdef CONFIG_KGDB
46820 static struct kgdb_io kgdbdbgp_io_ops;
46821 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
46822 +static struct kgdb_io kgdbdbgp_io_ops_console;
46823 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
46824 #else
46825 #define dbgp_kgdb_mode (0)
46826 #endif
46827 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
46828 .write_char = kgdbdbgp_write_char,
46829 };
46830
46831 +static struct kgdb_io kgdbdbgp_io_ops_console = {
46832 + .name = "kgdbdbgp",
46833 + .read_char = kgdbdbgp_read_char,
46834 + .write_char = kgdbdbgp_write_char,
46835 + .is_console = 1
46836 +};
46837 +
46838 static int kgdbdbgp_wait_time;
46839
46840 static int __init kgdbdbgp_parse_config(char *str)
46841 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
46842 ptr++;
46843 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
46844 }
46845 - kgdb_register_io_module(&kgdbdbgp_io_ops);
46846 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
46847 + if (early_dbgp_console.index != -1)
46848 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
46849 + else
46850 + kgdb_register_io_module(&kgdbdbgp_io_ops);
46851
46852 return 0;
46853 }
46854 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
46855 index b369292..9f3ba40 100644
46856 --- a/drivers/usb/gadget/u_serial.c
46857 +++ b/drivers/usb/gadget/u_serial.c
46858 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
46859 spin_lock_irq(&port->port_lock);
46860
46861 /* already open? Great. */
46862 - if (port->port.count) {
46863 + if (atomic_read(&port->port.count)) {
46864 status = 0;
46865 - port->port.count++;
46866 + atomic_inc(&port->port.count);
46867
46868 /* currently opening/closing? wait ... */
46869 } else if (port->openclose) {
46870 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
46871 tty->driver_data = port;
46872 port->port.tty = tty;
46873
46874 - port->port.count = 1;
46875 + atomic_set(&port->port.count, 1);
46876 port->openclose = false;
46877
46878 /* if connected, start the I/O stream */
46879 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
46880
46881 spin_lock_irq(&port->port_lock);
46882
46883 - if (port->port.count != 1) {
46884 - if (port->port.count == 0)
46885 + if (atomic_read(&port->port.count) != 1) {
46886 + if (atomic_read(&port->port.count) == 0)
46887 WARN_ON(1);
46888 else
46889 - --port->port.count;
46890 + atomic_dec(&port->port.count);
46891 goto exit;
46892 }
46893
46894 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
46895 * and sleep if necessary
46896 */
46897 port->openclose = true;
46898 - port->port.count = 0;
46899 + atomic_set(&port->port.count, 0);
46900
46901 gser = port->port_usb;
46902 if (gser && gser->disconnect)
46903 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
46904 int cond;
46905
46906 spin_lock_irq(&port->port_lock);
46907 - cond = (port->port.count == 0) && !port->openclose;
46908 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
46909 spin_unlock_irq(&port->port_lock);
46910 return cond;
46911 }
46912 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
46913 /* if it's already open, start I/O ... and notify the serial
46914 * protocol about open/close status (connect/disconnect).
46915 */
46916 - if (port->port.count) {
46917 + if (atomic_read(&port->port.count)) {
46918 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
46919 gs_start_io(port);
46920 if (gser->connect)
46921 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
46922
46923 port->port_usb = NULL;
46924 gser->ioport = NULL;
46925 - if (port->port.count > 0 || port->openclose) {
46926 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
46927 wake_up_interruptible(&port->drain_wait);
46928 if (port->port.tty)
46929 tty_hangup(port->port.tty);
46930 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
46931
46932 /* finally, free any unused/unusable I/O buffers */
46933 spin_lock_irqsave(&port->port_lock, flags);
46934 - if (port->port.count == 0 && !port->openclose)
46935 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
46936 gs_buf_free(&port->port_write_buf);
46937 gs_free_requests(gser->out, &port->read_pool, NULL);
46938 gs_free_requests(gser->out, &port->read_queue, NULL);
46939 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
46940 index 5f3bcd3..bfca43f 100644
46941 --- a/drivers/usb/serial/console.c
46942 +++ b/drivers/usb/serial/console.c
46943 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
46944
46945 info->port = port;
46946
46947 - ++port->port.count;
46948 + atomic_inc(&port->port.count);
46949 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
46950 if (serial->type->set_termios) {
46951 /*
46952 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
46953 }
46954 /* Now that any required fake tty operations are completed restore
46955 * the tty port count */
46956 - --port->port.count;
46957 + atomic_dec(&port->port.count);
46958 /* The console is special in terms of closing the device so
46959 * indicate this port is now acting as a system console. */
46960 port->port.console = 1;
46961 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
46962 free_tty:
46963 kfree(tty);
46964 reset_open_count:
46965 - port->port.count = 0;
46966 + atomic_set(&port->port.count, 0);
46967 usb_autopm_put_interface(serial->interface);
46968 error_get_interface:
46969 usb_serial_put(serial);
46970 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
46971 index 75f70f0..d467e1a 100644
46972 --- a/drivers/usb/storage/usb.h
46973 +++ b/drivers/usb/storage/usb.h
46974 @@ -63,7 +63,7 @@ struct us_unusual_dev {
46975 __u8 useProtocol;
46976 __u8 useTransport;
46977 int (*initFunction)(struct us_data *);
46978 -};
46979 +} __do_const;
46980
46981
46982 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
46983 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
46984 index d6bea3e..60b250e 100644
46985 --- a/drivers/usb/wusbcore/wa-hc.h
46986 +++ b/drivers/usb/wusbcore/wa-hc.h
46987 @@ -192,7 +192,7 @@ struct wahc {
46988 struct list_head xfer_delayed_list;
46989 spinlock_t xfer_list_lock;
46990 struct work_struct xfer_work;
46991 - atomic_t xfer_id_count;
46992 + atomic_unchecked_t xfer_id_count;
46993 };
46994
46995
46996 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
46997 INIT_LIST_HEAD(&wa->xfer_delayed_list);
46998 spin_lock_init(&wa->xfer_list_lock);
46999 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
47000 - atomic_set(&wa->xfer_id_count, 1);
47001 + atomic_set_unchecked(&wa->xfer_id_count, 1);
47002 }
47003
47004 /**
47005 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
47006 index 6ef94bc..1b41265 100644
47007 --- a/drivers/usb/wusbcore/wa-xfer.c
47008 +++ b/drivers/usb/wusbcore/wa-xfer.c
47009 @@ -296,7 +296,7 @@ out:
47010 */
47011 static void wa_xfer_id_init(struct wa_xfer *xfer)
47012 {
47013 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
47014 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
47015 }
47016
47017 /*
47018 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
47019 index 5174eba..86e764a 100644
47020 --- a/drivers/vhost/vringh.c
47021 +++ b/drivers/vhost/vringh.c
47022 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
47023
47024 static inline int putu16_kern(u16 *p, u16 val)
47025 {
47026 - ACCESS_ONCE(*p) = val;
47027 + ACCESS_ONCE_RW(*p) = val;
47028 return 0;
47029 }
47030
47031 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
47032 index 8c55011..eed4ae1a 100644
47033 --- a/drivers/video/aty/aty128fb.c
47034 +++ b/drivers/video/aty/aty128fb.c
47035 @@ -149,7 +149,7 @@ enum {
47036 };
47037
47038 /* Must match above enum */
47039 -static char * const r128_family[] = {
47040 +static const char * const r128_family[] = {
47041 "AGP",
47042 "PCI",
47043 "PRO AGP",
47044 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
47045 index 4f27fdc..d3537e6 100644
47046 --- a/drivers/video/aty/atyfb_base.c
47047 +++ b/drivers/video/aty/atyfb_base.c
47048 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
47049 par->accel_flags = var->accel_flags; /* hack */
47050
47051 if (var->accel_flags) {
47052 - info->fbops->fb_sync = atyfb_sync;
47053 + pax_open_kernel();
47054 + *(void **)&info->fbops->fb_sync = atyfb_sync;
47055 + pax_close_kernel();
47056 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47057 } else {
47058 - info->fbops->fb_sync = NULL;
47059 + pax_open_kernel();
47060 + *(void **)&info->fbops->fb_sync = NULL;
47061 + pax_close_kernel();
47062 info->flags |= FBINFO_HWACCEL_DISABLED;
47063 }
47064
47065 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
47066 index 95ec042..e6affdd 100644
47067 --- a/drivers/video/aty/mach64_cursor.c
47068 +++ b/drivers/video/aty/mach64_cursor.c
47069 @@ -7,6 +7,7 @@
47070 #include <linux/string.h>
47071
47072 #include <asm/io.h>
47073 +#include <asm/pgtable.h>
47074
47075 #ifdef __sparc__
47076 #include <asm/fbio.h>
47077 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
47078 info->sprite.buf_align = 16; /* and 64 lines tall. */
47079 info->sprite.flags = FB_PIXMAP_IO;
47080
47081 - info->fbops->fb_cursor = atyfb_cursor;
47082 + pax_open_kernel();
47083 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
47084 + pax_close_kernel();
47085
47086 return 0;
47087 }
47088 diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
47089 index c74e7aa..e3c2790 100644
47090 --- a/drivers/video/backlight/backlight.c
47091 +++ b/drivers/video/backlight/backlight.c
47092 @@ -304,7 +304,7 @@ struct backlight_device *backlight_device_register(const char *name,
47093 new_bd->dev.class = backlight_class;
47094 new_bd->dev.parent = parent;
47095 new_bd->dev.release = bl_device_release;
47096 - dev_set_name(&new_bd->dev, name);
47097 + dev_set_name(&new_bd->dev, "%s", name);
47098 dev_set_drvdata(&new_bd->dev, devdata);
47099
47100 /* Set default properties */
47101 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
47102 index bca6ccc..252107e 100644
47103 --- a/drivers/video/backlight/kb3886_bl.c
47104 +++ b/drivers/video/backlight/kb3886_bl.c
47105 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
47106 static unsigned long kb3886bl_flags;
47107 #define KB3886BL_SUSPENDED 0x01
47108
47109 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
47110 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
47111 {
47112 .ident = "Sahara Touch-iT",
47113 .matches = {
47114 diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
47115 index 34fb6bd..3649fd9 100644
47116 --- a/drivers/video/backlight/lcd.c
47117 +++ b/drivers/video/backlight/lcd.c
47118 @@ -219,7 +219,7 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
47119 new_ld->dev.class = lcd_class;
47120 new_ld->dev.parent = parent;
47121 new_ld->dev.release = lcd_device_release;
47122 - dev_set_name(&new_ld->dev, name);
47123 + dev_set_name(&new_ld->dev, "%s", name);
47124 dev_set_drvdata(&new_ld->dev, devdata);
47125
47126 rc = device_register(&new_ld->dev);
47127 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
47128 index 900aa4e..6d49418 100644
47129 --- a/drivers/video/fb_defio.c
47130 +++ b/drivers/video/fb_defio.c
47131 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
47132
47133 BUG_ON(!fbdefio);
47134 mutex_init(&fbdefio->lock);
47135 - info->fbops->fb_mmap = fb_deferred_io_mmap;
47136 + pax_open_kernel();
47137 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
47138 + pax_close_kernel();
47139 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
47140 INIT_LIST_HEAD(&fbdefio->pagelist);
47141 if (fbdefio->delay == 0) /* set a default of 1 s */
47142 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
47143 page->mapping = NULL;
47144 }
47145
47146 - info->fbops->fb_mmap = NULL;
47147 + *(void **)&info->fbops->fb_mmap = NULL;
47148 mutex_destroy(&fbdefio->lock);
47149 }
47150 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
47151 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
47152 index 5c3960d..15cf8fc 100644
47153 --- a/drivers/video/fbcmap.c
47154 +++ b/drivers/video/fbcmap.c
47155 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
47156 rc = -ENODEV;
47157 goto out;
47158 }
47159 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
47160 - !info->fbops->fb_setcmap)) {
47161 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
47162 rc = -EINVAL;
47163 goto out1;
47164 }
47165 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
47166 index 098bfc6..796841d 100644
47167 --- a/drivers/video/fbmem.c
47168 +++ b/drivers/video/fbmem.c
47169 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
47170 image->dx += image->width + 8;
47171 }
47172 } else if (rotate == FB_ROTATE_UD) {
47173 - for (x = 0; x < num && image->dx >= 0; x++) {
47174 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
47175 info->fbops->fb_imageblit(info, image);
47176 image->dx -= image->width + 8;
47177 }
47178 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
47179 image->dy += image->height + 8;
47180 }
47181 } else if (rotate == FB_ROTATE_CCW) {
47182 - for (x = 0; x < num && image->dy >= 0; x++) {
47183 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
47184 info->fbops->fb_imageblit(info, image);
47185 image->dy -= image->height + 8;
47186 }
47187 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
47188 return -EFAULT;
47189 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
47190 return -EINVAL;
47191 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
47192 + if (con2fb.framebuffer >= FB_MAX)
47193 return -EINVAL;
47194 if (!registered_fb[con2fb.framebuffer])
47195 request_module("fb%d", con2fb.framebuffer);
47196 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
47197 index 7672d2e..b56437f 100644
47198 --- a/drivers/video/i810/i810_accel.c
47199 +++ b/drivers/video/i810/i810_accel.c
47200 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
47201 }
47202 }
47203 printk("ringbuffer lockup!!!\n");
47204 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
47205 i810_report_error(mmio);
47206 par->dev_flags |= LOCKUP;
47207 info->pixmap.scan_align = 1;
47208 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
47209 index 3c14e43..eafa544 100644
47210 --- a/drivers/video/logo/logo_linux_clut224.ppm
47211 +++ b/drivers/video/logo/logo_linux_clut224.ppm
47212 @@ -1,1604 +1,1123 @@
47213 P3
47214 -# Standard 224-color Linux logo
47215 80 80
47216 255
47217 - 0 0 0 0 0 0 0 0 0 0 0 0
47218 - 0 0 0 0 0 0 0 0 0 0 0 0
47219 - 0 0 0 0 0 0 0 0 0 0 0 0
47220 - 0 0 0 0 0 0 0 0 0 0 0 0
47221 - 0 0 0 0 0 0 0 0 0 0 0 0
47222 - 0 0 0 0 0 0 0 0 0 0 0 0
47223 - 0 0 0 0 0 0 0 0 0 0 0 0
47224 - 0 0 0 0 0 0 0 0 0 0 0 0
47225 - 0 0 0 0 0 0 0 0 0 0 0 0
47226 - 6 6 6 6 6 6 10 10 10 10 10 10
47227 - 10 10 10 6 6 6 6 6 6 6 6 6
47228 - 0 0 0 0 0 0 0 0 0 0 0 0
47229 - 0 0 0 0 0 0 0 0 0 0 0 0
47230 - 0 0 0 0 0 0 0 0 0 0 0 0
47231 - 0 0 0 0 0 0 0 0 0 0 0 0
47232 - 0 0 0 0 0 0 0 0 0 0 0 0
47233 - 0 0 0 0 0 0 0 0 0 0 0 0
47234 - 0 0 0 0 0 0 0 0 0 0 0 0
47235 - 0 0 0 0 0 0 0 0 0 0 0 0
47236 - 0 0 0 0 0 0 0 0 0 0 0 0
47237 - 0 0 0 0 0 0 0 0 0 0 0 0
47238 - 0 0 0 0 0 0 0 0 0 0 0 0
47239 - 0 0 0 0 0 0 0 0 0 0 0 0
47240 - 0 0 0 0 0 0 0 0 0 0 0 0
47241 - 0 0 0 0 0 0 0 0 0 0 0 0
47242 - 0 0 0 0 0 0 0 0 0 0 0 0
47243 - 0 0 0 0 0 0 0 0 0 0 0 0
47244 - 0 0 0 0 0 0 0 0 0 0 0 0
47245 - 0 0 0 6 6 6 10 10 10 14 14 14
47246 - 22 22 22 26 26 26 30 30 30 34 34 34
47247 - 30 30 30 30 30 30 26 26 26 18 18 18
47248 - 14 14 14 10 10 10 6 6 6 0 0 0
47249 - 0 0 0 0 0 0 0 0 0 0 0 0
47250 - 0 0 0 0 0 0 0 0 0 0 0 0
47251 - 0 0 0 0 0 0 0 0 0 0 0 0
47252 - 0 0 0 0 0 0 0 0 0 0 0 0
47253 - 0 0 0 0 0 0 0 0 0 0 0 0
47254 - 0 0 0 0 0 0 0 0 0 0 0 0
47255 - 0 0 0 0 0 0 0 0 0 0 0 0
47256 - 0 0 0 0 0 0 0 0 0 0 0 0
47257 - 0 0 0 0 0 0 0 0 0 0 0 0
47258 - 0 0 0 0 0 1 0 0 1 0 0 0
47259 - 0 0 0 0 0 0 0 0 0 0 0 0
47260 - 0 0 0 0 0 0 0 0 0 0 0 0
47261 - 0 0 0 0 0 0 0 0 0 0 0 0
47262 - 0 0 0 0 0 0 0 0 0 0 0 0
47263 - 0 0 0 0 0 0 0 0 0 0 0 0
47264 - 0 0 0 0 0 0 0 0 0 0 0 0
47265 - 6 6 6 14 14 14 26 26 26 42 42 42
47266 - 54 54 54 66 66 66 78 78 78 78 78 78
47267 - 78 78 78 74 74 74 66 66 66 54 54 54
47268 - 42 42 42 26 26 26 18 18 18 10 10 10
47269 - 6 6 6 0 0 0 0 0 0 0 0 0
47270 - 0 0 0 0 0 0 0 0 0 0 0 0
47271 - 0 0 0 0 0 0 0 0 0 0 0 0
47272 - 0 0 0 0 0 0 0 0 0 0 0 0
47273 - 0 0 0 0 0 0 0 0 0 0 0 0
47274 - 0 0 0 0 0 0 0 0 0 0 0 0
47275 - 0 0 0 0 0 0 0 0 0 0 0 0
47276 - 0 0 0 0 0 0 0 0 0 0 0 0
47277 - 0 0 0 0 0 0 0 0 0 0 0 0
47278 - 0 0 1 0 0 0 0 0 0 0 0 0
47279 - 0 0 0 0 0 0 0 0 0 0 0 0
47280 - 0 0 0 0 0 0 0 0 0 0 0 0
47281 - 0 0 0 0 0 0 0 0 0 0 0 0
47282 - 0 0 0 0 0 0 0 0 0 0 0 0
47283 - 0 0 0 0 0 0 0 0 0 0 0 0
47284 - 0 0 0 0 0 0 0 0 0 10 10 10
47285 - 22 22 22 42 42 42 66 66 66 86 86 86
47286 - 66 66 66 38 38 38 38 38 38 22 22 22
47287 - 26 26 26 34 34 34 54 54 54 66 66 66
47288 - 86 86 86 70 70 70 46 46 46 26 26 26
47289 - 14 14 14 6 6 6 0 0 0 0 0 0
47290 - 0 0 0 0 0 0 0 0 0 0 0 0
47291 - 0 0 0 0 0 0 0 0 0 0 0 0
47292 - 0 0 0 0 0 0 0 0 0 0 0 0
47293 - 0 0 0 0 0 0 0 0 0 0 0 0
47294 - 0 0 0 0 0 0 0 0 0 0 0 0
47295 - 0 0 0 0 0 0 0 0 0 0 0 0
47296 - 0 0 0 0 0 0 0 0 0 0 0 0
47297 - 0 0 0 0 0 0 0 0 0 0 0 0
47298 - 0 0 1 0 0 1 0 0 1 0 0 0
47299 - 0 0 0 0 0 0 0 0 0 0 0 0
47300 - 0 0 0 0 0 0 0 0 0 0 0 0
47301 - 0 0 0 0 0 0 0 0 0 0 0 0
47302 - 0 0 0 0 0 0 0 0 0 0 0 0
47303 - 0 0 0 0 0 0 0 0 0 0 0 0
47304 - 0 0 0 0 0 0 10 10 10 26 26 26
47305 - 50 50 50 82 82 82 58 58 58 6 6 6
47306 - 2 2 6 2 2 6 2 2 6 2 2 6
47307 - 2 2 6 2 2 6 2 2 6 2 2 6
47308 - 6 6 6 54 54 54 86 86 86 66 66 66
47309 - 38 38 38 18 18 18 6 6 6 0 0 0
47310 - 0 0 0 0 0 0 0 0 0 0 0 0
47311 - 0 0 0 0 0 0 0 0 0 0 0 0
47312 - 0 0 0 0 0 0 0 0 0 0 0 0
47313 - 0 0 0 0 0 0 0 0 0 0 0 0
47314 - 0 0 0 0 0 0 0 0 0 0 0 0
47315 - 0 0 0 0 0 0 0 0 0 0 0 0
47316 - 0 0 0 0 0 0 0 0 0 0 0 0
47317 - 0 0 0 0 0 0 0 0 0 0 0 0
47318 - 0 0 0 0 0 0 0 0 0 0 0 0
47319 - 0 0 0 0 0 0 0 0 0 0 0 0
47320 - 0 0 0 0 0 0 0 0 0 0 0 0
47321 - 0 0 0 0 0 0 0 0 0 0 0 0
47322 - 0 0 0 0 0 0 0 0 0 0 0 0
47323 - 0 0 0 0 0 0 0 0 0 0 0 0
47324 - 0 0 0 6 6 6 22 22 22 50 50 50
47325 - 78 78 78 34 34 34 2 2 6 2 2 6
47326 - 2 2 6 2 2 6 2 2 6 2 2 6
47327 - 2 2 6 2 2 6 2 2 6 2 2 6
47328 - 2 2 6 2 2 6 6 6 6 70 70 70
47329 - 78 78 78 46 46 46 22 22 22 6 6 6
47330 - 0 0 0 0 0 0 0 0 0 0 0 0
47331 - 0 0 0 0 0 0 0 0 0 0 0 0
47332 - 0 0 0 0 0 0 0 0 0 0 0 0
47333 - 0 0 0 0 0 0 0 0 0 0 0 0
47334 - 0 0 0 0 0 0 0 0 0 0 0 0
47335 - 0 0 0 0 0 0 0 0 0 0 0 0
47336 - 0 0 0 0 0 0 0 0 0 0 0 0
47337 - 0 0 0 0 0 0 0 0 0 0 0 0
47338 - 0 0 1 0 0 1 0 0 1 0 0 0
47339 - 0 0 0 0 0 0 0 0 0 0 0 0
47340 - 0 0 0 0 0 0 0 0 0 0 0 0
47341 - 0 0 0 0 0 0 0 0 0 0 0 0
47342 - 0 0 0 0 0 0 0 0 0 0 0 0
47343 - 0 0 0 0 0 0 0 0 0 0 0 0
47344 - 6 6 6 18 18 18 42 42 42 82 82 82
47345 - 26 26 26 2 2 6 2 2 6 2 2 6
47346 - 2 2 6 2 2 6 2 2 6 2 2 6
47347 - 2 2 6 2 2 6 2 2 6 14 14 14
47348 - 46 46 46 34 34 34 6 6 6 2 2 6
47349 - 42 42 42 78 78 78 42 42 42 18 18 18
47350 - 6 6 6 0 0 0 0 0 0 0 0 0
47351 - 0 0 0 0 0 0 0 0 0 0 0 0
47352 - 0 0 0 0 0 0 0 0 0 0 0 0
47353 - 0 0 0 0 0 0 0 0 0 0 0 0
47354 - 0 0 0 0 0 0 0 0 0 0 0 0
47355 - 0 0 0 0 0 0 0 0 0 0 0 0
47356 - 0 0 0 0 0 0 0 0 0 0 0 0
47357 - 0 0 0 0 0 0 0 0 0 0 0 0
47358 - 0 0 1 0 0 0 0 0 1 0 0 0
47359 - 0 0 0 0 0 0 0 0 0 0 0 0
47360 - 0 0 0 0 0 0 0 0 0 0 0 0
47361 - 0 0 0 0 0 0 0 0 0 0 0 0
47362 - 0 0 0 0 0 0 0 0 0 0 0 0
47363 - 0 0 0 0 0 0 0 0 0 0 0 0
47364 - 10 10 10 30 30 30 66 66 66 58 58 58
47365 - 2 2 6 2 2 6 2 2 6 2 2 6
47366 - 2 2 6 2 2 6 2 2 6 2 2 6
47367 - 2 2 6 2 2 6 2 2 6 26 26 26
47368 - 86 86 86 101 101 101 46 46 46 10 10 10
47369 - 2 2 6 58 58 58 70 70 70 34 34 34
47370 - 10 10 10 0 0 0 0 0 0 0 0 0
47371 - 0 0 0 0 0 0 0 0 0 0 0 0
47372 - 0 0 0 0 0 0 0 0 0 0 0 0
47373 - 0 0 0 0 0 0 0 0 0 0 0 0
47374 - 0 0 0 0 0 0 0 0 0 0 0 0
47375 - 0 0 0 0 0 0 0 0 0 0 0 0
47376 - 0 0 0 0 0 0 0 0 0 0 0 0
47377 - 0 0 0 0 0 0 0 0 0 0 0 0
47378 - 0 0 1 0 0 1 0 0 1 0 0 0
47379 - 0 0 0 0 0 0 0 0 0 0 0 0
47380 - 0 0 0 0 0 0 0 0 0 0 0 0
47381 - 0 0 0 0 0 0 0 0 0 0 0 0
47382 - 0 0 0 0 0 0 0 0 0 0 0 0
47383 - 0 0 0 0 0 0 0 0 0 0 0 0
47384 - 14 14 14 42 42 42 86 86 86 10 10 10
47385 - 2 2 6 2 2 6 2 2 6 2 2 6
47386 - 2 2 6 2 2 6 2 2 6 2 2 6
47387 - 2 2 6 2 2 6 2 2 6 30 30 30
47388 - 94 94 94 94 94 94 58 58 58 26 26 26
47389 - 2 2 6 6 6 6 78 78 78 54 54 54
47390 - 22 22 22 6 6 6 0 0 0 0 0 0
47391 - 0 0 0 0 0 0 0 0 0 0 0 0
47392 - 0 0 0 0 0 0 0 0 0 0 0 0
47393 - 0 0 0 0 0 0 0 0 0 0 0 0
47394 - 0 0 0 0 0 0 0 0 0 0 0 0
47395 - 0 0 0 0 0 0 0 0 0 0 0 0
47396 - 0 0 0 0 0 0 0 0 0 0 0 0
47397 - 0 0 0 0 0 0 0 0 0 0 0 0
47398 - 0 0 0 0 0 0 0 0 0 0 0 0
47399 - 0 0 0 0 0 0 0 0 0 0 0 0
47400 - 0 0 0 0 0 0 0 0 0 0 0 0
47401 - 0 0 0 0 0 0 0 0 0 0 0 0
47402 - 0 0 0 0 0 0 0 0 0 0 0 0
47403 - 0 0 0 0 0 0 0 0 0 6 6 6
47404 - 22 22 22 62 62 62 62 62 62 2 2 6
47405 - 2 2 6 2 2 6 2 2 6 2 2 6
47406 - 2 2 6 2 2 6 2 2 6 2 2 6
47407 - 2 2 6 2 2 6 2 2 6 26 26 26
47408 - 54 54 54 38 38 38 18 18 18 10 10 10
47409 - 2 2 6 2 2 6 34 34 34 82 82 82
47410 - 38 38 38 14 14 14 0 0 0 0 0 0
47411 - 0 0 0 0 0 0 0 0 0 0 0 0
47412 - 0 0 0 0 0 0 0 0 0 0 0 0
47413 - 0 0 0 0 0 0 0 0 0 0 0 0
47414 - 0 0 0 0 0 0 0 0 0 0 0 0
47415 - 0 0 0 0 0 0 0 0 0 0 0 0
47416 - 0 0 0 0 0 0 0 0 0 0 0 0
47417 - 0 0 0 0 0 0 0 0 0 0 0 0
47418 - 0 0 0 0 0 1 0 0 1 0 0 0
47419 - 0 0 0 0 0 0 0 0 0 0 0 0
47420 - 0 0 0 0 0 0 0 0 0 0 0 0
47421 - 0 0 0 0 0 0 0 0 0 0 0 0
47422 - 0 0 0 0 0 0 0 0 0 0 0 0
47423 - 0 0 0 0 0 0 0 0 0 6 6 6
47424 - 30 30 30 78 78 78 30 30 30 2 2 6
47425 - 2 2 6 2 2 6 2 2 6 2 2 6
47426 - 2 2 6 2 2 6 2 2 6 2 2 6
47427 - 2 2 6 2 2 6 2 2 6 10 10 10
47428 - 10 10 10 2 2 6 2 2 6 2 2 6
47429 - 2 2 6 2 2 6 2 2 6 78 78 78
47430 - 50 50 50 18 18 18 6 6 6 0 0 0
47431 - 0 0 0 0 0 0 0 0 0 0 0 0
47432 - 0 0 0 0 0 0 0 0 0 0 0 0
47433 - 0 0 0 0 0 0 0 0 0 0 0 0
47434 - 0 0 0 0 0 0 0 0 0 0 0 0
47435 - 0 0 0 0 0 0 0 0 0 0 0 0
47436 - 0 0 0 0 0 0 0 0 0 0 0 0
47437 - 0 0 0 0 0 0 0 0 0 0 0 0
47438 - 0 0 1 0 0 0 0 0 0 0 0 0
47439 - 0 0 0 0 0 0 0 0 0 0 0 0
47440 - 0 0 0 0 0 0 0 0 0 0 0 0
47441 - 0 0 0 0 0 0 0 0 0 0 0 0
47442 - 0 0 0 0 0 0 0 0 0 0 0 0
47443 - 0 0 0 0 0 0 0 0 0 10 10 10
47444 - 38 38 38 86 86 86 14 14 14 2 2 6
47445 - 2 2 6 2 2 6 2 2 6 2 2 6
47446 - 2 2 6 2 2 6 2 2 6 2 2 6
47447 - 2 2 6 2 2 6 2 2 6 2 2 6
47448 - 2 2 6 2 2 6 2 2 6 2 2 6
47449 - 2 2 6 2 2 6 2 2 6 54 54 54
47450 - 66 66 66 26 26 26 6 6 6 0 0 0
47451 - 0 0 0 0 0 0 0 0 0 0 0 0
47452 - 0 0 0 0 0 0 0 0 0 0 0 0
47453 - 0 0 0 0 0 0 0 0 0 0 0 0
47454 - 0 0 0 0 0 0 0 0 0 0 0 0
47455 - 0 0 0 0 0 0 0 0 0 0 0 0
47456 - 0 0 0 0 0 0 0 0 0 0 0 0
47457 - 0 0 0 0 0 0 0 0 0 0 0 0
47458 - 0 0 0 0 0 1 0 0 1 0 0 0
47459 - 0 0 0 0 0 0 0 0 0 0 0 0
47460 - 0 0 0 0 0 0 0 0 0 0 0 0
47461 - 0 0 0 0 0 0 0 0 0 0 0 0
47462 - 0 0 0 0 0 0 0 0 0 0 0 0
47463 - 0 0 0 0 0 0 0 0 0 14 14 14
47464 - 42 42 42 82 82 82 2 2 6 2 2 6
47465 - 2 2 6 6 6 6 10 10 10 2 2 6
47466 - 2 2 6 2 2 6 2 2 6 2 2 6
47467 - 2 2 6 2 2 6 2 2 6 6 6 6
47468 - 14 14 14 10 10 10 2 2 6 2 2 6
47469 - 2 2 6 2 2 6 2 2 6 18 18 18
47470 - 82 82 82 34 34 34 10 10 10 0 0 0
47471 - 0 0 0 0 0 0 0 0 0 0 0 0
47472 - 0 0 0 0 0 0 0 0 0 0 0 0
47473 - 0 0 0 0 0 0 0 0 0 0 0 0
47474 - 0 0 0 0 0 0 0 0 0 0 0 0
47475 - 0 0 0 0 0 0 0 0 0 0 0 0
47476 - 0 0 0 0 0 0 0 0 0 0 0 0
47477 - 0 0 0 0 0 0 0 0 0 0 0 0
47478 - 0 0 1 0 0 0 0 0 0 0 0 0
47479 - 0 0 0 0 0 0 0 0 0 0 0 0
47480 - 0 0 0 0 0 0 0 0 0 0 0 0
47481 - 0 0 0 0 0 0 0 0 0 0 0 0
47482 - 0 0 0 0 0 0 0 0 0 0 0 0
47483 - 0 0 0 0 0 0 0 0 0 14 14 14
47484 - 46 46 46 86 86 86 2 2 6 2 2 6
47485 - 6 6 6 6 6 6 22 22 22 34 34 34
47486 - 6 6 6 2 2 6 2 2 6 2 2 6
47487 - 2 2 6 2 2 6 18 18 18 34 34 34
47488 - 10 10 10 50 50 50 22 22 22 2 2 6
47489 - 2 2 6 2 2 6 2 2 6 10 10 10
47490 - 86 86 86 42 42 42 14 14 14 0 0 0
47491 - 0 0 0 0 0 0 0 0 0 0 0 0
47492 - 0 0 0 0 0 0 0 0 0 0 0 0
47493 - 0 0 0 0 0 0 0 0 0 0 0 0
47494 - 0 0 0 0 0 0 0 0 0 0 0 0
47495 - 0 0 0 0 0 0 0 0 0 0 0 0
47496 - 0 0 0 0 0 0 0 0 0 0 0 0
47497 - 0 0 0 0 0 0 0 0 0 0 0 0
47498 - 0 0 1 0 0 1 0 0 1 0 0 0
47499 - 0 0 0 0 0 0 0 0 0 0 0 0
47500 - 0 0 0 0 0 0 0 0 0 0 0 0
47501 - 0 0 0 0 0 0 0 0 0 0 0 0
47502 - 0 0 0 0 0 0 0 0 0 0 0 0
47503 - 0 0 0 0 0 0 0 0 0 14 14 14
47504 - 46 46 46 86 86 86 2 2 6 2 2 6
47505 - 38 38 38 116 116 116 94 94 94 22 22 22
47506 - 22 22 22 2 2 6 2 2 6 2 2 6
47507 - 14 14 14 86 86 86 138 138 138 162 162 162
47508 -154 154 154 38 38 38 26 26 26 6 6 6
47509 - 2 2 6 2 2 6 2 2 6 2 2 6
47510 - 86 86 86 46 46 46 14 14 14 0 0 0
47511 - 0 0 0 0 0 0 0 0 0 0 0 0
47512 - 0 0 0 0 0 0 0 0 0 0 0 0
47513 - 0 0 0 0 0 0 0 0 0 0 0 0
47514 - 0 0 0 0 0 0 0 0 0 0 0 0
47515 - 0 0 0 0 0 0 0 0 0 0 0 0
47516 - 0 0 0 0 0 0 0 0 0 0 0 0
47517 - 0 0 0 0 0 0 0 0 0 0 0 0
47518 - 0 0 0 0 0 0 0 0 0 0 0 0
47519 - 0 0 0 0 0 0 0 0 0 0 0 0
47520 - 0 0 0 0 0 0 0 0 0 0 0 0
47521 - 0 0 0 0 0 0 0 0 0 0 0 0
47522 - 0 0 0 0 0 0 0 0 0 0 0 0
47523 - 0 0 0 0 0 0 0 0 0 14 14 14
47524 - 46 46 46 86 86 86 2 2 6 14 14 14
47525 -134 134 134 198 198 198 195 195 195 116 116 116
47526 - 10 10 10 2 2 6 2 2 6 6 6 6
47527 -101 98 89 187 187 187 210 210 210 218 218 218
47528 -214 214 214 134 134 134 14 14 14 6 6 6
47529 - 2 2 6 2 2 6 2 2 6 2 2 6
47530 - 86 86 86 50 50 50 18 18 18 6 6 6
47531 - 0 0 0 0 0 0 0 0 0 0 0 0
47532 - 0 0 0 0 0 0 0 0 0 0 0 0
47533 - 0 0 0 0 0 0 0 0 0 0 0 0
47534 - 0 0 0 0 0 0 0 0 0 0 0 0
47535 - 0 0 0 0 0 0 0 0 0 0 0 0
47536 - 0 0 0 0 0 0 0 0 0 0 0 0
47537 - 0 0 0 0 0 0 0 0 1 0 0 0
47538 - 0 0 1 0 0 1 0 0 1 0 0 0
47539 - 0 0 0 0 0 0 0 0 0 0 0 0
47540 - 0 0 0 0 0 0 0 0 0 0 0 0
47541 - 0 0 0 0 0 0 0 0 0 0 0 0
47542 - 0 0 0 0 0 0 0 0 0 0 0 0
47543 - 0 0 0 0 0 0 0 0 0 14 14 14
47544 - 46 46 46 86 86 86 2 2 6 54 54 54
47545 -218 218 218 195 195 195 226 226 226 246 246 246
47546 - 58 58 58 2 2 6 2 2 6 30 30 30
47547 -210 210 210 253 253 253 174 174 174 123 123 123
47548 -221 221 221 234 234 234 74 74 74 2 2 6
47549 - 2 2 6 2 2 6 2 2 6 2 2 6
47550 - 70 70 70 58 58 58 22 22 22 6 6 6
47551 - 0 0 0 0 0 0 0 0 0 0 0 0
47552 - 0 0 0 0 0 0 0 0 0 0 0 0
47553 - 0 0 0 0 0 0 0 0 0 0 0 0
47554 - 0 0 0 0 0 0 0 0 0 0 0 0
47555 - 0 0 0 0 0 0 0 0 0 0 0 0
47556 - 0 0 0 0 0 0 0 0 0 0 0 0
47557 - 0 0 0 0 0 0 0 0 0 0 0 0
47558 - 0 0 0 0 0 0 0 0 0 0 0 0
47559 - 0 0 0 0 0 0 0 0 0 0 0 0
47560 - 0 0 0 0 0 0 0 0 0 0 0 0
47561 - 0 0 0 0 0 0 0 0 0 0 0 0
47562 - 0 0 0 0 0 0 0 0 0 0 0 0
47563 - 0 0 0 0 0 0 0 0 0 14 14 14
47564 - 46 46 46 82 82 82 2 2 6 106 106 106
47565 -170 170 170 26 26 26 86 86 86 226 226 226
47566 -123 123 123 10 10 10 14 14 14 46 46 46
47567 -231 231 231 190 190 190 6 6 6 70 70 70
47568 - 90 90 90 238 238 238 158 158 158 2 2 6
47569 - 2 2 6 2 2 6 2 2 6 2 2 6
47570 - 70 70 70 58 58 58 22 22 22 6 6 6
47571 - 0 0 0 0 0 0 0 0 0 0 0 0
47572 - 0 0 0 0 0 0 0 0 0 0 0 0
47573 - 0 0 0 0 0 0 0 0 0 0 0 0
47574 - 0 0 0 0 0 0 0 0 0 0 0 0
47575 - 0 0 0 0 0 0 0 0 0 0 0 0
47576 - 0 0 0 0 0 0 0 0 0 0 0 0
47577 - 0 0 0 0 0 0 0 0 1 0 0 0
47578 - 0 0 1 0 0 1 0 0 1 0 0 0
47579 - 0 0 0 0 0 0 0 0 0 0 0 0
47580 - 0 0 0 0 0 0 0 0 0 0 0 0
47581 - 0 0 0 0 0 0 0 0 0 0 0 0
47582 - 0 0 0 0 0 0 0 0 0 0 0 0
47583 - 0 0 0 0 0 0 0 0 0 14 14 14
47584 - 42 42 42 86 86 86 6 6 6 116 116 116
47585 -106 106 106 6 6 6 70 70 70 149 149 149
47586 -128 128 128 18 18 18 38 38 38 54 54 54
47587 -221 221 221 106 106 106 2 2 6 14 14 14
47588 - 46 46 46 190 190 190 198 198 198 2 2 6
47589 - 2 2 6 2 2 6 2 2 6 2 2 6
47590 - 74 74 74 62 62 62 22 22 22 6 6 6
47591 - 0 0 0 0 0 0 0 0 0 0 0 0
47592 - 0 0 0 0 0 0 0 0 0 0 0 0
47593 - 0 0 0 0 0 0 0 0 0 0 0 0
47594 - 0 0 0 0 0 0 0 0 0 0 0 0
47595 - 0 0 0 0 0 0 0 0 0 0 0 0
47596 - 0 0 0 0 0 0 0 0 0 0 0 0
47597 - 0 0 0 0 0 0 0 0 1 0 0 0
47598 - 0 0 1 0 0 0 0 0 1 0 0 0
47599 - 0 0 0 0 0 0 0 0 0 0 0 0
47600 - 0 0 0 0 0 0 0 0 0 0 0 0
47601 - 0 0 0 0 0 0 0 0 0 0 0 0
47602 - 0 0 0 0 0 0 0 0 0 0 0 0
47603 - 0 0 0 0 0 0 0 0 0 14 14 14
47604 - 42 42 42 94 94 94 14 14 14 101 101 101
47605 -128 128 128 2 2 6 18 18 18 116 116 116
47606 -118 98 46 121 92 8 121 92 8 98 78 10
47607 -162 162 162 106 106 106 2 2 6 2 2 6
47608 - 2 2 6 195 195 195 195 195 195 6 6 6
47609 - 2 2 6 2 2 6 2 2 6 2 2 6
47610 - 74 74 74 62 62 62 22 22 22 6 6 6
47611 - 0 0 0 0 0 0 0 0 0 0 0 0
47612 - 0 0 0 0 0 0 0 0 0 0 0 0
47613 - 0 0 0 0 0 0 0 0 0 0 0 0
47614 - 0 0 0 0 0 0 0 0 0 0 0 0
47615 - 0 0 0 0 0 0 0 0 0 0 0 0
47616 - 0 0 0 0 0 0 0 0 0 0 0 0
47617 - 0 0 0 0 0 0 0 0 1 0 0 1
47618 - 0 0 1 0 0 0 0 0 1 0 0 0
47619 - 0 0 0 0 0 0 0 0 0 0 0 0
47620 - 0 0 0 0 0 0 0 0 0 0 0 0
47621 - 0 0 0 0 0 0 0 0 0 0 0 0
47622 - 0 0 0 0 0 0 0 0 0 0 0 0
47623 - 0 0 0 0 0 0 0 0 0 10 10 10
47624 - 38 38 38 90 90 90 14 14 14 58 58 58
47625 -210 210 210 26 26 26 54 38 6 154 114 10
47626 -226 170 11 236 186 11 225 175 15 184 144 12
47627 -215 174 15 175 146 61 37 26 9 2 2 6
47628 - 70 70 70 246 246 246 138 138 138 2 2 6
47629 - 2 2 6 2 2 6 2 2 6 2 2 6
47630 - 70 70 70 66 66 66 26 26 26 6 6 6
47631 - 0 0 0 0 0 0 0 0 0 0 0 0
47632 - 0 0 0 0 0 0 0 0 0 0 0 0
47633 - 0 0 0 0 0 0 0 0 0 0 0 0
47634 - 0 0 0 0 0 0 0 0 0 0 0 0
47635 - 0 0 0 0 0 0 0 0 0 0 0 0
47636 - 0 0 0 0 0 0 0 0 0 0 0 0
47637 - 0 0 0 0 0 0 0 0 0 0 0 0
47638 - 0 0 0 0 0 0 0 0 0 0 0 0
47639 - 0 0 0 0 0 0 0 0 0 0 0 0
47640 - 0 0 0 0 0 0 0 0 0 0 0 0
47641 - 0 0 0 0 0 0 0 0 0 0 0 0
47642 - 0 0 0 0 0 0 0 0 0 0 0 0
47643 - 0 0 0 0 0 0 0 0 0 10 10 10
47644 - 38 38 38 86 86 86 14 14 14 10 10 10
47645 -195 195 195 188 164 115 192 133 9 225 175 15
47646 -239 182 13 234 190 10 232 195 16 232 200 30
47647 -245 207 45 241 208 19 232 195 16 184 144 12
47648 -218 194 134 211 206 186 42 42 42 2 2 6
47649 - 2 2 6 2 2 6 2 2 6 2 2 6
47650 - 50 50 50 74 74 74 30 30 30 6 6 6
47651 - 0 0 0 0 0 0 0 0 0 0 0 0
47652 - 0 0 0 0 0 0 0 0 0 0 0 0
47653 - 0 0 0 0 0 0 0 0 0 0 0 0
47654 - 0 0 0 0 0 0 0 0 0 0 0 0
47655 - 0 0 0 0 0 0 0 0 0 0 0 0
47656 - 0 0 0 0 0 0 0 0 0 0 0 0
47657 - 0 0 0 0 0 0 0 0 0 0 0 0
47658 - 0 0 0 0 0 0 0 0 0 0 0 0
47659 - 0 0 0 0 0 0 0 0 0 0 0 0
47660 - 0 0 0 0 0 0 0 0 0 0 0 0
47661 - 0 0 0 0 0 0 0 0 0 0 0 0
47662 - 0 0 0 0 0 0 0 0 0 0 0 0
47663 - 0 0 0 0 0 0 0 0 0 10 10 10
47664 - 34 34 34 86 86 86 14 14 14 2 2 6
47665 -121 87 25 192 133 9 219 162 10 239 182 13
47666 -236 186 11 232 195 16 241 208 19 244 214 54
47667 -246 218 60 246 218 38 246 215 20 241 208 19
47668 -241 208 19 226 184 13 121 87 25 2 2 6
47669 - 2 2 6 2 2 6 2 2 6 2 2 6
47670 - 50 50 50 82 82 82 34 34 34 10 10 10
47671 - 0 0 0 0 0 0 0 0 0 0 0 0
47672 - 0 0 0 0 0 0 0 0 0 0 0 0
47673 - 0 0 0 0 0 0 0 0 0 0 0 0
47674 - 0 0 0 0 0 0 0 0 0 0 0 0
47675 - 0 0 0 0 0 0 0 0 0 0 0 0
47676 - 0 0 0 0 0 0 0 0 0 0 0 0
47677 - 0 0 0 0 0 0 0 0 0 0 0 0
47678 - 0 0 0 0 0 0 0 0 0 0 0 0
47679 - 0 0 0 0 0 0 0 0 0 0 0 0
47680 - 0 0 0 0 0 0 0 0 0 0 0 0
47681 - 0 0 0 0 0 0 0 0 0 0 0 0
47682 - 0 0 0 0 0 0 0 0 0 0 0 0
47683 - 0 0 0 0 0 0 0 0 0 10 10 10
47684 - 34 34 34 82 82 82 30 30 30 61 42 6
47685 -180 123 7 206 145 10 230 174 11 239 182 13
47686 -234 190 10 238 202 15 241 208 19 246 218 74
47687 -246 218 38 246 215 20 246 215 20 246 215 20
47688 -226 184 13 215 174 15 184 144 12 6 6 6
47689 - 2 2 6 2 2 6 2 2 6 2 2 6
47690 - 26 26 26 94 94 94 42 42 42 14 14 14
47691 - 0 0 0 0 0 0 0 0 0 0 0 0
47692 - 0 0 0 0 0 0 0 0 0 0 0 0
47693 - 0 0 0 0 0 0 0 0 0 0 0 0
47694 - 0 0 0 0 0 0 0 0 0 0 0 0
47695 - 0 0 0 0 0 0 0 0 0 0 0 0
47696 - 0 0 0 0 0 0 0 0 0 0 0 0
47697 - 0 0 0 0 0 0 0 0 0 0 0 0
47698 - 0 0 0 0 0 0 0 0 0 0 0 0
47699 - 0 0 0 0 0 0 0 0 0 0 0 0
47700 - 0 0 0 0 0 0 0 0 0 0 0 0
47701 - 0 0 0 0 0 0 0 0 0 0 0 0
47702 - 0 0 0 0 0 0 0 0 0 0 0 0
47703 - 0 0 0 0 0 0 0 0 0 10 10 10
47704 - 30 30 30 78 78 78 50 50 50 104 69 6
47705 -192 133 9 216 158 10 236 178 12 236 186 11
47706 -232 195 16 241 208 19 244 214 54 245 215 43
47707 -246 215 20 246 215 20 241 208 19 198 155 10
47708 -200 144 11 216 158 10 156 118 10 2 2 6
47709 - 2 2 6 2 2 6 2 2 6 2 2 6
47710 - 6 6 6 90 90 90 54 54 54 18 18 18
47711 - 6 6 6 0 0 0 0 0 0 0 0 0
47712 - 0 0 0 0 0 0 0 0 0 0 0 0
47713 - 0 0 0 0 0 0 0 0 0 0 0 0
47714 - 0 0 0 0 0 0 0 0 0 0 0 0
47715 - 0 0 0 0 0 0 0 0 0 0 0 0
47716 - 0 0 0 0 0 0 0 0 0 0 0 0
47717 - 0 0 0 0 0 0 0 0 0 0 0 0
47718 - 0 0 0 0 0 0 0 0 0 0 0 0
47719 - 0 0 0 0 0 0 0 0 0 0 0 0
47720 - 0 0 0 0 0 0 0 0 0 0 0 0
47721 - 0 0 0 0 0 0 0 0 0 0 0 0
47722 - 0 0 0 0 0 0 0 0 0 0 0 0
47723 - 0 0 0 0 0 0 0 0 0 10 10 10
47724 - 30 30 30 78 78 78 46 46 46 22 22 22
47725 -137 92 6 210 162 10 239 182 13 238 190 10
47726 -238 202 15 241 208 19 246 215 20 246 215 20
47727 -241 208 19 203 166 17 185 133 11 210 150 10
47728 -216 158 10 210 150 10 102 78 10 2 2 6
47729 - 6 6 6 54 54 54 14 14 14 2 2 6
47730 - 2 2 6 62 62 62 74 74 74 30 30 30
47731 - 10 10 10 0 0 0 0 0 0 0 0 0
47732 - 0 0 0 0 0 0 0 0 0 0 0 0
47733 - 0 0 0 0 0 0 0 0 0 0 0 0
47734 - 0 0 0 0 0 0 0 0 0 0 0 0
47735 - 0 0 0 0 0 0 0 0 0 0 0 0
47736 - 0 0 0 0 0 0 0 0 0 0 0 0
47737 - 0 0 0 0 0 0 0 0 0 0 0 0
47738 - 0 0 0 0 0 0 0 0 0 0 0 0
47739 - 0 0 0 0 0 0 0 0 0 0 0 0
47740 - 0 0 0 0 0 0 0 0 0 0 0 0
47741 - 0 0 0 0 0 0 0 0 0 0 0 0
47742 - 0 0 0 0 0 0 0 0 0 0 0 0
47743 - 0 0 0 0 0 0 0 0 0 10 10 10
47744 - 34 34 34 78 78 78 50 50 50 6 6 6
47745 - 94 70 30 139 102 15 190 146 13 226 184 13
47746 -232 200 30 232 195 16 215 174 15 190 146 13
47747 -168 122 10 192 133 9 210 150 10 213 154 11
47748 -202 150 34 182 157 106 101 98 89 2 2 6
47749 - 2 2 6 78 78 78 116 116 116 58 58 58
47750 - 2 2 6 22 22 22 90 90 90 46 46 46
47751 - 18 18 18 6 6 6 0 0 0 0 0 0
47752 - 0 0 0 0 0 0 0 0 0 0 0 0
47753 - 0 0 0 0 0 0 0 0 0 0 0 0
47754 - 0 0 0 0 0 0 0 0 0 0 0 0
47755 - 0 0 0 0 0 0 0 0 0 0 0 0
47756 - 0 0 0 0 0 0 0 0 0 0 0 0
47757 - 0 0 0 0 0 0 0 0 0 0 0 0
47758 - 0 0 0 0 0 0 0 0 0 0 0 0
47759 - 0 0 0 0 0 0 0 0 0 0 0 0
47760 - 0 0 0 0 0 0 0 0 0 0 0 0
47761 - 0 0 0 0 0 0 0 0 0 0 0 0
47762 - 0 0 0 0 0 0 0 0 0 0 0 0
47763 - 0 0 0 0 0 0 0 0 0 10 10 10
47764 - 38 38 38 86 86 86 50 50 50 6 6 6
47765 -128 128 128 174 154 114 156 107 11 168 122 10
47766 -198 155 10 184 144 12 197 138 11 200 144 11
47767 -206 145 10 206 145 10 197 138 11 188 164 115
47768 -195 195 195 198 198 198 174 174 174 14 14 14
47769 - 2 2 6 22 22 22 116 116 116 116 116 116
47770 - 22 22 22 2 2 6 74 74 74 70 70 70
47771 - 30 30 30 10 10 10 0 0 0 0 0 0
47772 - 0 0 0 0 0 0 0 0 0 0 0 0
47773 - 0 0 0 0 0 0 0 0 0 0 0 0
47774 - 0 0 0 0 0 0 0 0 0 0 0 0
47775 - 0 0 0 0 0 0 0 0 0 0 0 0
47776 - 0 0 0 0 0 0 0 0 0 0 0 0
47777 - 0 0 0 0 0 0 0 0 0 0 0 0
47778 - 0 0 0 0 0 0 0 0 0 0 0 0
47779 - 0 0 0 0 0 0 0 0 0 0 0 0
47780 - 0 0 0 0 0 0 0 0 0 0 0 0
47781 - 0 0 0 0 0 0 0 0 0 0 0 0
47782 - 0 0 0 0 0 0 0 0 0 0 0 0
47783 - 0 0 0 0 0 0 6 6 6 18 18 18
47784 - 50 50 50 101 101 101 26 26 26 10 10 10
47785 -138 138 138 190 190 190 174 154 114 156 107 11
47786 -197 138 11 200 144 11 197 138 11 192 133 9
47787 -180 123 7 190 142 34 190 178 144 187 187 187
47788 -202 202 202 221 221 221 214 214 214 66 66 66
47789 - 2 2 6 2 2 6 50 50 50 62 62 62
47790 - 6 6 6 2 2 6 10 10 10 90 90 90
47791 - 50 50 50 18 18 18 6 6 6 0 0 0
47792 - 0 0 0 0 0 0 0 0 0 0 0 0
47793 - 0 0 0 0 0 0 0 0 0 0 0 0
47794 - 0 0 0 0 0 0 0 0 0 0 0 0
47795 - 0 0 0 0 0 0 0 0 0 0 0 0
47796 - 0 0 0 0 0 0 0 0 0 0 0 0
47797 - 0 0 0 0 0 0 0 0 0 0 0 0
47798 - 0 0 0 0 0 0 0 0 0 0 0 0
47799 - 0 0 0 0 0 0 0 0 0 0 0 0
47800 - 0 0 0 0 0 0 0 0 0 0 0 0
47801 - 0 0 0 0 0 0 0 0 0 0 0 0
47802 - 0 0 0 0 0 0 0 0 0 0 0 0
47803 - 0 0 0 0 0 0 10 10 10 34 34 34
47804 - 74 74 74 74 74 74 2 2 6 6 6 6
47805 -144 144 144 198 198 198 190 190 190 178 166 146
47806 -154 121 60 156 107 11 156 107 11 168 124 44
47807 -174 154 114 187 187 187 190 190 190 210 210 210
47808 -246 246 246 253 253 253 253 253 253 182 182 182
47809 - 6 6 6 2 2 6 2 2 6 2 2 6
47810 - 2 2 6 2 2 6 2 2 6 62 62 62
47811 - 74 74 74 34 34 34 14 14 14 0 0 0
47812 - 0 0 0 0 0 0 0 0 0 0 0 0
47813 - 0 0 0 0 0 0 0 0 0 0 0 0
47814 - 0 0 0 0 0 0 0 0 0 0 0 0
47815 - 0 0 0 0 0 0 0 0 0 0 0 0
47816 - 0 0 0 0 0 0 0 0 0 0 0 0
47817 - 0 0 0 0 0 0 0 0 0 0 0 0
47818 - 0 0 0 0 0 0 0 0 0 0 0 0
47819 - 0 0 0 0 0 0 0 0 0 0 0 0
47820 - 0 0 0 0 0 0 0 0 0 0 0 0
47821 - 0 0 0 0 0 0 0 0 0 0 0 0
47822 - 0 0 0 0 0 0 0 0 0 0 0 0
47823 - 0 0 0 10 10 10 22 22 22 54 54 54
47824 - 94 94 94 18 18 18 2 2 6 46 46 46
47825 -234 234 234 221 221 221 190 190 190 190 190 190
47826 -190 190 190 187 187 187 187 187 187 190 190 190
47827 -190 190 190 195 195 195 214 214 214 242 242 242
47828 -253 253 253 253 253 253 253 253 253 253 253 253
47829 - 82 82 82 2 2 6 2 2 6 2 2 6
47830 - 2 2 6 2 2 6 2 2 6 14 14 14
47831 - 86 86 86 54 54 54 22 22 22 6 6 6
47832 - 0 0 0 0 0 0 0 0 0 0 0 0
47833 - 0 0 0 0 0 0 0 0 0 0 0 0
47834 - 0 0 0 0 0 0 0 0 0 0 0 0
47835 - 0 0 0 0 0 0 0 0 0 0 0 0
47836 - 0 0 0 0 0 0 0 0 0 0 0 0
47837 - 0 0 0 0 0 0 0 0 0 0 0 0
47838 - 0 0 0 0 0 0 0 0 0 0 0 0
47839 - 0 0 0 0 0 0 0 0 0 0 0 0
47840 - 0 0 0 0 0 0 0 0 0 0 0 0
47841 - 0 0 0 0 0 0 0 0 0 0 0 0
47842 - 0 0 0 0 0 0 0 0 0 0 0 0
47843 - 6 6 6 18 18 18 46 46 46 90 90 90
47844 - 46 46 46 18 18 18 6 6 6 182 182 182
47845 -253 253 253 246 246 246 206 206 206 190 190 190
47846 -190 190 190 190 190 190 190 190 190 190 190 190
47847 -206 206 206 231 231 231 250 250 250 253 253 253
47848 -253 253 253 253 253 253 253 253 253 253 253 253
47849 -202 202 202 14 14 14 2 2 6 2 2 6
47850 - 2 2 6 2 2 6 2 2 6 2 2 6
47851 - 42 42 42 86 86 86 42 42 42 18 18 18
47852 - 6 6 6 0 0 0 0 0 0 0 0 0
47853 - 0 0 0 0 0 0 0 0 0 0 0 0
47854 - 0 0 0 0 0 0 0 0 0 0 0 0
47855 - 0 0 0 0 0 0 0 0 0 0 0 0
47856 - 0 0 0 0 0 0 0 0 0 0 0 0
47857 - 0 0 0 0 0 0 0 0 0 0 0 0
47858 - 0 0 0 0 0 0 0 0 0 0 0 0
47859 - 0 0 0 0 0 0 0 0 0 0 0 0
47860 - 0 0 0 0 0 0 0 0 0 0 0 0
47861 - 0 0 0 0 0 0 0 0 0 0 0 0
47862 - 0 0 0 0 0 0 0 0 0 6 6 6
47863 - 14 14 14 38 38 38 74 74 74 66 66 66
47864 - 2 2 6 6 6 6 90 90 90 250 250 250
47865 -253 253 253 253 253 253 238 238 238 198 198 198
47866 -190 190 190 190 190 190 195 195 195 221 221 221
47867 -246 246 246 253 253 253 253 253 253 253 253 253
47868 -253 253 253 253 253 253 253 253 253 253 253 253
47869 -253 253 253 82 82 82 2 2 6 2 2 6
47870 - 2 2 6 2 2 6 2 2 6 2 2 6
47871 - 2 2 6 78 78 78 70 70 70 34 34 34
47872 - 14 14 14 6 6 6 0 0 0 0 0 0
47873 - 0 0 0 0 0 0 0 0 0 0 0 0
47874 - 0 0 0 0 0 0 0 0 0 0 0 0
47875 - 0 0 0 0 0 0 0 0 0 0 0 0
47876 - 0 0 0 0 0 0 0 0 0 0 0 0
47877 - 0 0 0 0 0 0 0 0 0 0 0 0
47878 - 0 0 0 0 0 0 0 0 0 0 0 0
47879 - 0 0 0 0 0 0 0 0 0 0 0 0
47880 - 0 0 0 0 0 0 0 0 0 0 0 0
47881 - 0 0 0 0 0 0 0 0 0 0 0 0
47882 - 0 0 0 0 0 0 0 0 0 14 14 14
47883 - 34 34 34 66 66 66 78 78 78 6 6 6
47884 - 2 2 6 18 18 18 218 218 218 253 253 253
47885 -253 253 253 253 253 253 253 253 253 246 246 246
47886 -226 226 226 231 231 231 246 246 246 253 253 253
47887 -253 253 253 253 253 253 253 253 253 253 253 253
47888 -253 253 253 253 253 253 253 253 253 253 253 253
47889 -253 253 253 178 178 178 2 2 6 2 2 6
47890 - 2 2 6 2 2 6 2 2 6 2 2 6
47891 - 2 2 6 18 18 18 90 90 90 62 62 62
47892 - 30 30 30 10 10 10 0 0 0 0 0 0
47893 - 0 0 0 0 0 0 0 0 0 0 0 0
47894 - 0 0 0 0 0 0 0 0 0 0 0 0
47895 - 0 0 0 0 0 0 0 0 0 0 0 0
47896 - 0 0 0 0 0 0 0 0 0 0 0 0
47897 - 0 0 0 0 0 0 0 0 0 0 0 0
47898 - 0 0 0 0 0 0 0 0 0 0 0 0
47899 - 0 0 0 0 0 0 0 0 0 0 0 0
47900 - 0 0 0 0 0 0 0 0 0 0 0 0
47901 - 0 0 0 0 0 0 0 0 0 0 0 0
47902 - 0 0 0 0 0 0 10 10 10 26 26 26
47903 - 58 58 58 90 90 90 18 18 18 2 2 6
47904 - 2 2 6 110 110 110 253 253 253 253 253 253
47905 -253 253 253 253 253 253 253 253 253 253 253 253
47906 -250 250 250 253 253 253 253 253 253 253 253 253
47907 -253 253 253 253 253 253 253 253 253 253 253 253
47908 -253 253 253 253 253 253 253 253 253 253 253 253
47909 -253 253 253 231 231 231 18 18 18 2 2 6
47910 - 2 2 6 2 2 6 2 2 6 2 2 6
47911 - 2 2 6 2 2 6 18 18 18 94 94 94
47912 - 54 54 54 26 26 26 10 10 10 0 0 0
47913 - 0 0 0 0 0 0 0 0 0 0 0 0
47914 - 0 0 0 0 0 0 0 0 0 0 0 0
47915 - 0 0 0 0 0 0 0 0 0 0 0 0
47916 - 0 0 0 0 0 0 0 0 0 0 0 0
47917 - 0 0 0 0 0 0 0 0 0 0 0 0
47918 - 0 0 0 0 0 0 0 0 0 0 0 0
47919 - 0 0 0 0 0 0 0 0 0 0 0 0
47920 - 0 0 0 0 0 0 0 0 0 0 0 0
47921 - 0 0 0 0 0 0 0 0 0 0 0 0
47922 - 0 0 0 6 6 6 22 22 22 50 50 50
47923 - 90 90 90 26 26 26 2 2 6 2 2 6
47924 - 14 14 14 195 195 195 250 250 250 253 253 253
47925 -253 253 253 253 253 253 253 253 253 253 253 253
47926 -253 253 253 253 253 253 253 253 253 253 253 253
47927 -253 253 253 253 253 253 253 253 253 253 253 253
47928 -253 253 253 253 253 253 253 253 253 253 253 253
47929 -250 250 250 242 242 242 54 54 54 2 2 6
47930 - 2 2 6 2 2 6 2 2 6 2 2 6
47931 - 2 2 6 2 2 6 2 2 6 38 38 38
47932 - 86 86 86 50 50 50 22 22 22 6 6 6
47933 - 0 0 0 0 0 0 0 0 0 0 0 0
47934 - 0 0 0 0 0 0 0 0 0 0 0 0
47935 - 0 0 0 0 0 0 0 0 0 0 0 0
47936 - 0 0 0 0 0 0 0 0 0 0 0 0
47937 - 0 0 0 0 0 0 0 0 0 0 0 0
47938 - 0 0 0 0 0 0 0 0 0 0 0 0
47939 - 0 0 0 0 0 0 0 0 0 0 0 0
47940 - 0 0 0 0 0 0 0 0 0 0 0 0
47941 - 0 0 0 0 0 0 0 0 0 0 0 0
47942 - 6 6 6 14 14 14 38 38 38 82 82 82
47943 - 34 34 34 2 2 6 2 2 6 2 2 6
47944 - 42 42 42 195 195 195 246 246 246 253 253 253
47945 -253 253 253 253 253 253 253 253 253 250 250 250
47946 -242 242 242 242 242 242 250 250 250 253 253 253
47947 -253 253 253 253 253 253 253 253 253 253 253 253
47948 -253 253 253 250 250 250 246 246 246 238 238 238
47949 -226 226 226 231 231 231 101 101 101 6 6 6
47950 - 2 2 6 2 2 6 2 2 6 2 2 6
47951 - 2 2 6 2 2 6 2 2 6 2 2 6
47952 - 38 38 38 82 82 82 42 42 42 14 14 14
47953 - 6 6 6 0 0 0 0 0 0 0 0 0
47954 - 0 0 0 0 0 0 0 0 0 0 0 0
47955 - 0 0 0 0 0 0 0 0 0 0 0 0
47956 - 0 0 0 0 0 0 0 0 0 0 0 0
47957 - 0 0 0 0 0 0 0 0 0 0 0 0
47958 - 0 0 0 0 0 0 0 0 0 0 0 0
47959 - 0 0 0 0 0 0 0 0 0 0 0 0
47960 - 0 0 0 0 0 0 0 0 0 0 0 0
47961 - 0 0 0 0 0 0 0 0 0 0 0 0
47962 - 10 10 10 26 26 26 62 62 62 66 66 66
47963 - 2 2 6 2 2 6 2 2 6 6 6 6
47964 - 70 70 70 170 170 170 206 206 206 234 234 234
47965 -246 246 246 250 250 250 250 250 250 238 238 238
47966 -226 226 226 231 231 231 238 238 238 250 250 250
47967 -250 250 250 250 250 250 246 246 246 231 231 231
47968 -214 214 214 206 206 206 202 202 202 202 202 202
47969 -198 198 198 202 202 202 182 182 182 18 18 18
47970 - 2 2 6 2 2 6 2 2 6 2 2 6
47971 - 2 2 6 2 2 6 2 2 6 2 2 6
47972 - 2 2 6 62 62 62 66 66 66 30 30 30
47973 - 10 10 10 0 0 0 0 0 0 0 0 0
47974 - 0 0 0 0 0 0 0 0 0 0 0 0
47975 - 0 0 0 0 0 0 0 0 0 0 0 0
47976 - 0 0 0 0 0 0 0 0 0 0 0 0
47977 - 0 0 0 0 0 0 0 0 0 0 0 0
47978 - 0 0 0 0 0 0 0 0 0 0 0 0
47979 - 0 0 0 0 0 0 0 0 0 0 0 0
47980 - 0 0 0 0 0 0 0 0 0 0 0 0
47981 - 0 0 0 0 0 0 0 0 0 0 0 0
47982 - 14 14 14 42 42 42 82 82 82 18 18 18
47983 - 2 2 6 2 2 6 2 2 6 10 10 10
47984 - 94 94 94 182 182 182 218 218 218 242 242 242
47985 -250 250 250 253 253 253 253 253 253 250 250 250
47986 -234 234 234 253 253 253 253 253 253 253 253 253
47987 -253 253 253 253 253 253 253 253 253 246 246 246
47988 -238 238 238 226 226 226 210 210 210 202 202 202
47989 -195 195 195 195 195 195 210 210 210 158 158 158
47990 - 6 6 6 14 14 14 50 50 50 14 14 14
47991 - 2 2 6 2 2 6 2 2 6 2 2 6
47992 - 2 2 6 6 6 6 86 86 86 46 46 46
47993 - 18 18 18 6 6 6 0 0 0 0 0 0
47994 - 0 0 0 0 0 0 0 0 0 0 0 0
47995 - 0 0 0 0 0 0 0 0 0 0 0 0
47996 - 0 0 0 0 0 0 0 0 0 0 0 0
47997 - 0 0 0 0 0 0 0 0 0 0 0 0
47998 - 0 0 0 0 0 0 0 0 0 0 0 0
47999 - 0 0 0 0 0 0 0 0 0 0 0 0
48000 - 0 0 0 0 0 0 0 0 0 0 0 0
48001 - 0 0 0 0 0 0 0 0 0 6 6 6
48002 - 22 22 22 54 54 54 70 70 70 2 2 6
48003 - 2 2 6 10 10 10 2 2 6 22 22 22
48004 -166 166 166 231 231 231 250 250 250 253 253 253
48005 -253 253 253 253 253 253 253 253 253 250 250 250
48006 -242 242 242 253 253 253 253 253 253 253 253 253
48007 -253 253 253 253 253 253 253 253 253 253 253 253
48008 -253 253 253 253 253 253 253 253 253 246 246 246
48009 -231 231 231 206 206 206 198 198 198 226 226 226
48010 - 94 94 94 2 2 6 6 6 6 38 38 38
48011 - 30 30 30 2 2 6 2 2 6 2 2 6
48012 - 2 2 6 2 2 6 62 62 62 66 66 66
48013 - 26 26 26 10 10 10 0 0 0 0 0 0
48014 - 0 0 0 0 0 0 0 0 0 0 0 0
48015 - 0 0 0 0 0 0 0 0 0 0 0 0
48016 - 0 0 0 0 0 0 0 0 0 0 0 0
48017 - 0 0 0 0 0 0 0 0 0 0 0 0
48018 - 0 0 0 0 0 0 0 0 0 0 0 0
48019 - 0 0 0 0 0 0 0 0 0 0 0 0
48020 - 0 0 0 0 0 0 0 0 0 0 0 0
48021 - 0 0 0 0 0 0 0 0 0 10 10 10
48022 - 30 30 30 74 74 74 50 50 50 2 2 6
48023 - 26 26 26 26 26 26 2 2 6 106 106 106
48024 -238 238 238 253 253 253 253 253 253 253 253 253
48025 -253 253 253 253 253 253 253 253 253 253 253 253
48026 -253 253 253 253 253 253 253 253 253 253 253 253
48027 -253 253 253 253 253 253 253 253 253 253 253 253
48028 -253 253 253 253 253 253 253 253 253 253 253 253
48029 -253 253 253 246 246 246 218 218 218 202 202 202
48030 -210 210 210 14 14 14 2 2 6 2 2 6
48031 - 30 30 30 22 22 22 2 2 6 2 2 6
48032 - 2 2 6 2 2 6 18 18 18 86 86 86
48033 - 42 42 42 14 14 14 0 0 0 0 0 0
48034 - 0 0 0 0 0 0 0 0 0 0 0 0
48035 - 0 0 0 0 0 0 0 0 0 0 0 0
48036 - 0 0 0 0 0 0 0 0 0 0 0 0
48037 - 0 0 0 0 0 0 0 0 0 0 0 0
48038 - 0 0 0 0 0 0 0 0 0 0 0 0
48039 - 0 0 0 0 0 0 0 0 0 0 0 0
48040 - 0 0 0 0 0 0 0 0 0 0 0 0
48041 - 0 0 0 0 0 0 0 0 0 14 14 14
48042 - 42 42 42 90 90 90 22 22 22 2 2 6
48043 - 42 42 42 2 2 6 18 18 18 218 218 218
48044 -253 253 253 253 253 253 253 253 253 253 253 253
48045 -253 253 253 253 253 253 253 253 253 253 253 253
48046 -253 253 253 253 253 253 253 253 253 253 253 253
48047 -253 253 253 253 253 253 253 253 253 253 253 253
48048 -253 253 253 253 253 253 253 253 253 253 253 253
48049 -253 253 253 253 253 253 250 250 250 221 221 221
48050 -218 218 218 101 101 101 2 2 6 14 14 14
48051 - 18 18 18 38 38 38 10 10 10 2 2 6
48052 - 2 2 6 2 2 6 2 2 6 78 78 78
48053 - 58 58 58 22 22 22 6 6 6 0 0 0
48054 - 0 0 0 0 0 0 0 0 0 0 0 0
48055 - 0 0 0 0 0 0 0 0 0 0 0 0
48056 - 0 0 0 0 0 0 0 0 0 0 0 0
48057 - 0 0 0 0 0 0 0 0 0 0 0 0
48058 - 0 0 0 0 0 0 0 0 0 0 0 0
48059 - 0 0 0 0 0 0 0 0 0 0 0 0
48060 - 0 0 0 0 0 0 0 0 0 0 0 0
48061 - 0 0 0 0 0 0 6 6 6 18 18 18
48062 - 54 54 54 82 82 82 2 2 6 26 26 26
48063 - 22 22 22 2 2 6 123 123 123 253 253 253
48064 -253 253 253 253 253 253 253 253 253 253 253 253
48065 -253 253 253 253 253 253 253 253 253 253 253 253
48066 -253 253 253 253 253 253 253 253 253 253 253 253
48067 -253 253 253 253 253 253 253 253 253 253 253 253
48068 -253 253 253 253 253 253 253 253 253 253 253 253
48069 -253 253 253 253 253 253 253 253 253 250 250 250
48070 -238 238 238 198 198 198 6 6 6 38 38 38
48071 - 58 58 58 26 26 26 38 38 38 2 2 6
48072 - 2 2 6 2 2 6 2 2 6 46 46 46
48073 - 78 78 78 30 30 30 10 10 10 0 0 0
48074 - 0 0 0 0 0 0 0 0 0 0 0 0
48075 - 0 0 0 0 0 0 0 0 0 0 0 0
48076 - 0 0 0 0 0 0 0 0 0 0 0 0
48077 - 0 0 0 0 0 0 0 0 0 0 0 0
48078 - 0 0 0 0 0 0 0 0 0 0 0 0
48079 - 0 0 0 0 0 0 0 0 0 0 0 0
48080 - 0 0 0 0 0 0 0 0 0 0 0 0
48081 - 0 0 0 0 0 0 10 10 10 30 30 30
48082 - 74 74 74 58 58 58 2 2 6 42 42 42
48083 - 2 2 6 22 22 22 231 231 231 253 253 253
48084 -253 253 253 253 253 253 253 253 253 253 253 253
48085 -253 253 253 253 253 253 253 253 253 250 250 250
48086 -253 253 253 253 253 253 253 253 253 253 253 253
48087 -253 253 253 253 253 253 253 253 253 253 253 253
48088 -253 253 253 253 253 253 253 253 253 253 253 253
48089 -253 253 253 253 253 253 253 253 253 253 253 253
48090 -253 253 253 246 246 246 46 46 46 38 38 38
48091 - 42 42 42 14 14 14 38 38 38 14 14 14
48092 - 2 2 6 2 2 6 2 2 6 6 6 6
48093 - 86 86 86 46 46 46 14 14 14 0 0 0
48094 - 0 0 0 0 0 0 0 0 0 0 0 0
48095 - 0 0 0 0 0 0 0 0 0 0 0 0
48096 - 0 0 0 0 0 0 0 0 0 0 0 0
48097 - 0 0 0 0 0 0 0 0 0 0 0 0
48098 - 0 0 0 0 0 0 0 0 0 0 0 0
48099 - 0 0 0 0 0 0 0 0 0 0 0 0
48100 - 0 0 0 0 0 0 0 0 0 0 0 0
48101 - 0 0 0 6 6 6 14 14 14 42 42 42
48102 - 90 90 90 18 18 18 18 18 18 26 26 26
48103 - 2 2 6 116 116 116 253 253 253 253 253 253
48104 -253 253 253 253 253 253 253 253 253 253 253 253
48105 -253 253 253 253 253 253 250 250 250 238 238 238
48106 -253 253 253 253 253 253 253 253 253 253 253 253
48107 -253 253 253 253 253 253 253 253 253 253 253 253
48108 -253 253 253 253 253 253 253 253 253 253 253 253
48109 -253 253 253 253 253 253 253 253 253 253 253 253
48110 -253 253 253 253 253 253 94 94 94 6 6 6
48111 - 2 2 6 2 2 6 10 10 10 34 34 34
48112 - 2 2 6 2 2 6 2 2 6 2 2 6
48113 - 74 74 74 58 58 58 22 22 22 6 6 6
48114 - 0 0 0 0 0 0 0 0 0 0 0 0
48115 - 0 0 0 0 0 0 0 0 0 0 0 0
48116 - 0 0 0 0 0 0 0 0 0 0 0 0
48117 - 0 0 0 0 0 0 0 0 0 0 0 0
48118 - 0 0 0 0 0 0 0 0 0 0 0 0
48119 - 0 0 0 0 0 0 0 0 0 0 0 0
48120 - 0 0 0 0 0 0 0 0 0 0 0 0
48121 - 0 0 0 10 10 10 26 26 26 66 66 66
48122 - 82 82 82 2 2 6 38 38 38 6 6 6
48123 - 14 14 14 210 210 210 253 253 253 253 253 253
48124 -253 253 253 253 253 253 253 253 253 253 253 253
48125 -253 253 253 253 253 253 246 246 246 242 242 242
48126 -253 253 253 253 253 253 253 253 253 253 253 253
48127 -253 253 253 253 253 253 253 253 253 253 253 253
48128 -253 253 253 253 253 253 253 253 253 253 253 253
48129 -253 253 253 253 253 253 253 253 253 253 253 253
48130 -253 253 253 253 253 253 144 144 144 2 2 6
48131 - 2 2 6 2 2 6 2 2 6 46 46 46
48132 - 2 2 6 2 2 6 2 2 6 2 2 6
48133 - 42 42 42 74 74 74 30 30 30 10 10 10
48134 - 0 0 0 0 0 0 0 0 0 0 0 0
48135 - 0 0 0 0 0 0 0 0 0 0 0 0
48136 - 0 0 0 0 0 0 0 0 0 0 0 0
48137 - 0 0 0 0 0 0 0 0 0 0 0 0
48138 - 0 0 0 0 0 0 0 0 0 0 0 0
48139 - 0 0 0 0 0 0 0 0 0 0 0 0
48140 - 0 0 0 0 0 0 0 0 0 0 0 0
48141 - 6 6 6 14 14 14 42 42 42 90 90 90
48142 - 26 26 26 6 6 6 42 42 42 2 2 6
48143 - 74 74 74 250 250 250 253 253 253 253 253 253
48144 -253 253 253 253 253 253 253 253 253 253 253 253
48145 -253 253 253 253 253 253 242 242 242 242 242 242
48146 -253 253 253 253 253 253 253 253 253 253 253 253
48147 -253 253 253 253 253 253 253 253 253 253 253 253
48148 -253 253 253 253 253 253 253 253 253 253 253 253
48149 -253 253 253 253 253 253 253 253 253 253 253 253
48150 -253 253 253 253 253 253 182 182 182 2 2 6
48151 - 2 2 6 2 2 6 2 2 6 46 46 46
48152 - 2 2 6 2 2 6 2 2 6 2 2 6
48153 - 10 10 10 86 86 86 38 38 38 10 10 10
48154 - 0 0 0 0 0 0 0 0 0 0 0 0
48155 - 0 0 0 0 0 0 0 0 0 0 0 0
48156 - 0 0 0 0 0 0 0 0 0 0 0 0
48157 - 0 0 0 0 0 0 0 0 0 0 0 0
48158 - 0 0 0 0 0 0 0 0 0 0 0 0
48159 - 0 0 0 0 0 0 0 0 0 0 0 0
48160 - 0 0 0 0 0 0 0 0 0 0 0 0
48161 - 10 10 10 26 26 26 66 66 66 82 82 82
48162 - 2 2 6 22 22 22 18 18 18 2 2 6
48163 -149 149 149 253 253 253 253 253 253 253 253 253
48164 -253 253 253 253 253 253 253 253 253 253 253 253
48165 -253 253 253 253 253 253 234 234 234 242 242 242
48166 -253 253 253 253 253 253 253 253 253 253 253 253
48167 -253 253 253 253 253 253 253 253 253 253 253 253
48168 -253 253 253 253 253 253 253 253 253 253 253 253
48169 -253 253 253 253 253 253 253 253 253 253 253 253
48170 -253 253 253 253 253 253 206 206 206 2 2 6
48171 - 2 2 6 2 2 6 2 2 6 38 38 38
48172 - 2 2 6 2 2 6 2 2 6 2 2 6
48173 - 6 6 6 86 86 86 46 46 46 14 14 14
48174 - 0 0 0 0 0 0 0 0 0 0 0 0
48175 - 0 0 0 0 0 0 0 0 0 0 0 0
48176 - 0 0 0 0 0 0 0 0 0 0 0 0
48177 - 0 0 0 0 0 0 0 0 0 0 0 0
48178 - 0 0 0 0 0 0 0 0 0 0 0 0
48179 - 0 0 0 0 0 0 0 0 0 0 0 0
48180 - 0 0 0 0 0 0 0 0 0 6 6 6
48181 - 18 18 18 46 46 46 86 86 86 18 18 18
48182 - 2 2 6 34 34 34 10 10 10 6 6 6
48183 -210 210 210 253 253 253 253 253 253 253 253 253
48184 -253 253 253 253 253 253 253 253 253 253 253 253
48185 -253 253 253 253 253 253 234 234 234 242 242 242
48186 -253 253 253 253 253 253 253 253 253 253 253 253
48187 -253 253 253 253 253 253 253 253 253 253 253 253
48188 -253 253 253 253 253 253 253 253 253 253 253 253
48189 -253 253 253 253 253 253 253 253 253 253 253 253
48190 -253 253 253 253 253 253 221 221 221 6 6 6
48191 - 2 2 6 2 2 6 6 6 6 30 30 30
48192 - 2 2 6 2 2 6 2 2 6 2 2 6
48193 - 2 2 6 82 82 82 54 54 54 18 18 18
48194 - 6 6 6 0 0 0 0 0 0 0 0 0
48195 - 0 0 0 0 0 0 0 0 0 0 0 0
48196 - 0 0 0 0 0 0 0 0 0 0 0 0
48197 - 0 0 0 0 0 0 0 0 0 0 0 0
48198 - 0 0 0 0 0 0 0 0 0 0 0 0
48199 - 0 0 0 0 0 0 0 0 0 0 0 0
48200 - 0 0 0 0 0 0 0 0 0 10 10 10
48201 - 26 26 26 66 66 66 62 62 62 2 2 6
48202 - 2 2 6 38 38 38 10 10 10 26 26 26
48203 -238 238 238 253 253 253 253 253 253 253 253 253
48204 -253 253 253 253 253 253 253 253 253 253 253 253
48205 -253 253 253 253 253 253 231 231 231 238 238 238
48206 -253 253 253 253 253 253 253 253 253 253 253 253
48207 -253 253 253 253 253 253 253 253 253 253 253 253
48208 -253 253 253 253 253 253 253 253 253 253 253 253
48209 -253 253 253 253 253 253 253 253 253 253 253 253
48210 -253 253 253 253 253 253 231 231 231 6 6 6
48211 - 2 2 6 2 2 6 10 10 10 30 30 30
48212 - 2 2 6 2 2 6 2 2 6 2 2 6
48213 - 2 2 6 66 66 66 58 58 58 22 22 22
48214 - 6 6 6 0 0 0 0 0 0 0 0 0
48215 - 0 0 0 0 0 0 0 0 0 0 0 0
48216 - 0 0 0 0 0 0 0 0 0 0 0 0
48217 - 0 0 0 0 0 0 0 0 0 0 0 0
48218 - 0 0 0 0 0 0 0 0 0 0 0 0
48219 - 0 0 0 0 0 0 0 0 0 0 0 0
48220 - 0 0 0 0 0 0 0 0 0 10 10 10
48221 - 38 38 38 78 78 78 6 6 6 2 2 6
48222 - 2 2 6 46 46 46 14 14 14 42 42 42
48223 -246 246 246 253 253 253 253 253 253 253 253 253
48224 -253 253 253 253 253 253 253 253 253 253 253 253
48225 -253 253 253 253 253 253 231 231 231 242 242 242
48226 -253 253 253 253 253 253 253 253 253 253 253 253
48227 -253 253 253 253 253 253 253 253 253 253 253 253
48228 -253 253 253 253 253 253 253 253 253 253 253 253
48229 -253 253 253 253 253 253 253 253 253 253 253 253
48230 -253 253 253 253 253 253 234 234 234 10 10 10
48231 - 2 2 6 2 2 6 22 22 22 14 14 14
48232 - 2 2 6 2 2 6 2 2 6 2 2 6
48233 - 2 2 6 66 66 66 62 62 62 22 22 22
48234 - 6 6 6 0 0 0 0 0 0 0 0 0
48235 - 0 0 0 0 0 0 0 0 0 0 0 0
48236 - 0 0 0 0 0 0 0 0 0 0 0 0
48237 - 0 0 0 0 0 0 0 0 0 0 0 0
48238 - 0 0 0 0 0 0 0 0 0 0 0 0
48239 - 0 0 0 0 0 0 0 0 0 0 0 0
48240 - 0 0 0 0 0 0 6 6 6 18 18 18
48241 - 50 50 50 74 74 74 2 2 6 2 2 6
48242 - 14 14 14 70 70 70 34 34 34 62 62 62
48243 -250 250 250 253 253 253 253 253 253 253 253 253
48244 -253 253 253 253 253 253 253 253 253 253 253 253
48245 -253 253 253 253 253 253 231 231 231 246 246 246
48246 -253 253 253 253 253 253 253 253 253 253 253 253
48247 -253 253 253 253 253 253 253 253 253 253 253 253
48248 -253 253 253 253 253 253 253 253 253 253 253 253
48249 -253 253 253 253 253 253 253 253 253 253 253 253
48250 -253 253 253 253 253 253 234 234 234 14 14 14
48251 - 2 2 6 2 2 6 30 30 30 2 2 6
48252 - 2 2 6 2 2 6 2 2 6 2 2 6
48253 - 2 2 6 66 66 66 62 62 62 22 22 22
48254 - 6 6 6 0 0 0 0 0 0 0 0 0
48255 - 0 0 0 0 0 0 0 0 0 0 0 0
48256 - 0 0 0 0 0 0 0 0 0 0 0 0
48257 - 0 0 0 0 0 0 0 0 0 0 0 0
48258 - 0 0 0 0 0 0 0 0 0 0 0 0
48259 - 0 0 0 0 0 0 0 0 0 0 0 0
48260 - 0 0 0 0 0 0 6 6 6 18 18 18
48261 - 54 54 54 62 62 62 2 2 6 2 2 6
48262 - 2 2 6 30 30 30 46 46 46 70 70 70
48263 -250 250 250 253 253 253 253 253 253 253 253 253
48264 -253 253 253 253 253 253 253 253 253 253 253 253
48265 -253 253 253 253 253 253 231 231 231 246 246 246
48266 -253 253 253 253 253 253 253 253 253 253 253 253
48267 -253 253 253 253 253 253 253 253 253 253 253 253
48268 -253 253 253 253 253 253 253 253 253 253 253 253
48269 -253 253 253 253 253 253 253 253 253 253 253 253
48270 -253 253 253 253 253 253 226 226 226 10 10 10
48271 - 2 2 6 6 6 6 30 30 30 2 2 6
48272 - 2 2 6 2 2 6 2 2 6 2 2 6
48273 - 2 2 6 66 66 66 58 58 58 22 22 22
48274 - 6 6 6 0 0 0 0 0 0 0 0 0
48275 - 0 0 0 0 0 0 0 0 0 0 0 0
48276 - 0 0 0 0 0 0 0 0 0 0 0 0
48277 - 0 0 0 0 0 0 0 0 0 0 0 0
48278 - 0 0 0 0 0 0 0 0 0 0 0 0
48279 - 0 0 0 0 0 0 0 0 0 0 0 0
48280 - 0 0 0 0 0 0 6 6 6 22 22 22
48281 - 58 58 58 62 62 62 2 2 6 2 2 6
48282 - 2 2 6 2 2 6 30 30 30 78 78 78
48283 -250 250 250 253 253 253 253 253 253 253 253 253
48284 -253 253 253 253 253 253 253 253 253 253 253 253
48285 -253 253 253 253 253 253 231 231 231 246 246 246
48286 -253 253 253 253 253 253 253 253 253 253 253 253
48287 -253 253 253 253 253 253 253 253 253 253 253 253
48288 -253 253 253 253 253 253 253 253 253 253 253 253
48289 -253 253 253 253 253 253 253 253 253 253 253 253
48290 -253 253 253 253 253 253 206 206 206 2 2 6
48291 - 22 22 22 34 34 34 18 14 6 22 22 22
48292 - 26 26 26 18 18 18 6 6 6 2 2 6
48293 - 2 2 6 82 82 82 54 54 54 18 18 18
48294 - 6 6 6 0 0 0 0 0 0 0 0 0
48295 - 0 0 0 0 0 0 0 0 0 0 0 0
48296 - 0 0 0 0 0 0 0 0 0 0 0 0
48297 - 0 0 0 0 0 0 0 0 0 0 0 0
48298 - 0 0 0 0 0 0 0 0 0 0 0 0
48299 - 0 0 0 0 0 0 0 0 0 0 0 0
48300 - 0 0 0 0 0 0 6 6 6 26 26 26
48301 - 62 62 62 106 106 106 74 54 14 185 133 11
48302 -210 162 10 121 92 8 6 6 6 62 62 62
48303 -238 238 238 253 253 253 253 253 253 253 253 253
48304 -253 253 253 253 253 253 253 253 253 253 253 253
48305 -253 253 253 253 253 253 231 231 231 246 246 246
48306 -253 253 253 253 253 253 253 253 253 253 253 253
48307 -253 253 253 253 253 253 253 253 253 253 253 253
48308 -253 253 253 253 253 253 253 253 253 253 253 253
48309 -253 253 253 253 253 253 253 253 253 253 253 253
48310 -253 253 253 253 253 253 158 158 158 18 18 18
48311 - 14 14 14 2 2 6 2 2 6 2 2 6
48312 - 6 6 6 18 18 18 66 66 66 38 38 38
48313 - 6 6 6 94 94 94 50 50 50 18 18 18
48314 - 6 6 6 0 0 0 0 0 0 0 0 0
48315 - 0 0 0 0 0 0 0 0 0 0 0 0
48316 - 0 0 0 0 0 0 0 0 0 0 0 0
48317 - 0 0 0 0 0 0 0 0 0 0 0 0
48318 - 0 0 0 0 0 0 0 0 0 0 0 0
48319 - 0 0 0 0 0 0 0 0 0 6 6 6
48320 - 10 10 10 10 10 10 18 18 18 38 38 38
48321 - 78 78 78 142 134 106 216 158 10 242 186 14
48322 -246 190 14 246 190 14 156 118 10 10 10 10
48323 - 90 90 90 238 238 238 253 253 253 253 253 253
48324 -253 253 253 253 253 253 253 253 253 253 253 253
48325 -253 253 253 253 253 253 231 231 231 250 250 250
48326 -253 253 253 253 253 253 253 253 253 253 253 253
48327 -253 253 253 253 253 253 253 253 253 253 253 253
48328 -253 253 253 253 253 253 253 253 253 253 253 253
48329 -253 253 253 253 253 253 253 253 253 246 230 190
48330 -238 204 91 238 204 91 181 142 44 37 26 9
48331 - 2 2 6 2 2 6 2 2 6 2 2 6
48332 - 2 2 6 2 2 6 38 38 38 46 46 46
48333 - 26 26 26 106 106 106 54 54 54 18 18 18
48334 - 6 6 6 0 0 0 0 0 0 0 0 0
48335 - 0 0 0 0 0 0 0 0 0 0 0 0
48336 - 0 0 0 0 0 0 0 0 0 0 0 0
48337 - 0 0 0 0 0 0 0 0 0 0 0 0
48338 - 0 0 0 0 0 0 0 0 0 0 0 0
48339 - 0 0 0 6 6 6 14 14 14 22 22 22
48340 - 30 30 30 38 38 38 50 50 50 70 70 70
48341 -106 106 106 190 142 34 226 170 11 242 186 14
48342 -246 190 14 246 190 14 246 190 14 154 114 10
48343 - 6 6 6 74 74 74 226 226 226 253 253 253
48344 -253 253 253 253 253 253 253 253 253 253 253 253
48345 -253 253 253 253 253 253 231 231 231 250 250 250
48346 -253 253 253 253 253 253 253 253 253 253 253 253
48347 -253 253 253 253 253 253 253 253 253 253 253 253
48348 -253 253 253 253 253 253 253 253 253 253 253 253
48349 -253 253 253 253 253 253 253 253 253 228 184 62
48350 -241 196 14 241 208 19 232 195 16 38 30 10
48351 - 2 2 6 2 2 6 2 2 6 2 2 6
48352 - 2 2 6 6 6 6 30 30 30 26 26 26
48353 -203 166 17 154 142 90 66 66 66 26 26 26
48354 - 6 6 6 0 0 0 0 0 0 0 0 0
48355 - 0 0 0 0 0 0 0 0 0 0 0 0
48356 - 0 0 0 0 0 0 0 0 0 0 0 0
48357 - 0 0 0 0 0 0 0 0 0 0 0 0
48358 - 0 0 0 0 0 0 0 0 0 0 0 0
48359 - 6 6 6 18 18 18 38 38 38 58 58 58
48360 - 78 78 78 86 86 86 101 101 101 123 123 123
48361 -175 146 61 210 150 10 234 174 13 246 186 14
48362 -246 190 14 246 190 14 246 190 14 238 190 10
48363 -102 78 10 2 2 6 46 46 46 198 198 198
48364 -253 253 253 253 253 253 253 253 253 253 253 253
48365 -253 253 253 253 253 253 234 234 234 242 242 242
48366 -253 253 253 253 253 253 253 253 253 253 253 253
48367 -253 253 253 253 253 253 253 253 253 253 253 253
48368 -253 253 253 253 253 253 253 253 253 253 253 253
48369 -253 253 253 253 253 253 253 253 253 224 178 62
48370 -242 186 14 241 196 14 210 166 10 22 18 6
48371 - 2 2 6 2 2 6 2 2 6 2 2 6
48372 - 2 2 6 2 2 6 6 6 6 121 92 8
48373 -238 202 15 232 195 16 82 82 82 34 34 34
48374 - 10 10 10 0 0 0 0 0 0 0 0 0
48375 - 0 0 0 0 0 0 0 0 0 0 0 0
48376 - 0 0 0 0 0 0 0 0 0 0 0 0
48377 - 0 0 0 0 0 0 0 0 0 0 0 0
48378 - 0 0 0 0 0 0 0 0 0 0 0 0
48379 - 14 14 14 38 38 38 70 70 70 154 122 46
48380 -190 142 34 200 144 11 197 138 11 197 138 11
48381 -213 154 11 226 170 11 242 186 14 246 190 14
48382 -246 190 14 246 190 14 246 190 14 246 190 14
48383 -225 175 15 46 32 6 2 2 6 22 22 22
48384 -158 158 158 250 250 250 253 253 253 253 253 253
48385 -253 253 253 253 253 253 253 253 253 253 253 253
48386 -253 253 253 253 253 253 253 253 253 253 253 253
48387 -253 253 253 253 253 253 253 253 253 253 253 253
48388 -253 253 253 253 253 253 253 253 253 253 253 253
48389 -253 253 253 250 250 250 242 242 242 224 178 62
48390 -239 182 13 236 186 11 213 154 11 46 32 6
48391 - 2 2 6 2 2 6 2 2 6 2 2 6
48392 - 2 2 6 2 2 6 61 42 6 225 175 15
48393 -238 190 10 236 186 11 112 100 78 42 42 42
48394 - 14 14 14 0 0 0 0 0 0 0 0 0
48395 - 0 0 0 0 0 0 0 0 0 0 0 0
48396 - 0 0 0 0 0 0 0 0 0 0 0 0
48397 - 0 0 0 0 0 0 0 0 0 0 0 0
48398 - 0 0 0 0 0 0 0 0 0 6 6 6
48399 - 22 22 22 54 54 54 154 122 46 213 154 11
48400 -226 170 11 230 174 11 226 170 11 226 170 11
48401 -236 178 12 242 186 14 246 190 14 246 190 14
48402 -246 190 14 246 190 14 246 190 14 246 190 14
48403 -241 196 14 184 144 12 10 10 10 2 2 6
48404 - 6 6 6 116 116 116 242 242 242 253 253 253
48405 -253 253 253 253 253 253 253 253 253 253 253 253
48406 -253 253 253 253 253 253 253 253 253 253 253 253
48407 -253 253 253 253 253 253 253 253 253 253 253 253
48408 -253 253 253 253 253 253 253 253 253 253 253 253
48409 -253 253 253 231 231 231 198 198 198 214 170 54
48410 -236 178 12 236 178 12 210 150 10 137 92 6
48411 - 18 14 6 2 2 6 2 2 6 2 2 6
48412 - 6 6 6 70 47 6 200 144 11 236 178 12
48413 -239 182 13 239 182 13 124 112 88 58 58 58
48414 - 22 22 22 6 6 6 0 0 0 0 0 0
48415 - 0 0 0 0 0 0 0 0 0 0 0 0
48416 - 0 0 0 0 0 0 0 0 0 0 0 0
48417 - 0 0 0 0 0 0 0 0 0 0 0 0
48418 - 0 0 0 0 0 0 0 0 0 10 10 10
48419 - 30 30 30 70 70 70 180 133 36 226 170 11
48420 -239 182 13 242 186 14 242 186 14 246 186 14
48421 -246 190 14 246 190 14 246 190 14 246 190 14
48422 -246 190 14 246 190 14 246 190 14 246 190 14
48423 -246 190 14 232 195 16 98 70 6 2 2 6
48424 - 2 2 6 2 2 6 66 66 66 221 221 221
48425 -253 253 253 253 253 253 253 253 253 253 253 253
48426 -253 253 253 253 253 253 253 253 253 253 253 253
48427 -253 253 253 253 253 253 253 253 253 253 253 253
48428 -253 253 253 253 253 253 253 253 253 253 253 253
48429 -253 253 253 206 206 206 198 198 198 214 166 58
48430 -230 174 11 230 174 11 216 158 10 192 133 9
48431 -163 110 8 116 81 8 102 78 10 116 81 8
48432 -167 114 7 197 138 11 226 170 11 239 182 13
48433 -242 186 14 242 186 14 162 146 94 78 78 78
48434 - 34 34 34 14 14 14 6 6 6 0 0 0
48435 - 0 0 0 0 0 0 0 0 0 0 0 0
48436 - 0 0 0 0 0 0 0 0 0 0 0 0
48437 - 0 0 0 0 0 0 0 0 0 0 0 0
48438 - 0 0 0 0 0 0 0 0 0 6 6 6
48439 - 30 30 30 78 78 78 190 142 34 226 170 11
48440 -239 182 13 246 190 14 246 190 14 246 190 14
48441 -246 190 14 246 190 14 246 190 14 246 190 14
48442 -246 190 14 246 190 14 246 190 14 246 190 14
48443 -246 190 14 241 196 14 203 166 17 22 18 6
48444 - 2 2 6 2 2 6 2 2 6 38 38 38
48445 -218 218 218 253 253 253 253 253 253 253 253 253
48446 -253 253 253 253 253 253 253 253 253 253 253 253
48447 -253 253 253 253 253 253 253 253 253 253 253 253
48448 -253 253 253 253 253 253 253 253 253 253 253 253
48449 -250 250 250 206 206 206 198 198 198 202 162 69
48450 -226 170 11 236 178 12 224 166 10 210 150 10
48451 -200 144 11 197 138 11 192 133 9 197 138 11
48452 -210 150 10 226 170 11 242 186 14 246 190 14
48453 -246 190 14 246 186 14 225 175 15 124 112 88
48454 - 62 62 62 30 30 30 14 14 14 6 6 6
48455 - 0 0 0 0 0 0 0 0 0 0 0 0
48456 - 0 0 0 0 0 0 0 0 0 0 0 0
48457 - 0 0 0 0 0 0 0 0 0 0 0 0
48458 - 0 0 0 0 0 0 0 0 0 10 10 10
48459 - 30 30 30 78 78 78 174 135 50 224 166 10
48460 -239 182 13 246 190 14 246 190 14 246 190 14
48461 -246 190 14 246 190 14 246 190 14 246 190 14
48462 -246 190 14 246 190 14 246 190 14 246 190 14
48463 -246 190 14 246 190 14 241 196 14 139 102 15
48464 - 2 2 6 2 2 6 2 2 6 2 2 6
48465 - 78 78 78 250 250 250 253 253 253 253 253 253
48466 -253 253 253 253 253 253 253 253 253 253 253 253
48467 -253 253 253 253 253 253 253 253 253 253 253 253
48468 -253 253 253 253 253 253 253 253 253 253 253 253
48469 -250 250 250 214 214 214 198 198 198 190 150 46
48470 -219 162 10 236 178 12 234 174 13 224 166 10
48471 -216 158 10 213 154 11 213 154 11 216 158 10
48472 -226 170 11 239 182 13 246 190 14 246 190 14
48473 -246 190 14 246 190 14 242 186 14 206 162 42
48474 -101 101 101 58 58 58 30 30 30 14 14 14
48475 - 6 6 6 0 0 0 0 0 0 0 0 0
48476 - 0 0 0 0 0 0 0 0 0 0 0 0
48477 - 0 0 0 0 0 0 0 0 0 0 0 0
48478 - 0 0 0 0 0 0 0 0 0 10 10 10
48479 - 30 30 30 74 74 74 174 135 50 216 158 10
48480 -236 178 12 246 190 14 246 190 14 246 190 14
48481 -246 190 14 246 190 14 246 190 14 246 190 14
48482 -246 190 14 246 190 14 246 190 14 246 190 14
48483 -246 190 14 246 190 14 241 196 14 226 184 13
48484 - 61 42 6 2 2 6 2 2 6 2 2 6
48485 - 22 22 22 238 238 238 253 253 253 253 253 253
48486 -253 253 253 253 253 253 253 253 253 253 253 253
48487 -253 253 253 253 253 253 253 253 253 253 253 253
48488 -253 253 253 253 253 253 253 253 253 253 253 253
48489 -253 253 253 226 226 226 187 187 187 180 133 36
48490 -216 158 10 236 178 12 239 182 13 236 178 12
48491 -230 174 11 226 170 11 226 170 11 230 174 11
48492 -236 178 12 242 186 14 246 190 14 246 190 14
48493 -246 190 14 246 190 14 246 186 14 239 182 13
48494 -206 162 42 106 106 106 66 66 66 34 34 34
48495 - 14 14 14 6 6 6 0 0 0 0 0 0
48496 - 0 0 0 0 0 0 0 0 0 0 0 0
48497 - 0 0 0 0 0 0 0 0 0 0 0 0
48498 - 0 0 0 0 0 0 0 0 0 6 6 6
48499 - 26 26 26 70 70 70 163 133 67 213 154 11
48500 -236 178 12 246 190 14 246 190 14 246 190 14
48501 -246 190 14 246 190 14 246 190 14 246 190 14
48502 -246 190 14 246 190 14 246 190 14 246 190 14
48503 -246 190 14 246 190 14 246 190 14 241 196 14
48504 -190 146 13 18 14 6 2 2 6 2 2 6
48505 - 46 46 46 246 246 246 253 253 253 253 253 253
48506 -253 253 253 253 253 253 253 253 253 253 253 253
48507 -253 253 253 253 253 253 253 253 253 253 253 253
48508 -253 253 253 253 253 253 253 253 253 253 253 253
48509 -253 253 253 221 221 221 86 86 86 156 107 11
48510 -216 158 10 236 178 12 242 186 14 246 186 14
48511 -242 186 14 239 182 13 239 182 13 242 186 14
48512 -242 186 14 246 186 14 246 190 14 246 190 14
48513 -246 190 14 246 190 14 246 190 14 246 190 14
48514 -242 186 14 225 175 15 142 122 72 66 66 66
48515 - 30 30 30 10 10 10 0 0 0 0 0 0
48516 - 0 0 0 0 0 0 0 0 0 0 0 0
48517 - 0 0 0 0 0 0 0 0 0 0 0 0
48518 - 0 0 0 0 0 0 0 0 0 6 6 6
48519 - 26 26 26 70 70 70 163 133 67 210 150 10
48520 -236 178 12 246 190 14 246 190 14 246 190 14
48521 -246 190 14 246 190 14 246 190 14 246 190 14
48522 -246 190 14 246 190 14 246 190 14 246 190 14
48523 -246 190 14 246 190 14 246 190 14 246 190 14
48524 -232 195 16 121 92 8 34 34 34 106 106 106
48525 -221 221 221 253 253 253 253 253 253 253 253 253
48526 -253 253 253 253 253 253 253 253 253 253 253 253
48527 -253 253 253 253 253 253 253 253 253 253 253 253
48528 -253 253 253 253 253 253 253 253 253 253 253 253
48529 -242 242 242 82 82 82 18 14 6 163 110 8
48530 -216 158 10 236 178 12 242 186 14 246 190 14
48531 -246 190 14 246 190 14 246 190 14 246 190 14
48532 -246 190 14 246 190 14 246 190 14 246 190 14
48533 -246 190 14 246 190 14 246 190 14 246 190 14
48534 -246 190 14 246 190 14 242 186 14 163 133 67
48535 - 46 46 46 18 18 18 6 6 6 0 0 0
48536 - 0 0 0 0 0 0 0 0 0 0 0 0
48537 - 0 0 0 0 0 0 0 0 0 0 0 0
48538 - 0 0 0 0 0 0 0 0 0 10 10 10
48539 - 30 30 30 78 78 78 163 133 67 210 150 10
48540 -236 178 12 246 186 14 246 190 14 246 190 14
48541 -246 190 14 246 190 14 246 190 14 246 190 14
48542 -246 190 14 246 190 14 246 190 14 246 190 14
48543 -246 190 14 246 190 14 246 190 14 246 190 14
48544 -241 196 14 215 174 15 190 178 144 253 253 253
48545 -253 253 253 253 253 253 253 253 253 253 253 253
48546 -253 253 253 253 253 253 253 253 253 253 253 253
48547 -253 253 253 253 253 253 253 253 253 253 253 253
48548 -253 253 253 253 253 253 253 253 253 218 218 218
48549 - 58 58 58 2 2 6 22 18 6 167 114 7
48550 -216 158 10 236 178 12 246 186 14 246 190 14
48551 -246 190 14 246 190 14 246 190 14 246 190 14
48552 -246 190 14 246 190 14 246 190 14 246 190 14
48553 -246 190 14 246 190 14 246 190 14 246 190 14
48554 -246 190 14 246 186 14 242 186 14 190 150 46
48555 - 54 54 54 22 22 22 6 6 6 0 0 0
48556 - 0 0 0 0 0 0 0 0 0 0 0 0
48557 - 0 0 0 0 0 0 0 0 0 0 0 0
48558 - 0 0 0 0 0 0 0 0 0 14 14 14
48559 - 38 38 38 86 86 86 180 133 36 213 154 11
48560 -236 178 12 246 186 14 246 190 14 246 190 14
48561 -246 190 14 246 190 14 246 190 14 246 190 14
48562 -246 190 14 246 190 14 246 190 14 246 190 14
48563 -246 190 14 246 190 14 246 190 14 246 190 14
48564 -246 190 14 232 195 16 190 146 13 214 214 214
48565 -253 253 253 253 253 253 253 253 253 253 253 253
48566 -253 253 253 253 253 253 253 253 253 253 253 253
48567 -253 253 253 253 253 253 253 253 253 253 253 253
48568 -253 253 253 250 250 250 170 170 170 26 26 26
48569 - 2 2 6 2 2 6 37 26 9 163 110 8
48570 -219 162 10 239 182 13 246 186 14 246 190 14
48571 -246 190 14 246 190 14 246 190 14 246 190 14
48572 -246 190 14 246 190 14 246 190 14 246 190 14
48573 -246 190 14 246 190 14 246 190 14 246 190 14
48574 -246 186 14 236 178 12 224 166 10 142 122 72
48575 - 46 46 46 18 18 18 6 6 6 0 0 0
48576 - 0 0 0 0 0 0 0 0 0 0 0 0
48577 - 0 0 0 0 0 0 0 0 0 0 0 0
48578 - 0 0 0 0 0 0 6 6 6 18 18 18
48579 - 50 50 50 109 106 95 192 133 9 224 166 10
48580 -242 186 14 246 190 14 246 190 14 246 190 14
48581 -246 190 14 246 190 14 246 190 14 246 190 14
48582 -246 190 14 246 190 14 246 190 14 246 190 14
48583 -246 190 14 246 190 14 246 190 14 246 190 14
48584 -242 186 14 226 184 13 210 162 10 142 110 46
48585 -226 226 226 253 253 253 253 253 253 253 253 253
48586 -253 253 253 253 253 253 253 253 253 253 253 253
48587 -253 253 253 253 253 253 253 253 253 253 253 253
48588 -198 198 198 66 66 66 2 2 6 2 2 6
48589 - 2 2 6 2 2 6 50 34 6 156 107 11
48590 -219 162 10 239 182 13 246 186 14 246 190 14
48591 -246 190 14 246 190 14 246 190 14 246 190 14
48592 -246 190 14 246 190 14 246 190 14 246 190 14
48593 -246 190 14 246 190 14 246 190 14 242 186 14
48594 -234 174 13 213 154 11 154 122 46 66 66 66
48595 - 30 30 30 10 10 10 0 0 0 0 0 0
48596 - 0 0 0 0 0 0 0 0 0 0 0 0
48597 - 0 0 0 0 0 0 0 0 0 0 0 0
48598 - 0 0 0 0 0 0 6 6 6 22 22 22
48599 - 58 58 58 154 121 60 206 145 10 234 174 13
48600 -242 186 14 246 186 14 246 190 14 246 190 14
48601 -246 190 14 246 190 14 246 190 14 246 190 14
48602 -246 190 14 246 190 14 246 190 14 246 190 14
48603 -246 190 14 246 190 14 246 190 14 246 190 14
48604 -246 186 14 236 178 12 210 162 10 163 110 8
48605 - 61 42 6 138 138 138 218 218 218 250 250 250
48606 -253 253 253 253 253 253 253 253 253 250 250 250
48607 -242 242 242 210 210 210 144 144 144 66 66 66
48608 - 6 6 6 2 2 6 2 2 6 2 2 6
48609 - 2 2 6 2 2 6 61 42 6 163 110 8
48610 -216 158 10 236 178 12 246 190 14 246 190 14
48611 -246 190 14 246 190 14 246 190 14 246 190 14
48612 -246 190 14 246 190 14 246 190 14 246 190 14
48613 -246 190 14 239 182 13 230 174 11 216 158 10
48614 -190 142 34 124 112 88 70 70 70 38 38 38
48615 - 18 18 18 6 6 6 0 0 0 0 0 0
48616 - 0 0 0 0 0 0 0 0 0 0 0 0
48617 - 0 0 0 0 0 0 0 0 0 0 0 0
48618 - 0 0 0 0 0 0 6 6 6 22 22 22
48619 - 62 62 62 168 124 44 206 145 10 224 166 10
48620 -236 178 12 239 182 13 242 186 14 242 186 14
48621 -246 186 14 246 190 14 246 190 14 246 190 14
48622 -246 190 14 246 190 14 246 190 14 246 190 14
48623 -246 190 14 246 190 14 246 190 14 246 190 14
48624 -246 190 14 236 178 12 216 158 10 175 118 6
48625 - 80 54 7 2 2 6 6 6 6 30 30 30
48626 - 54 54 54 62 62 62 50 50 50 38 38 38
48627 - 14 14 14 2 2 6 2 2 6 2 2 6
48628 - 2 2 6 2 2 6 2 2 6 2 2 6
48629 - 2 2 6 6 6 6 80 54 7 167 114 7
48630 -213 154 11 236 178 12 246 190 14 246 190 14
48631 -246 190 14 246 190 14 246 190 14 246 190 14
48632 -246 190 14 242 186 14 239 182 13 239 182 13
48633 -230 174 11 210 150 10 174 135 50 124 112 88
48634 - 82 82 82 54 54 54 34 34 34 18 18 18
48635 - 6 6 6 0 0 0 0 0 0 0 0 0
48636 - 0 0 0 0 0 0 0 0 0 0 0 0
48637 - 0 0 0 0 0 0 0 0 0 0 0 0
48638 - 0 0 0 0 0 0 6 6 6 18 18 18
48639 - 50 50 50 158 118 36 192 133 9 200 144 11
48640 -216 158 10 219 162 10 224 166 10 226 170 11
48641 -230 174 11 236 178 12 239 182 13 239 182 13
48642 -242 186 14 246 186 14 246 190 14 246 190 14
48643 -246 190 14 246 190 14 246 190 14 246 190 14
48644 -246 186 14 230 174 11 210 150 10 163 110 8
48645 -104 69 6 10 10 10 2 2 6 2 2 6
48646 - 2 2 6 2 2 6 2 2 6 2 2 6
48647 - 2 2 6 2 2 6 2 2 6 2 2 6
48648 - 2 2 6 2 2 6 2 2 6 2 2 6
48649 - 2 2 6 6 6 6 91 60 6 167 114 7
48650 -206 145 10 230 174 11 242 186 14 246 190 14
48651 -246 190 14 246 190 14 246 186 14 242 186 14
48652 -239 182 13 230 174 11 224 166 10 213 154 11
48653 -180 133 36 124 112 88 86 86 86 58 58 58
48654 - 38 38 38 22 22 22 10 10 10 6 6 6
48655 - 0 0 0 0 0 0 0 0 0 0 0 0
48656 - 0 0 0 0 0 0 0 0 0 0 0 0
48657 - 0 0 0 0 0 0 0 0 0 0 0 0
48658 - 0 0 0 0 0 0 0 0 0 14 14 14
48659 - 34 34 34 70 70 70 138 110 50 158 118 36
48660 -167 114 7 180 123 7 192 133 9 197 138 11
48661 -200 144 11 206 145 10 213 154 11 219 162 10
48662 -224 166 10 230 174 11 239 182 13 242 186 14
48663 -246 186 14 246 186 14 246 186 14 246 186 14
48664 -239 182 13 216 158 10 185 133 11 152 99 6
48665 -104 69 6 18 14 6 2 2 6 2 2 6
48666 - 2 2 6 2 2 6 2 2 6 2 2 6
48667 - 2 2 6 2 2 6 2 2 6 2 2 6
48668 - 2 2 6 2 2 6 2 2 6 2 2 6
48669 - 2 2 6 6 6 6 80 54 7 152 99 6
48670 -192 133 9 219 162 10 236 178 12 239 182 13
48671 -246 186 14 242 186 14 239 182 13 236 178 12
48672 -224 166 10 206 145 10 192 133 9 154 121 60
48673 - 94 94 94 62 62 62 42 42 42 22 22 22
48674 - 14 14 14 6 6 6 0 0 0 0 0 0
48675 - 0 0 0 0 0 0 0 0 0 0 0 0
48676 - 0 0 0 0 0 0 0 0 0 0 0 0
48677 - 0 0 0 0 0 0 0 0 0 0 0 0
48678 - 0 0 0 0 0 0 0 0 0 6 6 6
48679 - 18 18 18 34 34 34 58 58 58 78 78 78
48680 -101 98 89 124 112 88 142 110 46 156 107 11
48681 -163 110 8 167 114 7 175 118 6 180 123 7
48682 -185 133 11 197 138 11 210 150 10 219 162 10
48683 -226 170 11 236 178 12 236 178 12 234 174 13
48684 -219 162 10 197 138 11 163 110 8 130 83 6
48685 - 91 60 6 10 10 10 2 2 6 2 2 6
48686 - 18 18 18 38 38 38 38 38 38 38 38 38
48687 - 38 38 38 38 38 38 38 38 38 38 38 38
48688 - 38 38 38 38 38 38 26 26 26 2 2 6
48689 - 2 2 6 6 6 6 70 47 6 137 92 6
48690 -175 118 6 200 144 11 219 162 10 230 174 11
48691 -234 174 13 230 174 11 219 162 10 210 150 10
48692 -192 133 9 163 110 8 124 112 88 82 82 82
48693 - 50 50 50 30 30 30 14 14 14 6 6 6
48694 - 0 0 0 0 0 0 0 0 0 0 0 0
48695 - 0 0 0 0 0 0 0 0 0 0 0 0
48696 - 0 0 0 0 0 0 0 0 0 0 0 0
48697 - 0 0 0 0 0 0 0 0 0 0 0 0
48698 - 0 0 0 0 0 0 0 0 0 0 0 0
48699 - 6 6 6 14 14 14 22 22 22 34 34 34
48700 - 42 42 42 58 58 58 74 74 74 86 86 86
48701 -101 98 89 122 102 70 130 98 46 121 87 25
48702 -137 92 6 152 99 6 163 110 8 180 123 7
48703 -185 133 11 197 138 11 206 145 10 200 144 11
48704 -180 123 7 156 107 11 130 83 6 104 69 6
48705 - 50 34 6 54 54 54 110 110 110 101 98 89
48706 - 86 86 86 82 82 82 78 78 78 78 78 78
48707 - 78 78 78 78 78 78 78 78 78 78 78 78
48708 - 78 78 78 82 82 82 86 86 86 94 94 94
48709 -106 106 106 101 101 101 86 66 34 124 80 6
48710 -156 107 11 180 123 7 192 133 9 200 144 11
48711 -206 145 10 200 144 11 192 133 9 175 118 6
48712 -139 102 15 109 106 95 70 70 70 42 42 42
48713 - 22 22 22 10 10 10 0 0 0 0 0 0
48714 - 0 0 0 0 0 0 0 0 0 0 0 0
48715 - 0 0 0 0 0 0 0 0 0 0 0 0
48716 - 0 0 0 0 0 0 0 0 0 0 0 0
48717 - 0 0 0 0 0 0 0 0 0 0 0 0
48718 - 0 0 0 0 0 0 0 0 0 0 0 0
48719 - 0 0 0 0 0 0 6 6 6 10 10 10
48720 - 14 14 14 22 22 22 30 30 30 38 38 38
48721 - 50 50 50 62 62 62 74 74 74 90 90 90
48722 -101 98 89 112 100 78 121 87 25 124 80 6
48723 -137 92 6 152 99 6 152 99 6 152 99 6
48724 -138 86 6 124 80 6 98 70 6 86 66 30
48725 -101 98 89 82 82 82 58 58 58 46 46 46
48726 - 38 38 38 34 34 34 34 34 34 34 34 34
48727 - 34 34 34 34 34 34 34 34 34 34 34 34
48728 - 34 34 34 34 34 34 38 38 38 42 42 42
48729 - 54 54 54 82 82 82 94 86 76 91 60 6
48730 -134 86 6 156 107 11 167 114 7 175 118 6
48731 -175 118 6 167 114 7 152 99 6 121 87 25
48732 -101 98 89 62 62 62 34 34 34 18 18 18
48733 - 6 6 6 0 0 0 0 0 0 0 0 0
48734 - 0 0 0 0 0 0 0 0 0 0 0 0
48735 - 0 0 0 0 0 0 0 0 0 0 0 0
48736 - 0 0 0 0 0 0 0 0 0 0 0 0
48737 - 0 0 0 0 0 0 0 0 0 0 0 0
48738 - 0 0 0 0 0 0 0 0 0 0 0 0
48739 - 0 0 0 0 0 0 0 0 0 0 0 0
48740 - 0 0 0 6 6 6 6 6 6 10 10 10
48741 - 18 18 18 22 22 22 30 30 30 42 42 42
48742 - 50 50 50 66 66 66 86 86 86 101 98 89
48743 -106 86 58 98 70 6 104 69 6 104 69 6
48744 -104 69 6 91 60 6 82 62 34 90 90 90
48745 - 62 62 62 38 38 38 22 22 22 14 14 14
48746 - 10 10 10 10 10 10 10 10 10 10 10 10
48747 - 10 10 10 10 10 10 6 6 6 10 10 10
48748 - 10 10 10 10 10 10 10 10 10 14 14 14
48749 - 22 22 22 42 42 42 70 70 70 89 81 66
48750 - 80 54 7 104 69 6 124 80 6 137 92 6
48751 -134 86 6 116 81 8 100 82 52 86 86 86
48752 - 58 58 58 30 30 30 14 14 14 6 6 6
48753 - 0 0 0 0 0 0 0 0 0 0 0 0
48754 - 0 0 0 0 0 0 0 0 0 0 0 0
48755 - 0 0 0 0 0 0 0 0 0 0 0 0
48756 - 0 0 0 0 0 0 0 0 0 0 0 0
48757 - 0 0 0 0 0 0 0 0 0 0 0 0
48758 - 0 0 0 0 0 0 0 0 0 0 0 0
48759 - 0 0 0 0 0 0 0 0 0 0 0 0
48760 - 0 0 0 0 0 0 0 0 0 0 0 0
48761 - 0 0 0 6 6 6 10 10 10 14 14 14
48762 - 18 18 18 26 26 26 38 38 38 54 54 54
48763 - 70 70 70 86 86 86 94 86 76 89 81 66
48764 - 89 81 66 86 86 86 74 74 74 50 50 50
48765 - 30 30 30 14 14 14 6 6 6 0 0 0
48766 - 0 0 0 0 0 0 0 0 0 0 0 0
48767 - 0 0 0 0 0 0 0 0 0 0 0 0
48768 - 0 0 0 0 0 0 0 0 0 0 0 0
48769 - 6 6 6 18 18 18 34 34 34 58 58 58
48770 - 82 82 82 89 81 66 89 81 66 89 81 66
48771 - 94 86 66 94 86 76 74 74 74 50 50 50
48772 - 26 26 26 14 14 14 6 6 6 0 0 0
48773 - 0 0 0 0 0 0 0 0 0 0 0 0
48774 - 0 0 0 0 0 0 0 0 0 0 0 0
48775 - 0 0 0 0 0 0 0 0 0 0 0 0
48776 - 0 0 0 0 0 0 0 0 0 0 0 0
48777 - 0 0 0 0 0 0 0 0 0 0 0 0
48778 - 0 0 0 0 0 0 0 0 0 0 0 0
48779 - 0 0 0 0 0 0 0 0 0 0 0 0
48780 - 0 0 0 0 0 0 0 0 0 0 0 0
48781 - 0 0 0 0 0 0 0 0 0 0 0 0
48782 - 6 6 6 6 6 6 14 14 14 18 18 18
48783 - 30 30 30 38 38 38 46 46 46 54 54 54
48784 - 50 50 50 42 42 42 30 30 30 18 18 18
48785 - 10 10 10 0 0 0 0 0 0 0 0 0
48786 - 0 0 0 0 0 0 0 0 0 0 0 0
48787 - 0 0 0 0 0 0 0 0 0 0 0 0
48788 - 0 0 0 0 0 0 0 0 0 0 0 0
48789 - 0 0 0 6 6 6 14 14 14 26 26 26
48790 - 38 38 38 50 50 50 58 58 58 58 58 58
48791 - 54 54 54 42 42 42 30 30 30 18 18 18
48792 - 10 10 10 0 0 0 0 0 0 0 0 0
48793 - 0 0 0 0 0 0 0 0 0 0 0 0
48794 - 0 0 0 0 0 0 0 0 0 0 0 0
48795 - 0 0 0 0 0 0 0 0 0 0 0 0
48796 - 0 0 0 0 0 0 0 0 0 0 0 0
48797 - 0 0 0 0 0 0 0 0 0 0 0 0
48798 - 0 0 0 0 0 0 0 0 0 0 0 0
48799 - 0 0 0 0 0 0 0 0 0 0 0 0
48800 - 0 0 0 0 0 0 0 0 0 0 0 0
48801 - 0 0 0 0 0 0 0 0 0 0 0 0
48802 - 0 0 0 0 0 0 0 0 0 6 6 6
48803 - 6 6 6 10 10 10 14 14 14 18 18 18
48804 - 18 18 18 14 14 14 10 10 10 6 6 6
48805 - 0 0 0 0 0 0 0 0 0 0 0 0
48806 - 0 0 0 0 0 0 0 0 0 0 0 0
48807 - 0 0 0 0 0 0 0 0 0 0 0 0
48808 - 0 0 0 0 0 0 0 0 0 0 0 0
48809 - 0 0 0 0 0 0 0 0 0 6 6 6
48810 - 14 14 14 18 18 18 22 22 22 22 22 22
48811 - 18 18 18 14 14 14 10 10 10 6 6 6
48812 - 0 0 0 0 0 0 0 0 0 0 0 0
48813 - 0 0 0 0 0 0 0 0 0 0 0 0
48814 - 0 0 0 0 0 0 0 0 0 0 0 0
48815 - 0 0 0 0 0 0 0 0 0 0 0 0
48816 - 0 0 0 0 0 0 0 0 0 0 0 0
48817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48828 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48830 +4 4 4 4 4 4
48831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48844 +4 4 4 4 4 4
48845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48858 +4 4 4 4 4 4
48859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48872 +4 4 4 4 4 4
48873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48886 +4 4 4 4 4 4
48887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48896 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48898 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48900 +4 4 4 4 4 4
48901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48905 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
48906 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
48907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48910 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
48911 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
48912 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
48913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48914 +4 4 4 4 4 4
48915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48919 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
48920 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
48921 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48924 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
48925 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
48926 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
48927 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48928 +4 4 4 4 4 4
48929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48933 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
48934 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
48935 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
48936 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48937 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48938 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
48939 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
48940 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
48941 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
48942 +4 4 4 4 4 4
48943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48946 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
48947 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
48948 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
48949 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
48950 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48951 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
48952 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
48953 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
48954 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
48955 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
48956 +4 4 4 4 4 4
48957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48960 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
48961 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
48962 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
48963 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
48964 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
48965 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
48966 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
48967 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
48968 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
48969 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
48970 +4 4 4 4 4 4
48971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
48974 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
48975 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
48976 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
48977 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
48978 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
48979 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
48980 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
48981 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
48982 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
48983 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
48984 +4 4 4 4 4 4
48985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48987 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
48988 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
48989 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
48990 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
48991 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
48992 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
48993 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
48994 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
48995 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
48996 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
48997 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
48998 +4 4 4 4 4 4
48999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49001 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
49002 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
49003 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
49004 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
49005 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
49006 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
49007 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
49008 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
49009 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
49010 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
49011 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
49012 +4 4 4 4 4 4
49013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49015 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
49016 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
49017 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
49018 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
49019 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
49020 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
49021 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
49022 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
49023 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
49024 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
49025 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
49026 +4 4 4 4 4 4
49027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49029 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
49030 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
49031 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
49032 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
49033 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
49034 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
49035 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
49036 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
49037 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
49038 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
49039 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
49040 +4 4 4 4 4 4
49041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49042 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
49043 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
49044 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
49045 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
49046 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
49047 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
49048 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
49049 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
49050 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
49051 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
49052 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
49053 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
49054 +4 4 4 4 4 4
49055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49056 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
49057 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
49058 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
49059 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
49060 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
49061 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
49062 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
49063 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
49064 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
49065 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
49066 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
49067 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
49068 +0 0 0 4 4 4
49069 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
49070 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
49071 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
49072 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
49073 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
49074 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
49075 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
49076 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
49077 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
49078 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
49079 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
49080 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
49081 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
49082 +2 0 0 0 0 0
49083 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
49084 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
49085 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
49086 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
49087 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
49088 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
49089 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
49090 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
49091 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
49092 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
49093 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
49094 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
49095 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
49096 +37 38 37 0 0 0
49097 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
49098 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
49099 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
49100 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
49101 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
49102 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
49103 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
49104 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
49105 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
49106 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
49107 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
49108 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
49109 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
49110 +85 115 134 4 0 0
49111 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
49112 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
49113 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
49114 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
49115 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
49116 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
49117 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
49118 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
49119 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
49120 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
49121 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
49122 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
49123 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
49124 +60 73 81 4 0 0
49125 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
49126 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
49127 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
49128 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
49129 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
49130 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
49131 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
49132 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
49133 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
49134 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
49135 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
49136 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
49137 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
49138 +16 19 21 4 0 0
49139 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
49140 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
49141 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
49142 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
49143 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
49144 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
49145 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
49146 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
49147 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
49148 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
49149 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
49150 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
49151 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
49152 +4 0 0 4 3 3
49153 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
49154 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
49155 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
49156 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
49157 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
49158 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
49159 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
49160 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
49161 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
49162 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
49163 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
49164 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
49165 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
49166 +3 2 2 4 4 4
49167 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
49168 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
49169 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
49170 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
49171 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
49172 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
49173 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49174 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
49175 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
49176 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
49177 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
49178 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
49179 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
49180 +4 4 4 4 4 4
49181 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
49182 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
49183 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
49184 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
49185 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
49186 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
49187 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
49188 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
49189 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
49190 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
49191 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
49192 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
49193 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
49194 +4 4 4 4 4 4
49195 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
49196 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
49197 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
49198 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
49199 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
49200 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
49201 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
49202 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
49203 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
49204 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
49205 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
49206 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
49207 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
49208 +5 5 5 5 5 5
49209 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
49210 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
49211 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
49212 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
49213 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
49214 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
49215 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
49216 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
49217 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
49218 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
49219 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
49220 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
49221 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
49222 +5 5 5 4 4 4
49223 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
49224 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
49225 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
49226 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
49227 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
49228 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
49229 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
49230 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
49231 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
49232 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
49233 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
49234 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
49235 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49236 +4 4 4 4 4 4
49237 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
49238 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
49239 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
49240 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
49241 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
49242 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
49243 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
49244 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
49245 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
49246 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
49247 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
49248 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
49249 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49250 +4 4 4 4 4 4
49251 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
49252 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
49253 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
49254 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
49255 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
49256 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
49257 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
49258 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
49259 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
49260 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
49261 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
49262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49264 +4 4 4 4 4 4
49265 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
49266 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
49267 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
49268 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
49269 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
49270 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
49271 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
49272 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
49273 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
49274 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
49275 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
49276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49277 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49278 +4 4 4 4 4 4
49279 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
49280 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
49281 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
49282 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
49283 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
49284 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
49285 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
49286 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
49287 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
49288 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
49289 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49291 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49292 +4 4 4 4 4 4
49293 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
49294 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
49295 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
49296 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
49297 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
49298 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
49299 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
49300 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
49301 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
49302 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
49303 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
49304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49305 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49306 +4 4 4 4 4 4
49307 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
49308 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
49309 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
49310 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
49311 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
49312 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
49313 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
49314 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
49315 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
49316 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
49317 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
49318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49319 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49320 +4 4 4 4 4 4
49321 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
49322 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
49323 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
49324 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
49325 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
49326 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
49327 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
49328 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
49329 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
49330 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
49331 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49333 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49334 +4 4 4 4 4 4
49335 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
49336 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
49337 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
49338 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
49339 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49340 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
49341 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
49342 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
49343 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
49344 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
49345 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49348 +4 4 4 4 4 4
49349 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
49350 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
49351 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
49352 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
49353 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49354 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
49355 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
49356 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
49357 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
49358 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
49359 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49362 +4 4 4 4 4 4
49363 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
49364 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
49365 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
49366 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
49367 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49368 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
49369 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
49370 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
49371 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
49372 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49373 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49376 +4 4 4 4 4 4
49377 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
49378 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
49379 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
49380 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
49381 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
49382 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
49383 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
49384 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
49385 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
49386 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49387 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49390 +4 4 4 4 4 4
49391 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
49392 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
49393 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
49394 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
49395 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49396 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
49397 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
49398 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
49399 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
49400 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49401 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49404 +4 4 4 4 4 4
49405 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
49406 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
49407 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
49408 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
49409 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
49410 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
49411 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
49412 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
49413 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
49414 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49415 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49418 +4 4 4 4 4 4
49419 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
49420 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
49421 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
49422 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
49423 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
49424 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
49425 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
49426 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
49427 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
49428 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49429 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49432 +4 4 4 4 4 4
49433 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
49434 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
49435 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
49436 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
49437 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
49438 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
49439 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
49440 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
49441 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
49442 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49443 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49446 +4 4 4 4 4 4
49447 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
49448 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
49449 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
49450 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
49451 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
49452 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
49453 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
49454 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
49455 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
49456 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49457 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49460 +4 4 4 4 4 4
49461 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
49462 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
49463 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
49464 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
49465 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
49466 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
49467 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
49468 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
49469 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
49470 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49471 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49474 +4 4 4 4 4 4
49475 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
49476 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
49477 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
49478 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
49479 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
49480 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
49481 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
49482 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
49483 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
49484 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49485 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49487 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49488 +4 4 4 4 4 4
49489 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
49490 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
49491 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
49492 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
49493 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
49494 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
49495 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49496 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
49497 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
49498 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49499 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49501 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49502 +4 4 4 4 4 4
49503 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
49504 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
49505 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
49506 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
49507 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
49508 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
49509 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49510 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
49511 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
49512 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49513 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49515 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49516 +4 4 4 4 4 4
49517 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
49518 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
49519 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
49520 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
49521 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
49522 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
49523 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
49524 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
49525 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
49526 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49527 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49529 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49530 +4 4 4 4 4 4
49531 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
49532 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
49533 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
49534 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
49535 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
49536 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
49537 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
49538 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
49539 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
49540 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49541 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49544 +4 4 4 4 4 4
49545 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
49546 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
49547 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
49548 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
49549 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
49550 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
49551 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
49552 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
49553 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
49554 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49555 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49558 +4 4 4 4 4 4
49559 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
49560 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
49561 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
49562 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
49563 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
49564 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
49565 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
49566 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
49567 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
49568 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49569 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49572 +4 4 4 4 4 4
49573 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
49574 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
49575 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
49576 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
49577 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
49578 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
49579 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
49580 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
49581 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
49582 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
49583 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49586 +4 4 4 4 4 4
49587 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
49588 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
49589 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
49590 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
49591 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
49592 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
49593 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
49594 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
49595 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
49596 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
49597 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49600 +4 4 4 4 4 4
49601 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
49602 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
49603 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
49604 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
49605 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
49606 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
49607 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49608 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
49609 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
49610 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
49611 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
49612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49613 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49614 +4 4 4 4 4 4
49615 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
49616 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
49617 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
49618 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
49619 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
49620 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
49621 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
49622 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
49623 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
49624 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
49625 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49628 +4 4 4 4 4 4
49629 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
49630 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
49631 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
49632 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
49633 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
49634 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
49635 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
49636 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
49637 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
49638 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
49639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49641 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49642 +4 4 4 4 4 4
49643 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
49644 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
49645 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
49646 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
49647 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
49648 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
49649 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
49650 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
49651 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
49652 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
49653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49656 +4 4 4 4 4 4
49657 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
49658 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
49659 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
49660 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
49661 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
49662 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
49663 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
49664 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
49665 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
49666 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
49667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49670 +4 4 4 4 4 4
49671 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
49672 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
49673 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
49674 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
49675 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
49676 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
49677 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
49678 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
49679 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
49680 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
49681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49684 +4 4 4 4 4 4
49685 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
49686 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
49687 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
49688 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
49689 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
49690 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
49691 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
49692 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
49693 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
49694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49698 +4 4 4 4 4 4
49699 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
49700 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
49701 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
49702 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
49703 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
49704 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
49705 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
49706 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
49707 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
49708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49712 +4 4 4 4 4 4
49713 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
49714 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
49715 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
49716 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
49717 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
49718 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
49719 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
49720 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
49721 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49726 +4 4 4 4 4 4
49727 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
49728 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
49729 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
49730 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
49731 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
49732 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
49733 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
49734 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
49735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49740 +4 4 4 4 4 4
49741 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
49742 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
49743 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
49744 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
49745 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
49746 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
49747 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
49748 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
49749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49754 +4 4 4 4 4 4
49755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
49756 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
49757 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
49758 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
49759 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
49760 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
49761 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
49762 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
49763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49768 +4 4 4 4 4 4
49769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49770 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
49771 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
49772 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
49773 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
49774 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
49775 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
49776 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
49777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49782 +4 4 4 4 4 4
49783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49784 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
49785 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
49786 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
49787 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
49788 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
49789 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
49790 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
49791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49796 +4 4 4 4 4 4
49797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49799 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
49800 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
49801 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
49802 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
49803 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
49804 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
49805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49810 +4 4 4 4 4 4
49811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
49814 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
49815 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
49816 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
49817 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
49818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49824 +4 4 4 4 4 4
49825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49828 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
49829 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
49830 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
49831 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
49832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49838 +4 4 4 4 4 4
49839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49842 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
49843 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
49844 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
49845 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
49846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49852 +4 4 4 4 4 4
49853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49856 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
49857 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
49858 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
49859 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
49860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49866 +4 4 4 4 4 4
49867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
49871 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
49872 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
49873 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49880 +4 4 4 4 4 4
49881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49885 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
49886 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
49887 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
49888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49894 +4 4 4 4 4 4
49895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49896 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49898 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49899 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
49900 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
49901 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49908 +4 4 4 4 4 4
49909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49912 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49913 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
49914 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
49915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49922 +4 4 4 4 4 4
49923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49926 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49927 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
49928 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
49929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49936 +4 4 4 4 4 4
49937 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
49938 index fe92eed..106e085 100644
49939 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
49940 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
49941 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
49942 struct mb862xxfb_par *par = info->par;
49943
49944 if (info->var.bits_per_pixel == 32) {
49945 - info->fbops->fb_fillrect = cfb_fillrect;
49946 - info->fbops->fb_copyarea = cfb_copyarea;
49947 - info->fbops->fb_imageblit = cfb_imageblit;
49948 + pax_open_kernel();
49949 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
49950 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
49951 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
49952 + pax_close_kernel();
49953 } else {
49954 outreg(disp, GC_L0EM, 3);
49955 - info->fbops->fb_fillrect = mb86290fb_fillrect;
49956 - info->fbops->fb_copyarea = mb86290fb_copyarea;
49957 - info->fbops->fb_imageblit = mb86290fb_imageblit;
49958 + pax_open_kernel();
49959 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
49960 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
49961 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
49962 + pax_close_kernel();
49963 }
49964 outreg(draw, GDC_REG_DRAW_BASE, 0);
49965 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
49966 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
49967 index ff22871..b129bed 100644
49968 --- a/drivers/video/nvidia/nvidia.c
49969 +++ b/drivers/video/nvidia/nvidia.c
49970 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
49971 info->fix.line_length = (info->var.xres_virtual *
49972 info->var.bits_per_pixel) >> 3;
49973 if (info->var.accel_flags) {
49974 - info->fbops->fb_imageblit = nvidiafb_imageblit;
49975 - info->fbops->fb_fillrect = nvidiafb_fillrect;
49976 - info->fbops->fb_copyarea = nvidiafb_copyarea;
49977 - info->fbops->fb_sync = nvidiafb_sync;
49978 + pax_open_kernel();
49979 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
49980 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
49981 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
49982 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
49983 + pax_close_kernel();
49984 info->pixmap.scan_align = 4;
49985 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49986 info->flags |= FBINFO_READS_FAST;
49987 NVResetGraphics(info);
49988 } else {
49989 - info->fbops->fb_imageblit = cfb_imageblit;
49990 - info->fbops->fb_fillrect = cfb_fillrect;
49991 - info->fbops->fb_copyarea = cfb_copyarea;
49992 - info->fbops->fb_sync = NULL;
49993 + pax_open_kernel();
49994 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
49995 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
49996 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
49997 + *(void **)&info->fbops->fb_sync = NULL;
49998 + pax_close_kernel();
49999 info->pixmap.scan_align = 1;
50000 info->flags |= FBINFO_HWACCEL_DISABLED;
50001 info->flags &= ~FBINFO_READS_FAST;
50002 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
50003 info->pixmap.size = 8 * 1024;
50004 info->pixmap.flags = FB_PIXMAP_SYSTEM;
50005
50006 - if (!hwcur)
50007 - info->fbops->fb_cursor = NULL;
50008 + if (!hwcur) {
50009 + pax_open_kernel();
50010 + *(void **)&info->fbops->fb_cursor = NULL;
50011 + pax_close_kernel();
50012 + }
50013
50014 info->var.accel_flags = (!noaccel);
50015
50016 diff --git a/drivers/video/output.c b/drivers/video/output.c
50017 index 0d6f2cd..6285b97 100644
50018 --- a/drivers/video/output.c
50019 +++ b/drivers/video/output.c
50020 @@ -97,7 +97,7 @@ struct output_device *video_output_register(const char *name,
50021 new_dev->props = op;
50022 new_dev->dev.class = &video_output_class;
50023 new_dev->dev.parent = dev;
50024 - dev_set_name(&new_dev->dev, name);
50025 + dev_set_name(&new_dev->dev, "%s", name);
50026 dev_set_drvdata(&new_dev->dev, devdata);
50027 ret_code = device_register(&new_dev->dev);
50028 if (ret_code) {
50029 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
50030 index 05c2dc3..ea1f391 100644
50031 --- a/drivers/video/s1d13xxxfb.c
50032 +++ b/drivers/video/s1d13xxxfb.c
50033 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
50034
50035 switch(prod_id) {
50036 case S1D13506_PROD_ID: /* activate acceleration */
50037 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
50038 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
50039 + pax_open_kernel();
50040 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
50041 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
50042 + pax_close_kernel();
50043 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
50044 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
50045 break;
50046 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
50047 index b2b33fc..f9f4658 100644
50048 --- a/drivers/video/smscufx.c
50049 +++ b/drivers/video/smscufx.c
50050 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
50051 fb_deferred_io_cleanup(info);
50052 kfree(info->fbdefio);
50053 info->fbdefio = NULL;
50054 - info->fbops->fb_mmap = ufx_ops_mmap;
50055 + pax_open_kernel();
50056 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
50057 + pax_close_kernel();
50058 }
50059
50060 pr_debug("released /dev/fb%d user=%d count=%d",
50061 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
50062 index ec03e72..f578436 100644
50063 --- a/drivers/video/udlfb.c
50064 +++ b/drivers/video/udlfb.c
50065 @@ -623,11 +623,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
50066 dlfb_urb_completion(urb);
50067
50068 error:
50069 - atomic_add(bytes_sent, &dev->bytes_sent);
50070 - atomic_add(bytes_identical, &dev->bytes_identical);
50071 - atomic_add(width*height*2, &dev->bytes_rendered);
50072 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
50073 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
50074 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
50075 end_cycles = get_cycles();
50076 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
50077 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
50078 >> 10)), /* Kcycles */
50079 &dev->cpu_kcycles_used);
50080
50081 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
50082 dlfb_urb_completion(urb);
50083
50084 error:
50085 - atomic_add(bytes_sent, &dev->bytes_sent);
50086 - atomic_add(bytes_identical, &dev->bytes_identical);
50087 - atomic_add(bytes_rendered, &dev->bytes_rendered);
50088 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
50089 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
50090 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
50091 end_cycles = get_cycles();
50092 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
50093 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
50094 >> 10)), /* Kcycles */
50095 &dev->cpu_kcycles_used);
50096 }
50097 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
50098 fb_deferred_io_cleanup(info);
50099 kfree(info->fbdefio);
50100 info->fbdefio = NULL;
50101 - info->fbops->fb_mmap = dlfb_ops_mmap;
50102 + pax_open_kernel();
50103 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
50104 + pax_close_kernel();
50105 }
50106
50107 pr_warn("released /dev/fb%d user=%d count=%d\n",
50108 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
50109 struct fb_info *fb_info = dev_get_drvdata(fbdev);
50110 struct dlfb_data *dev = fb_info->par;
50111 return snprintf(buf, PAGE_SIZE, "%u\n",
50112 - atomic_read(&dev->bytes_rendered));
50113 + atomic_read_unchecked(&dev->bytes_rendered));
50114 }
50115
50116 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
50117 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
50118 struct fb_info *fb_info = dev_get_drvdata(fbdev);
50119 struct dlfb_data *dev = fb_info->par;
50120 return snprintf(buf, PAGE_SIZE, "%u\n",
50121 - atomic_read(&dev->bytes_identical));
50122 + atomic_read_unchecked(&dev->bytes_identical));
50123 }
50124
50125 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
50126 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
50127 struct fb_info *fb_info = dev_get_drvdata(fbdev);
50128 struct dlfb_data *dev = fb_info->par;
50129 return snprintf(buf, PAGE_SIZE, "%u\n",
50130 - atomic_read(&dev->bytes_sent));
50131 + atomic_read_unchecked(&dev->bytes_sent));
50132 }
50133
50134 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
50135 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
50136 struct fb_info *fb_info = dev_get_drvdata(fbdev);
50137 struct dlfb_data *dev = fb_info->par;
50138 return snprintf(buf, PAGE_SIZE, "%u\n",
50139 - atomic_read(&dev->cpu_kcycles_used));
50140 + atomic_read_unchecked(&dev->cpu_kcycles_used));
50141 }
50142
50143 static ssize_t edid_show(
50144 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
50145 struct fb_info *fb_info = dev_get_drvdata(fbdev);
50146 struct dlfb_data *dev = fb_info->par;
50147
50148 - atomic_set(&dev->bytes_rendered, 0);
50149 - atomic_set(&dev->bytes_identical, 0);
50150 - atomic_set(&dev->bytes_sent, 0);
50151 - atomic_set(&dev->cpu_kcycles_used, 0);
50152 + atomic_set_unchecked(&dev->bytes_rendered, 0);
50153 + atomic_set_unchecked(&dev->bytes_identical, 0);
50154 + atomic_set_unchecked(&dev->bytes_sent, 0);
50155 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
50156
50157 return count;
50158 }
50159 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
50160 index e328a61..1b08ecb 100644
50161 --- a/drivers/video/uvesafb.c
50162 +++ b/drivers/video/uvesafb.c
50163 @@ -19,6 +19,7 @@
50164 #include <linux/io.h>
50165 #include <linux/mutex.h>
50166 #include <linux/slab.h>
50167 +#include <linux/moduleloader.h>
50168 #include <video/edid.h>
50169 #include <video/uvesafb.h>
50170 #ifdef CONFIG_X86
50171 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
50172 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
50173 par->pmi_setpal = par->ypan = 0;
50174 } else {
50175 +
50176 +#ifdef CONFIG_PAX_KERNEXEC
50177 +#ifdef CONFIG_MODULES
50178 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
50179 +#endif
50180 + if (!par->pmi_code) {
50181 + par->pmi_setpal = par->ypan = 0;
50182 + return 0;
50183 + }
50184 +#endif
50185 +
50186 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
50187 + task->t.regs.edi);
50188 +
50189 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50190 + pax_open_kernel();
50191 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
50192 + pax_close_kernel();
50193 +
50194 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
50195 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
50196 +#else
50197 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
50198 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
50199 +#endif
50200 +
50201 printk(KERN_INFO "uvesafb: protected mode interface info at "
50202 "%04x:%04x\n",
50203 (u16)task->t.regs.es, (u16)task->t.regs.edi);
50204 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
50205 par->ypan = ypan;
50206
50207 if (par->pmi_setpal || par->ypan) {
50208 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
50209 if (__supported_pte_mask & _PAGE_NX) {
50210 par->pmi_setpal = par->ypan = 0;
50211 printk(KERN_WARNING "uvesafb: NX protection is actively."
50212 "We have better not to use the PMI.\n");
50213 - } else {
50214 + } else
50215 +#endif
50216 uvesafb_vbe_getpmi(task, par);
50217 - }
50218 }
50219 #else
50220 /* The protected mode interface is not available on non-x86. */
50221 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
50222 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
50223
50224 /* Disable blanking if the user requested so. */
50225 - if (!blank)
50226 - info->fbops->fb_blank = NULL;
50227 + if (!blank) {
50228 + pax_open_kernel();
50229 + *(void **)&info->fbops->fb_blank = NULL;
50230 + pax_close_kernel();
50231 + }
50232
50233 /*
50234 * Find out how much IO memory is required for the mode with
50235 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
50236 info->flags = FBINFO_FLAG_DEFAULT |
50237 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
50238
50239 - if (!par->ypan)
50240 - info->fbops->fb_pan_display = NULL;
50241 + if (!par->ypan) {
50242 + pax_open_kernel();
50243 + *(void **)&info->fbops->fb_pan_display = NULL;
50244 + pax_close_kernel();
50245 + }
50246 }
50247
50248 static void uvesafb_init_mtrr(struct fb_info *info)
50249 @@ -1836,6 +1866,11 @@ out:
50250 if (par->vbe_modes)
50251 kfree(par->vbe_modes);
50252
50253 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50254 + if (par->pmi_code)
50255 + module_free_exec(NULL, par->pmi_code);
50256 +#endif
50257 +
50258 framebuffer_release(info);
50259 return err;
50260 }
50261 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
50262 kfree(par->vbe_state_orig);
50263 if (par->vbe_state_saved)
50264 kfree(par->vbe_state_saved);
50265 +
50266 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50267 + if (par->pmi_code)
50268 + module_free_exec(NULL, par->pmi_code);
50269 +#endif
50270 +
50271 }
50272
50273 framebuffer_release(info);
50274 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
50275 index 501b340..d80aa17 100644
50276 --- a/drivers/video/vesafb.c
50277 +++ b/drivers/video/vesafb.c
50278 @@ -9,6 +9,7 @@
50279 */
50280
50281 #include <linux/module.h>
50282 +#include <linux/moduleloader.h>
50283 #include <linux/kernel.h>
50284 #include <linux/errno.h>
50285 #include <linux/string.h>
50286 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
50287 static int vram_total __initdata; /* Set total amount of memory */
50288 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
50289 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
50290 -static void (*pmi_start)(void) __read_mostly;
50291 -static void (*pmi_pal) (void) __read_mostly;
50292 +static void (*pmi_start)(void) __read_only;
50293 +static void (*pmi_pal) (void) __read_only;
50294 static int depth __read_mostly;
50295 static int vga_compat __read_mostly;
50296 /* --------------------------------------------------------------------- */
50297 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
50298 unsigned int size_vmode;
50299 unsigned int size_remap;
50300 unsigned int size_total;
50301 + void *pmi_code = NULL;
50302
50303 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
50304 return -ENODEV;
50305 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
50306 size_remap = size_total;
50307 vesafb_fix.smem_len = size_remap;
50308
50309 -#ifndef __i386__
50310 - screen_info.vesapm_seg = 0;
50311 -#endif
50312 -
50313 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
50314 printk(KERN_WARNING
50315 "vesafb: cannot reserve video memory at 0x%lx\n",
50316 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
50317 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
50318 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
50319
50320 +#ifdef __i386__
50321 +
50322 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50323 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
50324 + if (!pmi_code)
50325 +#elif !defined(CONFIG_PAX_KERNEXEC)
50326 + if (0)
50327 +#endif
50328 +
50329 +#endif
50330 + screen_info.vesapm_seg = 0;
50331 +
50332 if (screen_info.vesapm_seg) {
50333 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
50334 - screen_info.vesapm_seg,screen_info.vesapm_off);
50335 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
50336 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
50337 }
50338
50339 if (screen_info.vesapm_seg < 0xc000)
50340 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
50341
50342 if (ypan || pmi_setpal) {
50343 unsigned short *pmi_base;
50344 +
50345 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
50346 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
50347 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
50348 +
50349 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50350 + pax_open_kernel();
50351 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
50352 +#else
50353 + pmi_code = pmi_base;
50354 +#endif
50355 +
50356 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
50357 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
50358 +
50359 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50360 + pmi_start = ktva_ktla(pmi_start);
50361 + pmi_pal = ktva_ktla(pmi_pal);
50362 + pax_close_kernel();
50363 +#endif
50364 +
50365 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
50366 if (pmi_base[3]) {
50367 printk(KERN_INFO "vesafb: pmi: ports = ");
50368 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
50369 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
50370 (ypan ? FBINFO_HWACCEL_YPAN : 0);
50371
50372 - if (!ypan)
50373 - info->fbops->fb_pan_display = NULL;
50374 + if (!ypan) {
50375 + pax_open_kernel();
50376 + *(void **)&info->fbops->fb_pan_display = NULL;
50377 + pax_close_kernel();
50378 + }
50379
50380 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
50381 err = -ENOMEM;
50382 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
50383 info->node, info->fix.id);
50384 return 0;
50385 err:
50386 +
50387 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50388 + module_free_exec(NULL, pmi_code);
50389 +#endif
50390 +
50391 if (info->screen_base)
50392 iounmap(info->screen_base);
50393 framebuffer_release(info);
50394 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
50395 index 88714ae..16c2e11 100644
50396 --- a/drivers/video/via/via_clock.h
50397 +++ b/drivers/video/via/via_clock.h
50398 @@ -56,7 +56,7 @@ struct via_clock {
50399
50400 void (*set_engine_pll_state)(u8 state);
50401 void (*set_engine_pll)(struct via_pll_config config);
50402 -};
50403 +} __no_const;
50404
50405
50406 static inline u32 get_pll_internal_frequency(u32 ref_freq,
50407 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
50408 index fef20db..d28b1ab 100644
50409 --- a/drivers/xen/xenfs/xenstored.c
50410 +++ b/drivers/xen/xenfs/xenstored.c
50411 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
50412 static int xsd_kva_open(struct inode *inode, struct file *file)
50413 {
50414 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
50415 +#ifdef CONFIG_GRKERNSEC_HIDESYM
50416 + NULL);
50417 +#else
50418 xen_store_interface);
50419 +#endif
50420 +
50421 if (!file->private_data)
50422 return -ENOMEM;
50423 return 0;
50424 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
50425 index 055562c..fdfb10d 100644
50426 --- a/fs/9p/vfs_addr.c
50427 +++ b/fs/9p/vfs_addr.c
50428 @@ -186,7 +186,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
50429
50430 retval = v9fs_file_write_internal(inode,
50431 v9inode->writeback_fid,
50432 - (__force const char __user *)buffer,
50433 + (const char __force_user *)buffer,
50434 len, &offset, 0);
50435 if (retval > 0)
50436 retval = 0;
50437 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
50438 index d86edc8..40ff2fb 100644
50439 --- a/fs/9p/vfs_inode.c
50440 +++ b/fs/9p/vfs_inode.c
50441 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
50442 void
50443 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
50444 {
50445 - char *s = nd_get_link(nd);
50446 + const char *s = nd_get_link(nd);
50447
50448 p9_debug(P9_DEBUG_VFS, " %s %s\n",
50449 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
50450 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
50451 index 370b24c..ff0be7b 100644
50452 --- a/fs/Kconfig.binfmt
50453 +++ b/fs/Kconfig.binfmt
50454 @@ -103,7 +103,7 @@ config HAVE_AOUT
50455
50456 config BINFMT_AOUT
50457 tristate "Kernel support for a.out and ECOFF binaries"
50458 - depends on HAVE_AOUT
50459 + depends on HAVE_AOUT && BROKEN
50460 ---help---
50461 A.out (Assembler.OUTput) is a set of formats for libraries and
50462 executables used in the earliest versions of UNIX. Linux used
50463 diff --git a/fs/aio.c b/fs/aio.c
50464 index 2bbcacf..8614116 100644
50465 --- a/fs/aio.c
50466 +++ b/fs/aio.c
50467 @@ -160,7 +160,7 @@ static int aio_setup_ring(struct kioctx *ctx)
50468 size += sizeof(struct io_event) * nr_events;
50469 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
50470
50471 - if (nr_pages < 0)
50472 + if (nr_pages <= 0)
50473 return -EINVAL;
50474
50475 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
50476 @@ -950,6 +950,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
50477 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
50478 {
50479 ssize_t ret;
50480 + struct iovec iovstack;
50481
50482 kiocb->ki_nr_segs = kiocb->ki_nbytes;
50483
50484 @@ -957,17 +958,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
50485 if (compat)
50486 ret = compat_rw_copy_check_uvector(rw,
50487 (struct compat_iovec __user *)kiocb->ki_buf,
50488 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
50489 + kiocb->ki_nr_segs, 1, &iovstack,
50490 &kiocb->ki_iovec);
50491 else
50492 #endif
50493 ret = rw_copy_check_uvector(rw,
50494 (struct iovec __user *)kiocb->ki_buf,
50495 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
50496 + kiocb->ki_nr_segs, 1, &iovstack,
50497 &kiocb->ki_iovec);
50498 if (ret < 0)
50499 return ret;
50500
50501 + if (kiocb->ki_iovec == &iovstack) {
50502 + kiocb->ki_inline_vec = iovstack;
50503 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
50504 + }
50505 +
50506 /* ki_nbytes now reflect bytes instead of segs */
50507 kiocb->ki_nbytes = ret;
50508 return 0;
50509 diff --git a/fs/attr.c b/fs/attr.c
50510 index 1449adb..a2038c2 100644
50511 --- a/fs/attr.c
50512 +++ b/fs/attr.c
50513 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
50514 unsigned long limit;
50515
50516 limit = rlimit(RLIMIT_FSIZE);
50517 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
50518 if (limit != RLIM_INFINITY && offset > limit)
50519 goto out_sig;
50520 if (offset > inode->i_sb->s_maxbytes)
50521 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
50522 index 3db70da..7aeec5b 100644
50523 --- a/fs/autofs4/waitq.c
50524 +++ b/fs/autofs4/waitq.c
50525 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
50526 {
50527 unsigned long sigpipe, flags;
50528 mm_segment_t fs;
50529 - const char *data = (const char *)addr;
50530 + const char __user *data = (const char __force_user *)addr;
50531 ssize_t wr = 0;
50532
50533 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
50534 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
50535 return 1;
50536 }
50537
50538 +#ifdef CONFIG_GRKERNSEC_HIDESYM
50539 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
50540 +#endif
50541 +
50542 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
50543 enum autofs_notify notify)
50544 {
50545 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
50546
50547 /* If this is a direct mount request create a dummy name */
50548 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
50549 +#ifdef CONFIG_GRKERNSEC_HIDESYM
50550 + /* this name does get written to userland via autofs4_write() */
50551 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
50552 +#else
50553 qstr.len = sprintf(name, "%p", dentry);
50554 +#endif
50555 else {
50556 qstr.len = autofs4_getpath(sbi, dentry, &name);
50557 if (!qstr.len) {
50558 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
50559 index 2722387..c8dd2a7 100644
50560 --- a/fs/befs/endian.h
50561 +++ b/fs/befs/endian.h
50562 @@ -11,7 +11,7 @@
50563
50564 #include <asm/byteorder.h>
50565
50566 -static inline u64
50567 +static inline u64 __intentional_overflow(-1)
50568 fs64_to_cpu(const struct super_block *sb, fs64 n)
50569 {
50570 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
50571 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
50572 return (__force fs64)cpu_to_be64(n);
50573 }
50574
50575 -static inline u32
50576 +static inline u32 __intentional_overflow(-1)
50577 fs32_to_cpu(const struct super_block *sb, fs32 n)
50578 {
50579 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
50580 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
50581 index f95dddc..b1e2c1c 100644
50582 --- a/fs/befs/linuxvfs.c
50583 +++ b/fs/befs/linuxvfs.c
50584 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
50585 {
50586 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
50587 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
50588 - char *link = nd_get_link(nd);
50589 + const char *link = nd_get_link(nd);
50590 if (!IS_ERR(link))
50591 kfree(link);
50592 }
50593 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
50594 index bce8769..7fc7544 100644
50595 --- a/fs/binfmt_aout.c
50596 +++ b/fs/binfmt_aout.c
50597 @@ -16,6 +16,7 @@
50598 #include <linux/string.h>
50599 #include <linux/fs.h>
50600 #include <linux/file.h>
50601 +#include <linux/security.h>
50602 #include <linux/stat.h>
50603 #include <linux/fcntl.h>
50604 #include <linux/ptrace.h>
50605 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
50606 #endif
50607 # define START_STACK(u) ((void __user *)u.start_stack)
50608
50609 + memset(&dump, 0, sizeof(dump));
50610 +
50611 fs = get_fs();
50612 set_fs(KERNEL_DS);
50613 has_dumped = 1;
50614 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
50615
50616 /* If the size of the dump file exceeds the rlimit, then see what would happen
50617 if we wrote the stack, but not the data area. */
50618 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
50619 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
50620 dump.u_dsize = 0;
50621
50622 /* Make sure we have enough room to write the stack and data areas. */
50623 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
50624 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
50625 dump.u_ssize = 0;
50626
50627 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
50628 rlim = rlimit(RLIMIT_DATA);
50629 if (rlim >= RLIM_INFINITY)
50630 rlim = ~0;
50631 +
50632 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
50633 if (ex.a_data + ex.a_bss > rlim)
50634 return -ENOMEM;
50635
50636 @@ -267,6 +274,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
50637
50638 install_exec_creds(bprm);
50639
50640 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
50641 + current->mm->pax_flags = 0UL;
50642 +#endif
50643 +
50644 +#ifdef CONFIG_PAX_PAGEEXEC
50645 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
50646 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
50647 +
50648 +#ifdef CONFIG_PAX_EMUTRAMP
50649 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
50650 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
50651 +#endif
50652 +
50653 +#ifdef CONFIG_PAX_MPROTECT
50654 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
50655 + current->mm->pax_flags |= MF_PAX_MPROTECT;
50656 +#endif
50657 +
50658 + }
50659 +#endif
50660 +
50661 if (N_MAGIC(ex) == OMAGIC) {
50662 unsigned long text_addr, map_size;
50663 loff_t pos;
50664 @@ -324,7 +352,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
50665 }
50666
50667 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
50668 - PROT_READ | PROT_WRITE | PROT_EXEC,
50669 + PROT_READ | PROT_WRITE,
50670 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
50671 fd_offset + ex.a_text);
50672 if (error != N_DATADDR(ex)) {
50673 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
50674 index f8a0b0e..6f036ed 100644
50675 --- a/fs/binfmt_elf.c
50676 +++ b/fs/binfmt_elf.c
50677 @@ -34,6 +34,7 @@
50678 #include <linux/utsname.h>
50679 #include <linux/coredump.h>
50680 #include <linux/sched.h>
50681 +#include <linux/xattr.h>
50682 #include <asm/uaccess.h>
50683 #include <asm/param.h>
50684 #include <asm/page.h>
50685 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
50686 #define elf_core_dump NULL
50687 #endif
50688
50689 +#ifdef CONFIG_PAX_MPROTECT
50690 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
50691 +#endif
50692 +
50693 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
50694 +static void elf_handle_mmap(struct file *file);
50695 +#endif
50696 +
50697 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
50698 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
50699 #else
50700 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
50701 .load_binary = load_elf_binary,
50702 .load_shlib = load_elf_library,
50703 .core_dump = elf_core_dump,
50704 +
50705 +#ifdef CONFIG_PAX_MPROTECT
50706 + .handle_mprotect= elf_handle_mprotect,
50707 +#endif
50708 +
50709 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
50710 + .handle_mmap = elf_handle_mmap,
50711 +#endif
50712 +
50713 .min_coredump = ELF_EXEC_PAGESIZE,
50714 };
50715
50716 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
50717
50718 static int set_brk(unsigned long start, unsigned long end)
50719 {
50720 + unsigned long e = end;
50721 +
50722 start = ELF_PAGEALIGN(start);
50723 end = ELF_PAGEALIGN(end);
50724 if (end > start) {
50725 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
50726 if (BAD_ADDR(addr))
50727 return addr;
50728 }
50729 - current->mm->start_brk = current->mm->brk = end;
50730 + current->mm->start_brk = current->mm->brk = e;
50731 return 0;
50732 }
50733
50734 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
50735 elf_addr_t __user *u_rand_bytes;
50736 const char *k_platform = ELF_PLATFORM;
50737 const char *k_base_platform = ELF_BASE_PLATFORM;
50738 - unsigned char k_rand_bytes[16];
50739 + u32 k_rand_bytes[4];
50740 int items;
50741 elf_addr_t *elf_info;
50742 int ei_index = 0;
50743 const struct cred *cred = current_cred();
50744 struct vm_area_struct *vma;
50745 + unsigned long saved_auxv[AT_VECTOR_SIZE];
50746
50747 /*
50748 * In some cases (e.g. Hyper-Threading), we want to avoid L1
50749 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
50750 * Generate 16 random bytes for userspace PRNG seeding.
50751 */
50752 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
50753 - u_rand_bytes = (elf_addr_t __user *)
50754 - STACK_ALLOC(p, sizeof(k_rand_bytes));
50755 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
50756 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
50757 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
50758 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
50759 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
50760 + u_rand_bytes = (elf_addr_t __user *) p;
50761 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
50762 return -EFAULT;
50763
50764 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
50765 return -EFAULT;
50766 current->mm->env_end = p;
50767
50768 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
50769 +
50770 /* Put the elf_info on the stack in the right place. */
50771 sp = (elf_addr_t __user *)envp + 1;
50772 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
50773 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
50774 return -EFAULT;
50775 return 0;
50776 }
50777 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
50778 an ELF header */
50779
50780 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
50781 - struct file *interpreter, unsigned long *interp_map_addr,
50782 - unsigned long no_base)
50783 + struct file *interpreter, unsigned long no_base)
50784 {
50785 struct elf_phdr *elf_phdata;
50786 struct elf_phdr *eppnt;
50787 - unsigned long load_addr = 0;
50788 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
50789 int load_addr_set = 0;
50790 unsigned long last_bss = 0, elf_bss = 0;
50791 - unsigned long error = ~0UL;
50792 + unsigned long error = -EINVAL;
50793 unsigned long total_size;
50794 int retval, i, size;
50795
50796 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
50797 goto out_close;
50798 }
50799
50800 +#ifdef CONFIG_PAX_SEGMEXEC
50801 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
50802 + pax_task_size = SEGMEXEC_TASK_SIZE;
50803 +#endif
50804 +
50805 eppnt = elf_phdata;
50806 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
50807 if (eppnt->p_type == PT_LOAD) {
50808 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
50809 map_addr = elf_map(interpreter, load_addr + vaddr,
50810 eppnt, elf_prot, elf_type, total_size);
50811 total_size = 0;
50812 - if (!*interp_map_addr)
50813 - *interp_map_addr = map_addr;
50814 error = map_addr;
50815 if (BAD_ADDR(map_addr))
50816 goto out_close;
50817 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
50818 k = load_addr + eppnt->p_vaddr;
50819 if (BAD_ADDR(k) ||
50820 eppnt->p_filesz > eppnt->p_memsz ||
50821 - eppnt->p_memsz > TASK_SIZE ||
50822 - TASK_SIZE - eppnt->p_memsz < k) {
50823 + eppnt->p_memsz > pax_task_size ||
50824 + pax_task_size - eppnt->p_memsz < k) {
50825 error = -ENOMEM;
50826 goto out_close;
50827 }
50828 @@ -538,6 +567,315 @@ out:
50829 return error;
50830 }
50831
50832 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
50833 +#ifdef CONFIG_PAX_SOFTMODE
50834 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
50835 +{
50836 + unsigned long pax_flags = 0UL;
50837 +
50838 +#ifdef CONFIG_PAX_PAGEEXEC
50839 + if (elf_phdata->p_flags & PF_PAGEEXEC)
50840 + pax_flags |= MF_PAX_PAGEEXEC;
50841 +#endif
50842 +
50843 +#ifdef CONFIG_PAX_SEGMEXEC
50844 + if (elf_phdata->p_flags & PF_SEGMEXEC)
50845 + pax_flags |= MF_PAX_SEGMEXEC;
50846 +#endif
50847 +
50848 +#ifdef CONFIG_PAX_EMUTRAMP
50849 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
50850 + pax_flags |= MF_PAX_EMUTRAMP;
50851 +#endif
50852 +
50853 +#ifdef CONFIG_PAX_MPROTECT
50854 + if (elf_phdata->p_flags & PF_MPROTECT)
50855 + pax_flags |= MF_PAX_MPROTECT;
50856 +#endif
50857 +
50858 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
50859 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
50860 + pax_flags |= MF_PAX_RANDMMAP;
50861 +#endif
50862 +
50863 + return pax_flags;
50864 +}
50865 +#endif
50866 +
50867 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
50868 +{
50869 + unsigned long pax_flags = 0UL;
50870 +
50871 +#ifdef CONFIG_PAX_PAGEEXEC
50872 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
50873 + pax_flags |= MF_PAX_PAGEEXEC;
50874 +#endif
50875 +
50876 +#ifdef CONFIG_PAX_SEGMEXEC
50877 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
50878 + pax_flags |= MF_PAX_SEGMEXEC;
50879 +#endif
50880 +
50881 +#ifdef CONFIG_PAX_EMUTRAMP
50882 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
50883 + pax_flags |= MF_PAX_EMUTRAMP;
50884 +#endif
50885 +
50886 +#ifdef CONFIG_PAX_MPROTECT
50887 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
50888 + pax_flags |= MF_PAX_MPROTECT;
50889 +#endif
50890 +
50891 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
50892 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
50893 + pax_flags |= MF_PAX_RANDMMAP;
50894 +#endif
50895 +
50896 + return pax_flags;
50897 +}
50898 +#endif
50899 +
50900 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
50901 +#ifdef CONFIG_PAX_SOFTMODE
50902 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
50903 +{
50904 + unsigned long pax_flags = 0UL;
50905 +
50906 +#ifdef CONFIG_PAX_PAGEEXEC
50907 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
50908 + pax_flags |= MF_PAX_PAGEEXEC;
50909 +#endif
50910 +
50911 +#ifdef CONFIG_PAX_SEGMEXEC
50912 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
50913 + pax_flags |= MF_PAX_SEGMEXEC;
50914 +#endif
50915 +
50916 +#ifdef CONFIG_PAX_EMUTRAMP
50917 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
50918 + pax_flags |= MF_PAX_EMUTRAMP;
50919 +#endif
50920 +
50921 +#ifdef CONFIG_PAX_MPROTECT
50922 + if (pax_flags_softmode & MF_PAX_MPROTECT)
50923 + pax_flags |= MF_PAX_MPROTECT;
50924 +#endif
50925 +
50926 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
50927 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
50928 + pax_flags |= MF_PAX_RANDMMAP;
50929 +#endif
50930 +
50931 + return pax_flags;
50932 +}
50933 +#endif
50934 +
50935 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
50936 +{
50937 + unsigned long pax_flags = 0UL;
50938 +
50939 +#ifdef CONFIG_PAX_PAGEEXEC
50940 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
50941 + pax_flags |= MF_PAX_PAGEEXEC;
50942 +#endif
50943 +
50944 +#ifdef CONFIG_PAX_SEGMEXEC
50945 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
50946 + pax_flags |= MF_PAX_SEGMEXEC;
50947 +#endif
50948 +
50949 +#ifdef CONFIG_PAX_EMUTRAMP
50950 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
50951 + pax_flags |= MF_PAX_EMUTRAMP;
50952 +#endif
50953 +
50954 +#ifdef CONFIG_PAX_MPROTECT
50955 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
50956 + pax_flags |= MF_PAX_MPROTECT;
50957 +#endif
50958 +
50959 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
50960 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
50961 + pax_flags |= MF_PAX_RANDMMAP;
50962 +#endif
50963 +
50964 + return pax_flags;
50965 +}
50966 +#endif
50967 +
50968 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
50969 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
50970 +{
50971 + unsigned long pax_flags = 0UL;
50972 +
50973 +#ifdef CONFIG_PAX_EI_PAX
50974 +
50975 +#ifdef CONFIG_PAX_PAGEEXEC
50976 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
50977 + pax_flags |= MF_PAX_PAGEEXEC;
50978 +#endif
50979 +
50980 +#ifdef CONFIG_PAX_SEGMEXEC
50981 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
50982 + pax_flags |= MF_PAX_SEGMEXEC;
50983 +#endif
50984 +
50985 +#ifdef CONFIG_PAX_EMUTRAMP
50986 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
50987 + pax_flags |= MF_PAX_EMUTRAMP;
50988 +#endif
50989 +
50990 +#ifdef CONFIG_PAX_MPROTECT
50991 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
50992 + pax_flags |= MF_PAX_MPROTECT;
50993 +#endif
50994 +
50995 +#ifdef CONFIG_PAX_ASLR
50996 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
50997 + pax_flags |= MF_PAX_RANDMMAP;
50998 +#endif
50999 +
51000 +#else
51001 +
51002 +#ifdef CONFIG_PAX_PAGEEXEC
51003 + pax_flags |= MF_PAX_PAGEEXEC;
51004 +#endif
51005 +
51006 +#ifdef CONFIG_PAX_SEGMEXEC
51007 + pax_flags |= MF_PAX_SEGMEXEC;
51008 +#endif
51009 +
51010 +#ifdef CONFIG_PAX_MPROTECT
51011 + pax_flags |= MF_PAX_MPROTECT;
51012 +#endif
51013 +
51014 +#ifdef CONFIG_PAX_RANDMMAP
51015 + if (randomize_va_space)
51016 + pax_flags |= MF_PAX_RANDMMAP;
51017 +#endif
51018 +
51019 +#endif
51020 +
51021 + return pax_flags;
51022 +}
51023 +
51024 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
51025 +{
51026 +
51027 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
51028 + unsigned long i;
51029 +
51030 + for (i = 0UL; i < elf_ex->e_phnum; i++)
51031 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
51032 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
51033 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
51034 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
51035 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
51036 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
51037 + return ~0UL;
51038 +
51039 +#ifdef CONFIG_PAX_SOFTMODE
51040 + if (pax_softmode)
51041 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
51042 + else
51043 +#endif
51044 +
51045 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
51046 + break;
51047 + }
51048 +#endif
51049 +
51050 + return ~0UL;
51051 +}
51052 +
51053 +static unsigned long pax_parse_xattr_pax(struct file * const file)
51054 +{
51055 +
51056 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
51057 + ssize_t xattr_size, i;
51058 + unsigned char xattr_value[sizeof("pemrs") - 1];
51059 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
51060 +
51061 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
51062 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
51063 + return ~0UL;
51064 +
51065 + for (i = 0; i < xattr_size; i++)
51066 + switch (xattr_value[i]) {
51067 + default:
51068 + return ~0UL;
51069 +
51070 +#define parse_flag(option1, option2, flag) \
51071 + case option1: \
51072 + if (pax_flags_hardmode & MF_PAX_##flag) \
51073 + return ~0UL; \
51074 + pax_flags_hardmode |= MF_PAX_##flag; \
51075 + break; \
51076 + case option2: \
51077 + if (pax_flags_softmode & MF_PAX_##flag) \
51078 + return ~0UL; \
51079 + pax_flags_softmode |= MF_PAX_##flag; \
51080 + break;
51081 +
51082 + parse_flag('p', 'P', PAGEEXEC);
51083 + parse_flag('e', 'E', EMUTRAMP);
51084 + parse_flag('m', 'M', MPROTECT);
51085 + parse_flag('r', 'R', RANDMMAP);
51086 + parse_flag('s', 'S', SEGMEXEC);
51087 +
51088 +#undef parse_flag
51089 + }
51090 +
51091 + if (pax_flags_hardmode & pax_flags_softmode)
51092 + return ~0UL;
51093 +
51094 +#ifdef CONFIG_PAX_SOFTMODE
51095 + if (pax_softmode)
51096 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
51097 + else
51098 +#endif
51099 +
51100 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
51101 +#else
51102 + return ~0UL;
51103 +#endif
51104 +
51105 +}
51106 +
51107 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
51108 +{
51109 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
51110 +
51111 + pax_flags = pax_parse_ei_pax(elf_ex);
51112 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
51113 + xattr_pax_flags = pax_parse_xattr_pax(file);
51114 +
51115 + if (pt_pax_flags == ~0UL)
51116 + pt_pax_flags = xattr_pax_flags;
51117 + else if (xattr_pax_flags == ~0UL)
51118 + xattr_pax_flags = pt_pax_flags;
51119 + if (pt_pax_flags != xattr_pax_flags)
51120 + return -EINVAL;
51121 + if (pt_pax_flags != ~0UL)
51122 + pax_flags = pt_pax_flags;
51123 +
51124 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
51125 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51126 + if ((__supported_pte_mask & _PAGE_NX))
51127 + pax_flags &= ~MF_PAX_SEGMEXEC;
51128 + else
51129 + pax_flags &= ~MF_PAX_PAGEEXEC;
51130 + }
51131 +#endif
51132 +
51133 + if (0 > pax_check_flags(&pax_flags))
51134 + return -EINVAL;
51135 +
51136 + current->mm->pax_flags = pax_flags;
51137 + return 0;
51138 +}
51139 +#endif
51140 +
51141 /*
51142 * These are the functions used to load ELF style executables and shared
51143 * libraries. There is no binary dependent code anywhere else.
51144 @@ -554,6 +892,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
51145 {
51146 unsigned int random_variable = 0;
51147
51148 +#ifdef CONFIG_PAX_RANDUSTACK
51149 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
51150 + return stack_top - current->mm->delta_stack;
51151 +#endif
51152 +
51153 if ((current->flags & PF_RANDOMIZE) &&
51154 !(current->personality & ADDR_NO_RANDOMIZE)) {
51155 random_variable = get_random_int() & STACK_RND_MASK;
51156 @@ -572,7 +915,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
51157 unsigned long load_addr = 0, load_bias = 0;
51158 int load_addr_set = 0;
51159 char * elf_interpreter = NULL;
51160 - unsigned long error;
51161 + unsigned long error = 0;
51162 struct elf_phdr *elf_ppnt, *elf_phdata;
51163 unsigned long elf_bss, elf_brk;
51164 int retval, i;
51165 @@ -582,12 +925,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
51166 unsigned long start_code, end_code, start_data, end_data;
51167 unsigned long reloc_func_desc __maybe_unused = 0;
51168 int executable_stack = EXSTACK_DEFAULT;
51169 - unsigned long def_flags = 0;
51170 struct pt_regs *regs = current_pt_regs();
51171 struct {
51172 struct elfhdr elf_ex;
51173 struct elfhdr interp_elf_ex;
51174 } *loc;
51175 + unsigned long pax_task_size = TASK_SIZE;
51176
51177 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
51178 if (!loc) {
51179 @@ -723,11 +1066,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
51180 goto out_free_dentry;
51181
51182 /* OK, This is the point of no return */
51183 - current->mm->def_flags = def_flags;
51184 +
51185 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
51186 + current->mm->pax_flags = 0UL;
51187 +#endif
51188 +
51189 +#ifdef CONFIG_PAX_DLRESOLVE
51190 + current->mm->call_dl_resolve = 0UL;
51191 +#endif
51192 +
51193 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
51194 + current->mm->call_syscall = 0UL;
51195 +#endif
51196 +
51197 +#ifdef CONFIG_PAX_ASLR
51198 + current->mm->delta_mmap = 0UL;
51199 + current->mm->delta_stack = 0UL;
51200 +#endif
51201 +
51202 + current->mm->def_flags = 0;
51203 +
51204 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
51205 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
51206 + send_sig(SIGKILL, current, 0);
51207 + goto out_free_dentry;
51208 + }
51209 +#endif
51210 +
51211 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
51212 + pax_set_initial_flags(bprm);
51213 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
51214 + if (pax_set_initial_flags_func)
51215 + (pax_set_initial_flags_func)(bprm);
51216 +#endif
51217 +
51218 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
51219 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
51220 + current->mm->context.user_cs_limit = PAGE_SIZE;
51221 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
51222 + }
51223 +#endif
51224 +
51225 +#ifdef CONFIG_PAX_SEGMEXEC
51226 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
51227 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
51228 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
51229 + pax_task_size = SEGMEXEC_TASK_SIZE;
51230 + current->mm->def_flags |= VM_NOHUGEPAGE;
51231 + }
51232 +#endif
51233 +
51234 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
51235 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51236 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
51237 + put_cpu();
51238 + }
51239 +#endif
51240
51241 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
51242 may depend on the personality. */
51243 SET_PERSONALITY(loc->elf_ex);
51244 +
51245 +#ifdef CONFIG_PAX_ASLR
51246 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
51247 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
51248 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
51249 + }
51250 +#endif
51251 +
51252 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51253 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51254 + executable_stack = EXSTACK_DISABLE_X;
51255 + current->personality &= ~READ_IMPLIES_EXEC;
51256 + } else
51257 +#endif
51258 +
51259 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
51260 current->personality |= READ_IMPLIES_EXEC;
51261
51262 @@ -819,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
51263 #else
51264 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
51265 #endif
51266 +
51267 +#ifdef CONFIG_PAX_RANDMMAP
51268 + /* PaX: randomize base address at the default exe base if requested */
51269 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
51270 +#ifdef CONFIG_SPARC64
51271 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
51272 +#else
51273 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
51274 +#endif
51275 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
51276 + elf_flags |= MAP_FIXED;
51277 + }
51278 +#endif
51279 +
51280 }
51281
51282 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
51283 @@ -851,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
51284 * allowed task size. Note that p_filesz must always be
51285 * <= p_memsz so it is only necessary to check p_memsz.
51286 */
51287 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
51288 - elf_ppnt->p_memsz > TASK_SIZE ||
51289 - TASK_SIZE - elf_ppnt->p_memsz < k) {
51290 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
51291 + elf_ppnt->p_memsz > pax_task_size ||
51292 + pax_task_size - elf_ppnt->p_memsz < k) {
51293 /* set_brk can never work. Avoid overflows. */
51294 send_sig(SIGKILL, current, 0);
51295 retval = -EINVAL;
51296 @@ -892,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
51297 goto out_free_dentry;
51298 }
51299 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
51300 - send_sig(SIGSEGV, current, 0);
51301 - retval = -EFAULT; /* Nobody gets to see this, but.. */
51302 - goto out_free_dentry;
51303 + /*
51304 + * This bss-zeroing can fail if the ELF
51305 + * file specifies odd protections. So
51306 + * we don't check the return value
51307 + */
51308 }
51309
51310 +#ifdef CONFIG_PAX_RANDMMAP
51311 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
51312 + unsigned long start, size, flags;
51313 + vm_flags_t vm_flags;
51314 +
51315 + start = ELF_PAGEALIGN(elf_brk);
51316 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
51317 + flags = MAP_FIXED | MAP_PRIVATE;
51318 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
51319 +
51320 + down_write(&current->mm->mmap_sem);
51321 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
51322 + retval = -ENOMEM;
51323 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
51324 +// if (current->personality & ADDR_NO_RANDOMIZE)
51325 +// vm_flags |= VM_READ | VM_MAYREAD;
51326 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
51327 + retval = IS_ERR_VALUE(start) ? start : 0;
51328 + }
51329 + up_write(&current->mm->mmap_sem);
51330 + if (retval == 0)
51331 + retval = set_brk(start + size, start + size + PAGE_SIZE);
51332 + if (retval < 0) {
51333 + send_sig(SIGKILL, current, 0);
51334 + goto out_free_dentry;
51335 + }
51336 + }
51337 +#endif
51338 +
51339 if (elf_interpreter) {
51340 - unsigned long interp_map_addr = 0;
51341 -
51342 elf_entry = load_elf_interp(&loc->interp_elf_ex,
51343 interpreter,
51344 - &interp_map_addr,
51345 load_bias);
51346 if (!IS_ERR((void *)elf_entry)) {
51347 /*
51348 @@ -1124,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
51349 * Decide what to dump of a segment, part, all or none.
51350 */
51351 static unsigned long vma_dump_size(struct vm_area_struct *vma,
51352 - unsigned long mm_flags)
51353 + unsigned long mm_flags, long signr)
51354 {
51355 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
51356
51357 @@ -1162,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
51358 if (vma->vm_file == NULL)
51359 return 0;
51360
51361 - if (FILTER(MAPPED_PRIVATE))
51362 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
51363 goto whole;
51364
51365 /*
51366 @@ -1387,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
51367 {
51368 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
51369 int i = 0;
51370 - do
51371 + do {
51372 i += 2;
51373 - while (auxv[i - 2] != AT_NULL);
51374 + } while (auxv[i - 2] != AT_NULL);
51375 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
51376 }
51377
51378 @@ -1398,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
51379 {
51380 mm_segment_t old_fs = get_fs();
51381 set_fs(KERNEL_DS);
51382 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
51383 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
51384 set_fs(old_fs);
51385 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
51386 }
51387 @@ -2019,14 +2474,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
51388 }
51389
51390 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
51391 - unsigned long mm_flags)
51392 + struct coredump_params *cprm)
51393 {
51394 struct vm_area_struct *vma;
51395 size_t size = 0;
51396
51397 for (vma = first_vma(current, gate_vma); vma != NULL;
51398 vma = next_vma(vma, gate_vma))
51399 - size += vma_dump_size(vma, mm_flags);
51400 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
51401 return size;
51402 }
51403
51404 @@ -2119,7 +2574,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51405
51406 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
51407
51408 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
51409 + offset += elf_core_vma_data_size(gate_vma, cprm);
51410 offset += elf_core_extra_data_size();
51411 e_shoff = offset;
51412
51413 @@ -2133,10 +2588,12 @@ static int elf_core_dump(struct coredump_params *cprm)
51414 offset = dataoff;
51415
51416 size += sizeof(*elf);
51417 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
51418 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
51419 goto end_coredump;
51420
51421 size += sizeof(*phdr4note);
51422 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
51423 if (size > cprm->limit
51424 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
51425 goto end_coredump;
51426 @@ -2150,7 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51427 phdr.p_offset = offset;
51428 phdr.p_vaddr = vma->vm_start;
51429 phdr.p_paddr = 0;
51430 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
51431 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
51432 phdr.p_memsz = vma->vm_end - vma->vm_start;
51433 offset += phdr.p_filesz;
51434 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
51435 @@ -2161,6 +2618,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51436 phdr.p_align = ELF_EXEC_PAGESIZE;
51437
51438 size += sizeof(phdr);
51439 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
51440 if (size > cprm->limit
51441 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
51442 goto end_coredump;
51443 @@ -2185,7 +2643,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51444 unsigned long addr;
51445 unsigned long end;
51446
51447 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
51448 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
51449
51450 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
51451 struct page *page;
51452 @@ -2194,6 +2652,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51453 page = get_dump_page(addr);
51454 if (page) {
51455 void *kaddr = kmap(page);
51456 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
51457 stop = ((size += PAGE_SIZE) > cprm->limit) ||
51458 !dump_write(cprm->file, kaddr,
51459 PAGE_SIZE);
51460 @@ -2211,6 +2670,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51461
51462 if (e_phnum == PN_XNUM) {
51463 size += sizeof(*shdr4extnum);
51464 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
51465 if (size > cprm->limit
51466 || !dump_write(cprm->file, shdr4extnum,
51467 sizeof(*shdr4extnum)))
51468 @@ -2231,6 +2691,167 @@ out:
51469
51470 #endif /* CONFIG_ELF_CORE */
51471
51472 +#ifdef CONFIG_PAX_MPROTECT
51473 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
51474 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
51475 + * we'll remove VM_MAYWRITE for good on RELRO segments.
51476 + *
51477 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
51478 + * basis because we want to allow the common case and not the special ones.
51479 + */
51480 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
51481 +{
51482 + struct elfhdr elf_h;
51483 + struct elf_phdr elf_p;
51484 + unsigned long i;
51485 + unsigned long oldflags;
51486 + bool is_textrel_rw, is_textrel_rx, is_relro;
51487 +
51488 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
51489 + return;
51490 +
51491 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
51492 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
51493 +
51494 +#ifdef CONFIG_PAX_ELFRELOCS
51495 + /* possible TEXTREL */
51496 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
51497 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
51498 +#else
51499 + is_textrel_rw = false;
51500 + is_textrel_rx = false;
51501 +#endif
51502 +
51503 + /* possible RELRO */
51504 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
51505 +
51506 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
51507 + return;
51508 +
51509 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
51510 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
51511 +
51512 +#ifdef CONFIG_PAX_ETEXECRELOCS
51513 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
51514 +#else
51515 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
51516 +#endif
51517 +
51518 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
51519 + !elf_check_arch(&elf_h) ||
51520 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
51521 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
51522 + return;
51523 +
51524 + for (i = 0UL; i < elf_h.e_phnum; i++) {
51525 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
51526 + return;
51527 + switch (elf_p.p_type) {
51528 + case PT_DYNAMIC:
51529 + if (!is_textrel_rw && !is_textrel_rx)
51530 + continue;
51531 + i = 0UL;
51532 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
51533 + elf_dyn dyn;
51534 +
51535 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
51536 + break;
51537 + if (dyn.d_tag == DT_NULL)
51538 + break;
51539 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
51540 + gr_log_textrel(vma);
51541 + if (is_textrel_rw)
51542 + vma->vm_flags |= VM_MAYWRITE;
51543 + else
51544 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
51545 + vma->vm_flags &= ~VM_MAYWRITE;
51546 + break;
51547 + }
51548 + i++;
51549 + }
51550 + is_textrel_rw = false;
51551 + is_textrel_rx = false;
51552 + continue;
51553 +
51554 + case PT_GNU_RELRO:
51555 + if (!is_relro)
51556 + continue;
51557 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
51558 + vma->vm_flags &= ~VM_MAYWRITE;
51559 + is_relro = false;
51560 + continue;
51561 +
51562 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
51563 + case PT_PAX_FLAGS: {
51564 + const char *msg_mprotect = "", *msg_emutramp = "";
51565 + char *buffer_lib, *buffer_exe;
51566 +
51567 + if (elf_p.p_flags & PF_NOMPROTECT)
51568 + msg_mprotect = "MPROTECT disabled";
51569 +
51570 +#ifdef CONFIG_PAX_EMUTRAMP
51571 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
51572 + msg_emutramp = "EMUTRAMP enabled";
51573 +#endif
51574 +
51575 + if (!msg_mprotect[0] && !msg_emutramp[0])
51576 + continue;
51577 +
51578 + if (!printk_ratelimit())
51579 + continue;
51580 +
51581 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
51582 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
51583 + if (buffer_lib && buffer_exe) {
51584 + char *path_lib, *path_exe;
51585 +
51586 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
51587 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
51588 +
51589 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
51590 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
51591 +
51592 + }
51593 + free_page((unsigned long)buffer_exe);
51594 + free_page((unsigned long)buffer_lib);
51595 + continue;
51596 + }
51597 +#endif
51598 +
51599 + }
51600 + }
51601 +}
51602 +#endif
51603 +
51604 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
51605 +
51606 +extern int grsec_enable_log_rwxmaps;
51607 +
51608 +static void elf_handle_mmap(struct file *file)
51609 +{
51610 + struct elfhdr elf_h;
51611 + struct elf_phdr elf_p;
51612 + unsigned long i;
51613 +
51614 + if (!grsec_enable_log_rwxmaps)
51615 + return;
51616 +
51617 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
51618 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
51619 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
51620 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
51621 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
51622 + return;
51623 +
51624 + for (i = 0UL; i < elf_h.e_phnum; i++) {
51625 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
51626 + return;
51627 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
51628 + gr_log_ptgnustack(file);
51629 + }
51630 +}
51631 +#endif
51632 +
51633 static int __init init_elf_binfmt(void)
51634 {
51635 register_binfmt(&elf_format);
51636 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
51637 index d50bbe5..af3b649 100644
51638 --- a/fs/binfmt_flat.c
51639 +++ b/fs/binfmt_flat.c
51640 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
51641 realdatastart = (unsigned long) -ENOMEM;
51642 printk("Unable to allocate RAM for process data, errno %d\n",
51643 (int)-realdatastart);
51644 + down_write(&current->mm->mmap_sem);
51645 vm_munmap(textpos, text_len);
51646 + up_write(&current->mm->mmap_sem);
51647 ret = realdatastart;
51648 goto err;
51649 }
51650 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
51651 }
51652 if (IS_ERR_VALUE(result)) {
51653 printk("Unable to read data+bss, errno %d\n", (int)-result);
51654 + down_write(&current->mm->mmap_sem);
51655 vm_munmap(textpos, text_len);
51656 vm_munmap(realdatastart, len);
51657 + up_write(&current->mm->mmap_sem);
51658 ret = result;
51659 goto err;
51660 }
51661 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
51662 }
51663 if (IS_ERR_VALUE(result)) {
51664 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
51665 + down_write(&current->mm->mmap_sem);
51666 vm_munmap(textpos, text_len + data_len + extra +
51667 MAX_SHARED_LIBS * sizeof(unsigned long));
51668 + up_write(&current->mm->mmap_sem);
51669 ret = result;
51670 goto err;
51671 }
51672 diff --git a/fs/bio.c b/fs/bio.c
51673 index 94bbc04..6fe78a4 100644
51674 --- a/fs/bio.c
51675 +++ b/fs/bio.c
51676 @@ -1096,7 +1096,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
51677 /*
51678 * Overflow, abort
51679 */
51680 - if (end < start)
51681 + if (end < start || end - start > INT_MAX - nr_pages)
51682 return ERR_PTR(-EINVAL);
51683
51684 nr_pages += end - start;
51685 @@ -1230,7 +1230,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
51686 /*
51687 * Overflow, abort
51688 */
51689 - if (end < start)
51690 + if (end < start || end - start > INT_MAX - nr_pages)
51691 return ERR_PTR(-EINVAL);
51692
51693 nr_pages += end - start;
51694 @@ -1492,7 +1492,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
51695 const int read = bio_data_dir(bio) == READ;
51696 struct bio_map_data *bmd = bio->bi_private;
51697 int i;
51698 - char *p = bmd->sgvecs[0].iov_base;
51699 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
51700
51701 bio_for_each_segment_all(bvec, bio, i) {
51702 char *addr = page_address(bvec->bv_page);
51703 diff --git a/fs/block_dev.c b/fs/block_dev.c
51704 index 85f5c85..d6f0b1a 100644
51705 --- a/fs/block_dev.c
51706 +++ b/fs/block_dev.c
51707 @@ -658,7 +658,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
51708 else if (bdev->bd_contains == bdev)
51709 return true; /* is a whole device which isn't held */
51710
51711 - else if (whole->bd_holder == bd_may_claim)
51712 + else if (whole->bd_holder == (void *)bd_may_claim)
51713 return true; /* is a partition of a device that is being partitioned */
51714 else if (whole->bd_holder != NULL)
51715 return false; /* is a partition of a held device */
51716 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
51717 index 7fb054b..ad36c67 100644
51718 --- a/fs/btrfs/ctree.c
51719 +++ b/fs/btrfs/ctree.c
51720 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
51721 free_extent_buffer(buf);
51722 add_root_to_dirty_list(root);
51723 } else {
51724 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
51725 - parent_start = parent->start;
51726 - else
51727 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
51728 + if (parent)
51729 + parent_start = parent->start;
51730 + else
51731 + parent_start = 0;
51732 + } else
51733 parent_start = 0;
51734
51735 WARN_ON(trans->transid != btrfs_header_generation(parent));
51736 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
51737 index 0f81d67..0ad55fe 100644
51738 --- a/fs/btrfs/ioctl.c
51739 +++ b/fs/btrfs/ioctl.c
51740 @@ -3084,9 +3084,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
51741 for (i = 0; i < num_types; i++) {
51742 struct btrfs_space_info *tmp;
51743
51744 + /* Don't copy in more than we allocated */
51745 if (!slot_count)
51746 break;
51747
51748 + slot_count--;
51749 +
51750 info = NULL;
51751 rcu_read_lock();
51752 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
51753 @@ -3108,10 +3111,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
51754 memcpy(dest, &space, sizeof(space));
51755 dest++;
51756 space_args.total_spaces++;
51757 - slot_count--;
51758 }
51759 - if (!slot_count)
51760 - break;
51761 }
51762 up_read(&info->groups_sem);
51763 }
51764 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
51765 index f0857e0..e7023c5 100644
51766 --- a/fs/btrfs/super.c
51767 +++ b/fs/btrfs/super.c
51768 @@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
51769 function, line, errstr);
51770 return;
51771 }
51772 - ACCESS_ONCE(trans->transaction->aborted) = errno;
51773 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
51774 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
51775 }
51776 /*
51777 diff --git a/fs/buffer.c b/fs/buffer.c
51778 index d2a4d1b..df798ca 100644
51779 --- a/fs/buffer.c
51780 +++ b/fs/buffer.c
51781 @@ -3367,7 +3367,7 @@ void __init buffer_init(void)
51782 bh_cachep = kmem_cache_create("buffer_head",
51783 sizeof(struct buffer_head), 0,
51784 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
51785 - SLAB_MEM_SPREAD),
51786 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
51787 NULL);
51788
51789 /*
51790 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
51791 index 622f469..e8d2d55 100644
51792 --- a/fs/cachefiles/bind.c
51793 +++ b/fs/cachefiles/bind.c
51794 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
51795 args);
51796
51797 /* start by checking things over */
51798 - ASSERT(cache->fstop_percent >= 0 &&
51799 - cache->fstop_percent < cache->fcull_percent &&
51800 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
51801 cache->fcull_percent < cache->frun_percent &&
51802 cache->frun_percent < 100);
51803
51804 - ASSERT(cache->bstop_percent >= 0 &&
51805 - cache->bstop_percent < cache->bcull_percent &&
51806 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
51807 cache->bcull_percent < cache->brun_percent &&
51808 cache->brun_percent < 100);
51809
51810 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
51811 index 0a1467b..6a53245 100644
51812 --- a/fs/cachefiles/daemon.c
51813 +++ b/fs/cachefiles/daemon.c
51814 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
51815 if (n > buflen)
51816 return -EMSGSIZE;
51817
51818 - if (copy_to_user(_buffer, buffer, n) != 0)
51819 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
51820 return -EFAULT;
51821
51822 return n;
51823 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
51824 if (test_bit(CACHEFILES_DEAD, &cache->flags))
51825 return -EIO;
51826
51827 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
51828 + if (datalen > PAGE_SIZE - 1)
51829 return -EOPNOTSUPP;
51830
51831 /* drag the command string into the kernel so we can parse it */
51832 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
51833 if (args[0] != '%' || args[1] != '\0')
51834 return -EINVAL;
51835
51836 - if (fstop < 0 || fstop >= cache->fcull_percent)
51837 + if (fstop >= cache->fcull_percent)
51838 return cachefiles_daemon_range_error(cache, args);
51839
51840 cache->fstop_percent = fstop;
51841 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
51842 if (args[0] != '%' || args[1] != '\0')
51843 return -EINVAL;
51844
51845 - if (bstop < 0 || bstop >= cache->bcull_percent)
51846 + if (bstop >= cache->bcull_percent)
51847 return cachefiles_daemon_range_error(cache, args);
51848
51849 cache->bstop_percent = bstop;
51850 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
51851 index 4938251..7e01445 100644
51852 --- a/fs/cachefiles/internal.h
51853 +++ b/fs/cachefiles/internal.h
51854 @@ -59,7 +59,7 @@ struct cachefiles_cache {
51855 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
51856 struct rb_root active_nodes; /* active nodes (can't be culled) */
51857 rwlock_t active_lock; /* lock for active_nodes */
51858 - atomic_t gravecounter; /* graveyard uniquifier */
51859 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
51860 unsigned frun_percent; /* when to stop culling (% files) */
51861 unsigned fcull_percent; /* when to start culling (% files) */
51862 unsigned fstop_percent; /* when to stop allocating (% files) */
51863 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
51864 * proc.c
51865 */
51866 #ifdef CONFIG_CACHEFILES_HISTOGRAM
51867 -extern atomic_t cachefiles_lookup_histogram[HZ];
51868 -extern atomic_t cachefiles_mkdir_histogram[HZ];
51869 -extern atomic_t cachefiles_create_histogram[HZ];
51870 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
51871 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
51872 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
51873
51874 extern int __init cachefiles_proc_init(void);
51875 extern void cachefiles_proc_cleanup(void);
51876 static inline
51877 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
51878 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
51879 {
51880 unsigned long jif = jiffies - start_jif;
51881 if (jif >= HZ)
51882 jif = HZ - 1;
51883 - atomic_inc(&histogram[jif]);
51884 + atomic_inc_unchecked(&histogram[jif]);
51885 }
51886
51887 #else
51888 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
51889 index 8c01c5fc..15f982e 100644
51890 --- a/fs/cachefiles/namei.c
51891 +++ b/fs/cachefiles/namei.c
51892 @@ -317,7 +317,7 @@ try_again:
51893 /* first step is to make up a grave dentry in the graveyard */
51894 sprintf(nbuffer, "%08x%08x",
51895 (uint32_t) get_seconds(),
51896 - (uint32_t) atomic_inc_return(&cache->gravecounter));
51897 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
51898
51899 /* do the multiway lock magic */
51900 trap = lock_rename(cache->graveyard, dir);
51901 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
51902 index eccd339..4c1d995 100644
51903 --- a/fs/cachefiles/proc.c
51904 +++ b/fs/cachefiles/proc.c
51905 @@ -14,9 +14,9 @@
51906 #include <linux/seq_file.h>
51907 #include "internal.h"
51908
51909 -atomic_t cachefiles_lookup_histogram[HZ];
51910 -atomic_t cachefiles_mkdir_histogram[HZ];
51911 -atomic_t cachefiles_create_histogram[HZ];
51912 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
51913 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
51914 +atomic_unchecked_t cachefiles_create_histogram[HZ];
51915
51916 /*
51917 * display the latency histogram
51918 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
51919 return 0;
51920 default:
51921 index = (unsigned long) v - 3;
51922 - x = atomic_read(&cachefiles_lookup_histogram[index]);
51923 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
51924 - z = atomic_read(&cachefiles_create_histogram[index]);
51925 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
51926 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
51927 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
51928 if (x == 0 && y == 0 && z == 0)
51929 return 0;
51930
51931 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
51932 index 317f9ee..3d24511 100644
51933 --- a/fs/cachefiles/rdwr.c
51934 +++ b/fs/cachefiles/rdwr.c
51935 @@ -966,7 +966,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
51936 old_fs = get_fs();
51937 set_fs(KERNEL_DS);
51938 ret = file->f_op->write(
51939 - file, (const void __user *) data, len, &pos);
51940 + file, (const void __force_user *) data, len, &pos);
51941 set_fs(old_fs);
51942 kunmap(page);
51943 file_end_write(file);
51944 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
51945 index f02d82b..2632cf86 100644
51946 --- a/fs/ceph/dir.c
51947 +++ b/fs/ceph/dir.c
51948 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
51949 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
51950 struct ceph_mds_client *mdsc = fsc->mdsc;
51951 unsigned frag = fpos_frag(filp->f_pos);
51952 - int off = fpos_off(filp->f_pos);
51953 + unsigned int off = fpos_off(filp->f_pos);
51954 int err;
51955 u32 ftype;
51956 struct ceph_mds_reply_info_parsed *rinfo;
51957 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
51958 index d597483..747901b 100644
51959 --- a/fs/cifs/cifs_debug.c
51960 +++ b/fs/cifs/cifs_debug.c
51961 @@ -284,8 +284,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
51962
51963 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
51964 #ifdef CONFIG_CIFS_STATS2
51965 - atomic_set(&totBufAllocCount, 0);
51966 - atomic_set(&totSmBufAllocCount, 0);
51967 + atomic_set_unchecked(&totBufAllocCount, 0);
51968 + atomic_set_unchecked(&totSmBufAllocCount, 0);
51969 #endif /* CONFIG_CIFS_STATS2 */
51970 spin_lock(&cifs_tcp_ses_lock);
51971 list_for_each(tmp1, &cifs_tcp_ses_list) {
51972 @@ -298,7 +298,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
51973 tcon = list_entry(tmp3,
51974 struct cifs_tcon,
51975 tcon_list);
51976 - atomic_set(&tcon->num_smbs_sent, 0);
51977 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
51978 if (server->ops->clear_stats)
51979 server->ops->clear_stats(tcon);
51980 }
51981 @@ -330,8 +330,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
51982 smBufAllocCount.counter, cifs_min_small);
51983 #ifdef CONFIG_CIFS_STATS2
51984 seq_printf(m, "Total Large %d Small %d Allocations\n",
51985 - atomic_read(&totBufAllocCount),
51986 - atomic_read(&totSmBufAllocCount));
51987 + atomic_read_unchecked(&totBufAllocCount),
51988 + atomic_read_unchecked(&totSmBufAllocCount));
51989 #endif /* CONFIG_CIFS_STATS2 */
51990
51991 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
51992 @@ -360,7 +360,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
51993 if (tcon->need_reconnect)
51994 seq_puts(m, "\tDISCONNECTED ");
51995 seq_printf(m, "\nSMBs: %d",
51996 - atomic_read(&tcon->num_smbs_sent));
51997 + atomic_read_unchecked(&tcon->num_smbs_sent));
51998 if (server->ops->print_stats)
51999 server->ops->print_stats(m, tcon);
52000 }
52001 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
52002 index 3752b9f..8db5569 100644
52003 --- a/fs/cifs/cifsfs.c
52004 +++ b/fs/cifs/cifsfs.c
52005 @@ -1035,7 +1035,7 @@ cifs_init_request_bufs(void)
52006 */
52007 cifs_req_cachep = kmem_cache_create("cifs_request",
52008 CIFSMaxBufSize + max_hdr_size, 0,
52009 - SLAB_HWCACHE_ALIGN, NULL);
52010 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
52011 if (cifs_req_cachep == NULL)
52012 return -ENOMEM;
52013
52014 @@ -1062,7 +1062,7 @@ cifs_init_request_bufs(void)
52015 efficient to alloc 1 per page off the slab compared to 17K (5page)
52016 alloc of large cifs buffers even when page debugging is on */
52017 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
52018 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
52019 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
52020 NULL);
52021 if (cifs_sm_req_cachep == NULL) {
52022 mempool_destroy(cifs_req_poolp);
52023 @@ -1147,8 +1147,8 @@ init_cifs(void)
52024 atomic_set(&bufAllocCount, 0);
52025 atomic_set(&smBufAllocCount, 0);
52026 #ifdef CONFIG_CIFS_STATS2
52027 - atomic_set(&totBufAllocCount, 0);
52028 - atomic_set(&totSmBufAllocCount, 0);
52029 + atomic_set_unchecked(&totBufAllocCount, 0);
52030 + atomic_set_unchecked(&totSmBufAllocCount, 0);
52031 #endif /* CONFIG_CIFS_STATS2 */
52032
52033 atomic_set(&midCount, 0);
52034 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
52035 index ea3a0b3..0194e39 100644
52036 --- a/fs/cifs/cifsglob.h
52037 +++ b/fs/cifs/cifsglob.h
52038 @@ -752,35 +752,35 @@ struct cifs_tcon {
52039 __u16 Flags; /* optional support bits */
52040 enum statusEnum tidStatus;
52041 #ifdef CONFIG_CIFS_STATS
52042 - atomic_t num_smbs_sent;
52043 + atomic_unchecked_t num_smbs_sent;
52044 union {
52045 struct {
52046 - atomic_t num_writes;
52047 - atomic_t num_reads;
52048 - atomic_t num_flushes;
52049 - atomic_t num_oplock_brks;
52050 - atomic_t num_opens;
52051 - atomic_t num_closes;
52052 - atomic_t num_deletes;
52053 - atomic_t num_mkdirs;
52054 - atomic_t num_posixopens;
52055 - atomic_t num_posixmkdirs;
52056 - atomic_t num_rmdirs;
52057 - atomic_t num_renames;
52058 - atomic_t num_t2renames;
52059 - atomic_t num_ffirst;
52060 - atomic_t num_fnext;
52061 - atomic_t num_fclose;
52062 - atomic_t num_hardlinks;
52063 - atomic_t num_symlinks;
52064 - atomic_t num_locks;
52065 - atomic_t num_acl_get;
52066 - atomic_t num_acl_set;
52067 + atomic_unchecked_t num_writes;
52068 + atomic_unchecked_t num_reads;
52069 + atomic_unchecked_t num_flushes;
52070 + atomic_unchecked_t num_oplock_brks;
52071 + atomic_unchecked_t num_opens;
52072 + atomic_unchecked_t num_closes;
52073 + atomic_unchecked_t num_deletes;
52074 + atomic_unchecked_t num_mkdirs;
52075 + atomic_unchecked_t num_posixopens;
52076 + atomic_unchecked_t num_posixmkdirs;
52077 + atomic_unchecked_t num_rmdirs;
52078 + atomic_unchecked_t num_renames;
52079 + atomic_unchecked_t num_t2renames;
52080 + atomic_unchecked_t num_ffirst;
52081 + atomic_unchecked_t num_fnext;
52082 + atomic_unchecked_t num_fclose;
52083 + atomic_unchecked_t num_hardlinks;
52084 + atomic_unchecked_t num_symlinks;
52085 + atomic_unchecked_t num_locks;
52086 + atomic_unchecked_t num_acl_get;
52087 + atomic_unchecked_t num_acl_set;
52088 } cifs_stats;
52089 #ifdef CONFIG_CIFS_SMB2
52090 struct {
52091 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
52092 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
52093 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
52094 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
52095 } smb2_stats;
52096 #endif /* CONFIG_CIFS_SMB2 */
52097 } stats;
52098 @@ -1081,7 +1081,7 @@ convert_delimiter(char *path, char delim)
52099 }
52100
52101 #ifdef CONFIG_CIFS_STATS
52102 -#define cifs_stats_inc atomic_inc
52103 +#define cifs_stats_inc atomic_inc_unchecked
52104
52105 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
52106 unsigned int bytes)
52107 @@ -1446,8 +1446,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
52108 /* Various Debug counters */
52109 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
52110 #ifdef CONFIG_CIFS_STATS2
52111 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
52112 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
52113 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
52114 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
52115 #endif
52116 GLOBAL_EXTERN atomic_t smBufAllocCount;
52117 GLOBAL_EXTERN atomic_t midCount;
52118 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
52119 index b83c3f5..6437caa 100644
52120 --- a/fs/cifs/link.c
52121 +++ b/fs/cifs/link.c
52122 @@ -616,7 +616,7 @@ symlink_exit:
52123
52124 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
52125 {
52126 - char *p = nd_get_link(nd);
52127 + const char *p = nd_get_link(nd);
52128 if (!IS_ERR(p))
52129 kfree(p);
52130 }
52131 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
52132 index 1bec014..f329411 100644
52133 --- a/fs/cifs/misc.c
52134 +++ b/fs/cifs/misc.c
52135 @@ -169,7 +169,7 @@ cifs_buf_get(void)
52136 memset(ret_buf, 0, buf_size + 3);
52137 atomic_inc(&bufAllocCount);
52138 #ifdef CONFIG_CIFS_STATS2
52139 - atomic_inc(&totBufAllocCount);
52140 + atomic_inc_unchecked(&totBufAllocCount);
52141 #endif /* CONFIG_CIFS_STATS2 */
52142 }
52143
52144 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
52145 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
52146 atomic_inc(&smBufAllocCount);
52147 #ifdef CONFIG_CIFS_STATS2
52148 - atomic_inc(&totSmBufAllocCount);
52149 + atomic_inc_unchecked(&totSmBufAllocCount);
52150 #endif /* CONFIG_CIFS_STATS2 */
52151
52152 }
52153 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
52154 index 3efdb9d..e845a5e 100644
52155 --- a/fs/cifs/smb1ops.c
52156 +++ b/fs/cifs/smb1ops.c
52157 @@ -591,27 +591,27 @@ static void
52158 cifs_clear_stats(struct cifs_tcon *tcon)
52159 {
52160 #ifdef CONFIG_CIFS_STATS
52161 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
52162 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
52163 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
52164 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
52165 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
52166 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
52167 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
52168 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
52169 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
52170 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
52171 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
52172 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
52173 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
52174 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
52175 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
52176 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
52177 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
52178 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
52179 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
52180 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
52181 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
52182 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
52183 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
52184 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
52185 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
52186 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
52187 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
52188 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
52189 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
52190 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
52191 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
52192 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
52193 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
52194 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
52195 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
52196 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
52197 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
52198 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
52199 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
52200 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
52201 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
52202 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
52203 #endif
52204 }
52205
52206 @@ -620,36 +620,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
52207 {
52208 #ifdef CONFIG_CIFS_STATS
52209 seq_printf(m, " Oplocks breaks: %d",
52210 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
52211 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
52212 seq_printf(m, "\nReads: %d Bytes: %llu",
52213 - atomic_read(&tcon->stats.cifs_stats.num_reads),
52214 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
52215 (long long)(tcon->bytes_read));
52216 seq_printf(m, "\nWrites: %d Bytes: %llu",
52217 - atomic_read(&tcon->stats.cifs_stats.num_writes),
52218 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
52219 (long long)(tcon->bytes_written));
52220 seq_printf(m, "\nFlushes: %d",
52221 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
52222 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
52223 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
52224 - atomic_read(&tcon->stats.cifs_stats.num_locks),
52225 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
52226 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
52227 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
52228 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
52229 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
52230 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
52231 - atomic_read(&tcon->stats.cifs_stats.num_opens),
52232 - atomic_read(&tcon->stats.cifs_stats.num_closes),
52233 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
52234 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
52235 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
52236 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
52237 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
52238 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
52239 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
52240 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
52241 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
52242 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
52243 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
52244 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
52245 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
52246 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
52247 seq_printf(m, "\nRenames: %d T2 Renames %d",
52248 - atomic_read(&tcon->stats.cifs_stats.num_renames),
52249 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
52250 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
52251 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
52252 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
52253 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
52254 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
52255 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
52256 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
52257 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
52258 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
52259 #endif
52260 }
52261
52262 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
52263 index f2e76f3..c44fac7 100644
52264 --- a/fs/cifs/smb2ops.c
52265 +++ b/fs/cifs/smb2ops.c
52266 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
52267 #ifdef CONFIG_CIFS_STATS
52268 int i;
52269 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
52270 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
52271 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
52272 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
52273 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
52274 }
52275 #endif
52276 }
52277 @@ -284,66 +284,66 @@ static void
52278 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
52279 {
52280 #ifdef CONFIG_CIFS_STATS
52281 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
52282 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
52283 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
52284 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
52285 seq_printf(m, "\nNegotiates: %d sent %d failed",
52286 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
52287 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
52288 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
52289 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
52290 seq_printf(m, "\nSessionSetups: %d sent %d failed",
52291 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
52292 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
52293 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
52294 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
52295 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
52296 seq_printf(m, "\nLogoffs: %d sent %d failed",
52297 - atomic_read(&sent[SMB2_LOGOFF_HE]),
52298 - atomic_read(&failed[SMB2_LOGOFF_HE]));
52299 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
52300 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
52301 seq_printf(m, "\nTreeConnects: %d sent %d failed",
52302 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
52303 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
52304 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
52305 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
52306 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
52307 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
52308 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
52309 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
52310 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
52311 seq_printf(m, "\nCreates: %d sent %d failed",
52312 - atomic_read(&sent[SMB2_CREATE_HE]),
52313 - atomic_read(&failed[SMB2_CREATE_HE]));
52314 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
52315 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
52316 seq_printf(m, "\nCloses: %d sent %d failed",
52317 - atomic_read(&sent[SMB2_CLOSE_HE]),
52318 - atomic_read(&failed[SMB2_CLOSE_HE]));
52319 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
52320 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
52321 seq_printf(m, "\nFlushes: %d sent %d failed",
52322 - atomic_read(&sent[SMB2_FLUSH_HE]),
52323 - atomic_read(&failed[SMB2_FLUSH_HE]));
52324 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
52325 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
52326 seq_printf(m, "\nReads: %d sent %d failed",
52327 - atomic_read(&sent[SMB2_READ_HE]),
52328 - atomic_read(&failed[SMB2_READ_HE]));
52329 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
52330 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
52331 seq_printf(m, "\nWrites: %d sent %d failed",
52332 - atomic_read(&sent[SMB2_WRITE_HE]),
52333 - atomic_read(&failed[SMB2_WRITE_HE]));
52334 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
52335 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
52336 seq_printf(m, "\nLocks: %d sent %d failed",
52337 - atomic_read(&sent[SMB2_LOCK_HE]),
52338 - atomic_read(&failed[SMB2_LOCK_HE]));
52339 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
52340 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
52341 seq_printf(m, "\nIOCTLs: %d sent %d failed",
52342 - atomic_read(&sent[SMB2_IOCTL_HE]),
52343 - atomic_read(&failed[SMB2_IOCTL_HE]));
52344 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
52345 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
52346 seq_printf(m, "\nCancels: %d sent %d failed",
52347 - atomic_read(&sent[SMB2_CANCEL_HE]),
52348 - atomic_read(&failed[SMB2_CANCEL_HE]));
52349 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
52350 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
52351 seq_printf(m, "\nEchos: %d sent %d failed",
52352 - atomic_read(&sent[SMB2_ECHO_HE]),
52353 - atomic_read(&failed[SMB2_ECHO_HE]));
52354 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
52355 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
52356 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
52357 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
52358 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
52359 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
52360 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
52361 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
52362 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
52363 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
52364 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
52365 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
52366 seq_printf(m, "\nQueryInfos: %d sent %d failed",
52367 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
52368 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
52369 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
52370 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
52371 seq_printf(m, "\nSetInfos: %d sent %d failed",
52372 - atomic_read(&sent[SMB2_SET_INFO_HE]),
52373 - atomic_read(&failed[SMB2_SET_INFO_HE]));
52374 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
52375 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
52376 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
52377 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
52378 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
52379 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
52380 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
52381 #endif
52382 }
52383
52384 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
52385 index 2b95ce2..d079d75 100644
52386 --- a/fs/cifs/smb2pdu.c
52387 +++ b/fs/cifs/smb2pdu.c
52388 @@ -1760,8 +1760,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
52389 default:
52390 cifs_dbg(VFS, "info level %u isn't supported\n",
52391 srch_inf->info_level);
52392 - rc = -EINVAL;
52393 - goto qdir_exit;
52394 + return -EINVAL;
52395 }
52396
52397 req->FileIndex = cpu_to_le32(index);
52398 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
52399 index 1da168c..8bc7ff6 100644
52400 --- a/fs/coda/cache.c
52401 +++ b/fs/coda/cache.c
52402 @@ -24,7 +24,7 @@
52403 #include "coda_linux.h"
52404 #include "coda_cache.h"
52405
52406 -static atomic_t permission_epoch = ATOMIC_INIT(0);
52407 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
52408
52409 /* replace or extend an acl cache hit */
52410 void coda_cache_enter(struct inode *inode, int mask)
52411 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
52412 struct coda_inode_info *cii = ITOC(inode);
52413
52414 spin_lock(&cii->c_lock);
52415 - cii->c_cached_epoch = atomic_read(&permission_epoch);
52416 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
52417 if (!uid_eq(cii->c_uid, current_fsuid())) {
52418 cii->c_uid = current_fsuid();
52419 cii->c_cached_perm = mask;
52420 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
52421 {
52422 struct coda_inode_info *cii = ITOC(inode);
52423 spin_lock(&cii->c_lock);
52424 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
52425 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
52426 spin_unlock(&cii->c_lock);
52427 }
52428
52429 /* remove all acl caches */
52430 void coda_cache_clear_all(struct super_block *sb)
52431 {
52432 - atomic_inc(&permission_epoch);
52433 + atomic_inc_unchecked(&permission_epoch);
52434 }
52435
52436
52437 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
52438 spin_lock(&cii->c_lock);
52439 hit = (mask & cii->c_cached_perm) == mask &&
52440 uid_eq(cii->c_uid, current_fsuid()) &&
52441 - cii->c_cached_epoch == atomic_read(&permission_epoch);
52442 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
52443 spin_unlock(&cii->c_lock);
52444
52445 return hit;
52446 diff --git a/fs/compat.c b/fs/compat.c
52447 index fc3b55d..7b568ae 100644
52448 --- a/fs/compat.c
52449 +++ b/fs/compat.c
52450 @@ -54,7 +54,7 @@
52451 #include <asm/ioctls.h>
52452 #include "internal.h"
52453
52454 -int compat_log = 1;
52455 +int compat_log = 0;
52456
52457 int compat_printk(const char *fmt, ...)
52458 {
52459 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
52460
52461 set_fs(KERNEL_DS);
52462 /* The __user pointer cast is valid because of the set_fs() */
52463 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
52464 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
52465 set_fs(oldfs);
52466 /* truncating is ok because it's a user address */
52467 if (!ret)
52468 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
52469 goto out;
52470
52471 ret = -EINVAL;
52472 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
52473 + if (nr_segs > UIO_MAXIOV)
52474 goto out;
52475 if (nr_segs > fast_segs) {
52476 ret = -ENOMEM;
52477 @@ -833,6 +833,7 @@ struct compat_old_linux_dirent {
52478
52479 struct compat_readdir_callback {
52480 struct compat_old_linux_dirent __user *dirent;
52481 + struct file * file;
52482 int result;
52483 };
52484
52485 @@ -850,6 +851,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
52486 buf->result = -EOVERFLOW;
52487 return -EOVERFLOW;
52488 }
52489 +
52490 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
52491 + return 0;
52492 +
52493 buf->result++;
52494 dirent = buf->dirent;
52495 if (!access_ok(VERIFY_WRITE, dirent,
52496 @@ -880,6 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
52497
52498 buf.result = 0;
52499 buf.dirent = dirent;
52500 + buf.file = f.file;
52501
52502 error = vfs_readdir(f.file, compat_fillonedir, &buf);
52503 if (buf.result)
52504 @@ -899,6 +905,7 @@ struct compat_linux_dirent {
52505 struct compat_getdents_callback {
52506 struct compat_linux_dirent __user *current_dir;
52507 struct compat_linux_dirent __user *previous;
52508 + struct file * file;
52509 int count;
52510 int error;
52511 };
52512 @@ -920,6 +927,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
52513 buf->error = -EOVERFLOW;
52514 return -EOVERFLOW;
52515 }
52516 +
52517 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
52518 + return 0;
52519 +
52520 dirent = buf->previous;
52521 if (dirent) {
52522 if (__put_user(offset, &dirent->d_off))
52523 @@ -965,6 +976,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
52524 buf.previous = NULL;
52525 buf.count = count;
52526 buf.error = 0;
52527 + buf.file = f.file;
52528
52529 error = vfs_readdir(f.file, compat_filldir, &buf);
52530 if (error >= 0)
52531 @@ -985,6 +997,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
52532 struct compat_getdents_callback64 {
52533 struct linux_dirent64 __user *current_dir;
52534 struct linux_dirent64 __user *previous;
52535 + struct file * file;
52536 int count;
52537 int error;
52538 };
52539 @@ -1001,6 +1014,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
52540 buf->error = -EINVAL; /* only used if we fail.. */
52541 if (reclen > buf->count)
52542 return -EINVAL;
52543 +
52544 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
52545 + return 0;
52546 +
52547 dirent = buf->previous;
52548
52549 if (dirent) {
52550 @@ -1050,13 +1067,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
52551 buf.previous = NULL;
52552 buf.count = count;
52553 buf.error = 0;
52554 + buf.file = f.file;
52555
52556 error = vfs_readdir(f.file, compat_filldir64, &buf);
52557 if (error >= 0)
52558 error = buf.error;
52559 lastdirent = buf.previous;
52560 if (lastdirent) {
52561 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
52562 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
52563 if (__put_user_unaligned(d_off, &lastdirent->d_off))
52564 error = -EFAULT;
52565 else
52566 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
52567 index a81147e..20bf2b5 100644
52568 --- a/fs/compat_binfmt_elf.c
52569 +++ b/fs/compat_binfmt_elf.c
52570 @@ -30,11 +30,13 @@
52571 #undef elf_phdr
52572 #undef elf_shdr
52573 #undef elf_note
52574 +#undef elf_dyn
52575 #undef elf_addr_t
52576 #define elfhdr elf32_hdr
52577 #define elf_phdr elf32_phdr
52578 #define elf_shdr elf32_shdr
52579 #define elf_note elf32_note
52580 +#define elf_dyn Elf32_Dyn
52581 #define elf_addr_t Elf32_Addr
52582
52583 /*
52584 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
52585 index 996cdc5..15e2f33 100644
52586 --- a/fs/compat_ioctl.c
52587 +++ b/fs/compat_ioctl.c
52588 @@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
52589 return -EFAULT;
52590 if (__get_user(udata, &ss32->iomem_base))
52591 return -EFAULT;
52592 - ss.iomem_base = compat_ptr(udata);
52593 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
52594 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
52595 __get_user(ss.port_high, &ss32->port_high))
52596 return -EFAULT;
52597 @@ -703,8 +703,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
52598 for (i = 0; i < nmsgs; i++) {
52599 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
52600 return -EFAULT;
52601 - if (get_user(datap, &umsgs[i].buf) ||
52602 - put_user(compat_ptr(datap), &tmsgs[i].buf))
52603 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
52604 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
52605 return -EFAULT;
52606 }
52607 return sys_ioctl(fd, cmd, (unsigned long)tdata);
52608 @@ -797,7 +797,7 @@ static int compat_ioctl_preallocate(struct file *file,
52609 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
52610 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
52611 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
52612 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
52613 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
52614 return -EFAULT;
52615
52616 return ioctl_preallocate(file, p);
52617 @@ -1619,8 +1619,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
52618 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
52619 {
52620 unsigned int a, b;
52621 - a = *(unsigned int *)p;
52622 - b = *(unsigned int *)q;
52623 + a = *(const unsigned int *)p;
52624 + b = *(const unsigned int *)q;
52625 if (a > b)
52626 return 1;
52627 if (a < b)
52628 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
52629 index 7aabc6a..34c1197 100644
52630 --- a/fs/configfs/dir.c
52631 +++ b/fs/configfs/dir.c
52632 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
52633 }
52634 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
52635 struct configfs_dirent *next;
52636 - const char * name;
52637 + const unsigned char * name;
52638 + char d_name[sizeof(next->s_dentry->d_iname)];
52639 int len;
52640 struct inode *inode = NULL;
52641
52642 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
52643 continue;
52644
52645 name = configfs_get_name(next);
52646 - len = strlen(name);
52647 + if (next->s_dentry && name == next->s_dentry->d_iname) {
52648 + len = next->s_dentry->d_name.len;
52649 + memcpy(d_name, name, len);
52650 + name = d_name;
52651 + } else
52652 + len = strlen(name);
52653
52654 /*
52655 * We'll have a dentry and an inode for
52656 diff --git a/fs/coredump.c b/fs/coredump.c
52657 index dafafba..10b3b27 100644
52658 --- a/fs/coredump.c
52659 +++ b/fs/coredump.c
52660 @@ -52,7 +52,7 @@ struct core_name {
52661 char *corename;
52662 int used, size;
52663 };
52664 -static atomic_t call_count = ATOMIC_INIT(1);
52665 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
52666
52667 /* The maximal length of core_pattern is also specified in sysctl.c */
52668
52669 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
52670 {
52671 char *old_corename = cn->corename;
52672
52673 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
52674 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
52675 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
52676
52677 if (!cn->corename) {
52678 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
52679 int pid_in_pattern = 0;
52680 int err = 0;
52681
52682 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
52683 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
52684 cn->corename = kmalloc(cn->size, GFP_KERNEL);
52685 cn->used = 0;
52686
52687 @@ -435,8 +435,8 @@ static void wait_for_dump_helpers(struct file *file)
52688 struct pipe_inode_info *pipe = file->private_data;
52689
52690 pipe_lock(pipe);
52691 - pipe->readers++;
52692 - pipe->writers--;
52693 + atomic_inc(&pipe->readers);
52694 + atomic_dec(&pipe->writers);
52695 wake_up_interruptible_sync(&pipe->wait);
52696 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
52697 pipe_unlock(pipe);
52698 @@ -445,11 +445,11 @@ static void wait_for_dump_helpers(struct file *file)
52699 * We actually want wait_event_freezable() but then we need
52700 * to clear TIF_SIGPENDING and improve dump_interrupted().
52701 */
52702 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
52703 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
52704
52705 pipe_lock(pipe);
52706 - pipe->readers--;
52707 - pipe->writers++;
52708 + atomic_dec(&pipe->readers);
52709 + atomic_inc(&pipe->writers);
52710 pipe_unlock(pipe);
52711 }
52712
52713 @@ -496,7 +496,8 @@ void do_coredump(siginfo_t *siginfo)
52714 struct files_struct *displaced;
52715 bool need_nonrelative = false;
52716 bool core_dumped = false;
52717 - static atomic_t core_dump_count = ATOMIC_INIT(0);
52718 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
52719 + long signr = siginfo->si_signo;
52720 struct coredump_params cprm = {
52721 .siginfo = siginfo,
52722 .regs = signal_pt_regs(),
52723 @@ -509,7 +510,10 @@ void do_coredump(siginfo_t *siginfo)
52724 .mm_flags = mm->flags,
52725 };
52726
52727 - audit_core_dumps(siginfo->si_signo);
52728 + audit_core_dumps(signr);
52729 +
52730 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
52731 + gr_handle_brute_attach(cprm.mm_flags);
52732
52733 binfmt = mm->binfmt;
52734 if (!binfmt || !binfmt->core_dump)
52735 @@ -533,7 +537,7 @@ void do_coredump(siginfo_t *siginfo)
52736 need_nonrelative = true;
52737 }
52738
52739 - retval = coredump_wait(siginfo->si_signo, &core_state);
52740 + retval = coredump_wait(signr, &core_state);
52741 if (retval < 0)
52742 goto fail_creds;
52743
52744 @@ -576,7 +580,7 @@ void do_coredump(siginfo_t *siginfo)
52745 }
52746 cprm.limit = RLIM_INFINITY;
52747
52748 - dump_count = atomic_inc_return(&core_dump_count);
52749 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
52750 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
52751 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
52752 task_tgid_vnr(current), current->comm);
52753 @@ -608,6 +612,8 @@ void do_coredump(siginfo_t *siginfo)
52754 } else {
52755 struct inode *inode;
52756
52757 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
52758 +
52759 if (cprm.limit < binfmt->min_coredump)
52760 goto fail_unlock;
52761
52762 @@ -666,7 +672,7 @@ close_fail:
52763 filp_close(cprm.file, NULL);
52764 fail_dropcount:
52765 if (ispipe)
52766 - atomic_dec(&core_dump_count);
52767 + atomic_dec_unchecked(&core_dump_count);
52768 fail_unlock:
52769 kfree(cn.corename);
52770 fail_corename:
52771 @@ -687,7 +693,7 @@ int dump_write(struct file *file, const void *addr, int nr)
52772 {
52773 return !dump_interrupted() &&
52774 access_ok(VERIFY_READ, addr, nr) &&
52775 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
52776 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
52777 }
52778 EXPORT_SYMBOL(dump_write);
52779
52780 diff --git a/fs/dcache.c b/fs/dcache.c
52781 index f09b908..04b9690 100644
52782 --- a/fs/dcache.c
52783 +++ b/fs/dcache.c
52784 @@ -3086,7 +3086,8 @@ void __init vfs_caches_init(unsigned long mempages)
52785 mempages -= reserve;
52786
52787 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
52788 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
52789 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
52790 + SLAB_NO_SANITIZE, NULL);
52791
52792 dcache_init();
52793 inode_init();
52794 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
52795 index c7c83ff..bda9461 100644
52796 --- a/fs/debugfs/inode.c
52797 +++ b/fs/debugfs/inode.c
52798 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
52799 */
52800 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
52801 {
52802 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
52803 + return __create_file(name, S_IFDIR | S_IRWXU,
52804 +#else
52805 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
52806 +#endif
52807 parent, NULL, NULL);
52808 }
52809 EXPORT_SYMBOL_GPL(debugfs_create_dir);
52810 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
52811 index 5eab400..810a3f5 100644
52812 --- a/fs/ecryptfs/inode.c
52813 +++ b/fs/ecryptfs/inode.c
52814 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
52815 old_fs = get_fs();
52816 set_fs(get_ds());
52817 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
52818 - (char __user *)lower_buf,
52819 + (char __force_user *)lower_buf,
52820 PATH_MAX);
52821 set_fs(old_fs);
52822 if (rc < 0)
52823 @@ -706,7 +706,7 @@ out:
52824 static void
52825 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
52826 {
52827 - char *buf = nd_get_link(nd);
52828 + const char *buf = nd_get_link(nd);
52829 if (!IS_ERR(buf)) {
52830 /* Free the char* */
52831 kfree(buf);
52832 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
52833 index e4141f2..d8263e8 100644
52834 --- a/fs/ecryptfs/miscdev.c
52835 +++ b/fs/ecryptfs/miscdev.c
52836 @@ -304,7 +304,7 @@ check_list:
52837 goto out_unlock_msg_ctx;
52838 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
52839 if (msg_ctx->msg) {
52840 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
52841 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
52842 goto out_unlock_msg_ctx;
52843 i += packet_length_size;
52844 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
52845 diff --git a/fs/exec.c b/fs/exec.c
52846 index ffd7a81..3c84660 100644
52847 --- a/fs/exec.c
52848 +++ b/fs/exec.c
52849 @@ -55,8 +55,20 @@
52850 #include <linux/pipe_fs_i.h>
52851 #include <linux/oom.h>
52852 #include <linux/compat.h>
52853 +#include <linux/random.h>
52854 +#include <linux/seq_file.h>
52855 +#include <linux/coredump.h>
52856 +#include <linux/mman.h>
52857 +
52858 +#ifdef CONFIG_PAX_REFCOUNT
52859 +#include <linux/kallsyms.h>
52860 +#include <linux/kdebug.h>
52861 +#endif
52862 +
52863 +#include <trace/events/fs.h>
52864
52865 #include <asm/uaccess.h>
52866 +#include <asm/sections.h>
52867 #include <asm/mmu_context.h>
52868 #include <asm/tlb.h>
52869
52870 @@ -66,17 +78,32 @@
52871
52872 #include <trace/events/sched.h>
52873
52874 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52875 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
52876 +{
52877 + 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");
52878 +}
52879 +#endif
52880 +
52881 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
52882 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
52883 +EXPORT_SYMBOL(pax_set_initial_flags_func);
52884 +#endif
52885 +
52886 int suid_dumpable = 0;
52887
52888 static LIST_HEAD(formats);
52889 static DEFINE_RWLOCK(binfmt_lock);
52890
52891 +extern int gr_process_kernel_exec_ban(void);
52892 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
52893 +
52894 void __register_binfmt(struct linux_binfmt * fmt, int insert)
52895 {
52896 BUG_ON(!fmt);
52897 write_lock(&binfmt_lock);
52898 - insert ? list_add(&fmt->lh, &formats) :
52899 - list_add_tail(&fmt->lh, &formats);
52900 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
52901 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
52902 write_unlock(&binfmt_lock);
52903 }
52904
52905 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
52906 void unregister_binfmt(struct linux_binfmt * fmt)
52907 {
52908 write_lock(&binfmt_lock);
52909 - list_del(&fmt->lh);
52910 + pax_list_del((struct list_head *)&fmt->lh);
52911 write_unlock(&binfmt_lock);
52912 }
52913
52914 @@ -180,18 +207,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
52915 int write)
52916 {
52917 struct page *page;
52918 - int ret;
52919
52920 -#ifdef CONFIG_STACK_GROWSUP
52921 - if (write) {
52922 - ret = expand_downwards(bprm->vma, pos);
52923 - if (ret < 0)
52924 - return NULL;
52925 - }
52926 -#endif
52927 - ret = get_user_pages(current, bprm->mm, pos,
52928 - 1, write, 1, &page, NULL);
52929 - if (ret <= 0)
52930 + if (0 > expand_downwards(bprm->vma, pos))
52931 + return NULL;
52932 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
52933 return NULL;
52934
52935 if (write) {
52936 @@ -207,6 +226,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
52937 if (size <= ARG_MAX)
52938 return page;
52939
52940 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
52941 + // only allow 512KB for argv+env on suid/sgid binaries
52942 + // to prevent easy ASLR exhaustion
52943 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
52944 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
52945 + (size > (512 * 1024))) {
52946 + put_page(page);
52947 + return NULL;
52948 + }
52949 +#endif
52950 +
52951 /*
52952 * Limit to 1/4-th the stack size for the argv+env strings.
52953 * This ensures that:
52954 @@ -266,6 +296,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
52955 vma->vm_end = STACK_TOP_MAX;
52956 vma->vm_start = vma->vm_end - PAGE_SIZE;
52957 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
52958 +
52959 +#ifdef CONFIG_PAX_SEGMEXEC
52960 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
52961 +#endif
52962 +
52963 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
52964 INIT_LIST_HEAD(&vma->anon_vma_chain);
52965
52966 @@ -276,6 +311,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
52967 mm->stack_vm = mm->total_vm = 1;
52968 up_write(&mm->mmap_sem);
52969 bprm->p = vma->vm_end - sizeof(void *);
52970 +
52971 +#ifdef CONFIG_PAX_RANDUSTACK
52972 + if (randomize_va_space)
52973 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
52974 +#endif
52975 +
52976 return 0;
52977 err:
52978 up_write(&mm->mmap_sem);
52979 @@ -396,7 +437,7 @@ struct user_arg_ptr {
52980 } ptr;
52981 };
52982
52983 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
52984 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
52985 {
52986 const char __user *native;
52987
52988 @@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
52989 compat_uptr_t compat;
52990
52991 if (get_user(compat, argv.ptr.compat + nr))
52992 - return ERR_PTR(-EFAULT);
52993 + return (const char __force_user *)ERR_PTR(-EFAULT);
52994
52995 return compat_ptr(compat);
52996 }
52997 #endif
52998
52999 if (get_user(native, argv.ptr.native + nr))
53000 - return ERR_PTR(-EFAULT);
53001 + return (const char __force_user *)ERR_PTR(-EFAULT);
53002
53003 return native;
53004 }
53005 @@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
53006 if (!p)
53007 break;
53008
53009 - if (IS_ERR(p))
53010 + if (IS_ERR((const char __force_kernel *)p))
53011 return -EFAULT;
53012
53013 if (i >= max)
53014 @@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
53015
53016 ret = -EFAULT;
53017 str = get_user_arg_ptr(argv, argc);
53018 - if (IS_ERR(str))
53019 + if (IS_ERR((const char __force_kernel *)str))
53020 goto out;
53021
53022 len = strnlen_user(str, MAX_ARG_STRLEN);
53023 @@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
53024 int r;
53025 mm_segment_t oldfs = get_fs();
53026 struct user_arg_ptr argv = {
53027 - .ptr.native = (const char __user *const __user *)__argv,
53028 + .ptr.native = (const char __force_user * const __force_user *)__argv,
53029 };
53030
53031 set_fs(KERNEL_DS);
53032 @@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
53033 unsigned long new_end = old_end - shift;
53034 struct mmu_gather tlb;
53035
53036 - BUG_ON(new_start > new_end);
53037 + if (new_start >= new_end || new_start < mmap_min_addr)
53038 + return -ENOMEM;
53039
53040 /*
53041 * ensure there are no vmas between where we want to go
53042 @@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
53043 if (vma != find_vma(mm, new_start))
53044 return -EFAULT;
53045
53046 +#ifdef CONFIG_PAX_SEGMEXEC
53047 + BUG_ON(pax_find_mirror_vma(vma));
53048 +#endif
53049 +
53050 /*
53051 * cover the whole range: [new_start, old_end)
53052 */
53053 @@ -607,7 +653,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
53054 return -ENOMEM;
53055
53056 lru_add_drain();
53057 - tlb_gather_mmu(&tlb, mm, 0);
53058 + tlb_gather_mmu(&tlb, mm, old_start, old_end);
53059 if (new_end > old_start) {
53060 /*
53061 * when the old and new regions overlap clear from new_end.
53062 @@ -624,7 +670,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
53063 free_pgd_range(&tlb, old_start, old_end, new_end,
53064 vma->vm_next ? vma->vm_next->vm_start : USER_PGTABLES_CEILING);
53065 }
53066 - tlb_finish_mmu(&tlb, new_end, old_end);
53067 + tlb_finish_mmu(&tlb, old_start, old_end);
53068
53069 /*
53070 * Shrink the vma to just the new range. Always succeeds.
53071 @@ -672,10 +718,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
53072 stack_top = arch_align_stack(stack_top);
53073 stack_top = PAGE_ALIGN(stack_top);
53074
53075 - if (unlikely(stack_top < mmap_min_addr) ||
53076 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
53077 - return -ENOMEM;
53078 -
53079 stack_shift = vma->vm_end - stack_top;
53080
53081 bprm->p -= stack_shift;
53082 @@ -687,8 +729,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
53083 bprm->exec -= stack_shift;
53084
53085 down_write(&mm->mmap_sem);
53086 +
53087 + /* Move stack pages down in memory. */
53088 + if (stack_shift) {
53089 + ret = shift_arg_pages(vma, stack_shift);
53090 + if (ret)
53091 + goto out_unlock;
53092 + }
53093 +
53094 vm_flags = VM_STACK_FLAGS;
53095
53096 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
53097 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53098 + vm_flags &= ~VM_EXEC;
53099 +
53100 +#ifdef CONFIG_PAX_MPROTECT
53101 + if (mm->pax_flags & MF_PAX_MPROTECT)
53102 + vm_flags &= ~VM_MAYEXEC;
53103 +#endif
53104 +
53105 + }
53106 +#endif
53107 +
53108 /*
53109 * Adjust stack execute permissions; explicitly enable for
53110 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
53111 @@ -707,13 +769,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
53112 goto out_unlock;
53113 BUG_ON(prev != vma);
53114
53115 - /* Move stack pages down in memory. */
53116 - if (stack_shift) {
53117 - ret = shift_arg_pages(vma, stack_shift);
53118 - if (ret)
53119 - goto out_unlock;
53120 - }
53121 -
53122 /* mprotect_fixup is overkill to remove the temporary stack flags */
53123 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
53124
53125 @@ -737,6 +792,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
53126 #endif
53127 current->mm->start_stack = bprm->p;
53128 ret = expand_stack(vma, stack_base);
53129 +
53130 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
53131 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
53132 + unsigned long size;
53133 + vm_flags_t vm_flags;
53134 +
53135 + size = STACK_TOP - vma->vm_end;
53136 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
53137 +
53138 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
53139 +
53140 +#ifdef CONFIG_X86
53141 + if (!ret) {
53142 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
53143 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
53144 + }
53145 +#endif
53146 +
53147 + }
53148 +#endif
53149 +
53150 if (ret)
53151 ret = -EFAULT;
53152
53153 @@ -772,6 +848,8 @@ struct file *open_exec(const char *name)
53154
53155 fsnotify_open(file);
53156
53157 + trace_open_exec(name);
53158 +
53159 err = deny_write_access(file);
53160 if (err)
53161 goto exit;
53162 @@ -795,7 +873,7 @@ int kernel_read(struct file *file, loff_t offset,
53163 old_fs = get_fs();
53164 set_fs(get_ds());
53165 /* The cast to a user pointer is valid due to the set_fs() */
53166 - result = vfs_read(file, (void __user *)addr, count, &pos);
53167 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
53168 set_fs(old_fs);
53169 return result;
53170 }
53171 @@ -1251,7 +1329,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
53172 }
53173 rcu_read_unlock();
53174
53175 - if (p->fs->users > n_fs) {
53176 + if (atomic_read(&p->fs->users) > n_fs) {
53177 bprm->unsafe |= LSM_UNSAFE_SHARE;
53178 } else {
53179 res = -EAGAIN;
53180 @@ -1451,6 +1529,31 @@ int search_binary_handler(struct linux_binprm *bprm)
53181
53182 EXPORT_SYMBOL(search_binary_handler);
53183
53184 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
53185 +static DEFINE_PER_CPU(u64, exec_counter);
53186 +static int __init init_exec_counters(void)
53187 +{
53188 + unsigned int cpu;
53189 +
53190 + for_each_possible_cpu(cpu) {
53191 + per_cpu(exec_counter, cpu) = (u64)cpu;
53192 + }
53193 +
53194 + return 0;
53195 +}
53196 +early_initcall(init_exec_counters);
53197 +static inline void increment_exec_counter(void)
53198 +{
53199 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
53200 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
53201 +}
53202 +#else
53203 +static inline void increment_exec_counter(void) {}
53204 +#endif
53205 +
53206 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
53207 + struct user_arg_ptr argv);
53208 +
53209 /*
53210 * sys_execve() executes a new program.
53211 */
53212 @@ -1458,6 +1561,11 @@ static int do_execve_common(const char *filename,
53213 struct user_arg_ptr argv,
53214 struct user_arg_ptr envp)
53215 {
53216 +#ifdef CONFIG_GRKERNSEC
53217 + struct file *old_exec_file;
53218 + struct acl_subject_label *old_acl;
53219 + struct rlimit old_rlim[RLIM_NLIMITS];
53220 +#endif
53221 struct linux_binprm *bprm;
53222 struct file *file;
53223 struct files_struct *displaced;
53224 @@ -1465,6 +1573,8 @@ static int do_execve_common(const char *filename,
53225 int retval;
53226 const struct cred *cred = current_cred();
53227
53228 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
53229 +
53230 /*
53231 * We move the actual failure in case of RLIMIT_NPROC excess from
53232 * set*uid() to execve() because too many poorly written programs
53233 @@ -1505,12 +1615,22 @@ static int do_execve_common(const char *filename,
53234 if (IS_ERR(file))
53235 goto out_unmark;
53236
53237 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
53238 + retval = -EPERM;
53239 + goto out_file;
53240 + }
53241 +
53242 sched_exec();
53243
53244 bprm->file = file;
53245 bprm->filename = filename;
53246 bprm->interp = filename;
53247
53248 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
53249 + retval = -EACCES;
53250 + goto out_file;
53251 + }
53252 +
53253 retval = bprm_mm_init(bprm);
53254 if (retval)
53255 goto out_file;
53256 @@ -1527,24 +1647,70 @@ static int do_execve_common(const char *filename,
53257 if (retval < 0)
53258 goto out;
53259
53260 +#ifdef CONFIG_GRKERNSEC
53261 + old_acl = current->acl;
53262 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
53263 + old_exec_file = current->exec_file;
53264 + get_file(file);
53265 + current->exec_file = file;
53266 +#endif
53267 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
53268 + /* limit suid stack to 8MB
53269 + * we saved the old limits above and will restore them if this exec fails
53270 + */
53271 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
53272 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
53273 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
53274 +#endif
53275 +
53276 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
53277 + retval = -EPERM;
53278 + goto out_fail;
53279 + }
53280 +
53281 + if (!gr_tpe_allow(file)) {
53282 + retval = -EACCES;
53283 + goto out_fail;
53284 + }
53285 +
53286 + if (gr_check_crash_exec(file)) {
53287 + retval = -EACCES;
53288 + goto out_fail;
53289 + }
53290 +
53291 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
53292 + bprm->unsafe);
53293 + if (retval < 0)
53294 + goto out_fail;
53295 +
53296 retval = copy_strings_kernel(1, &bprm->filename, bprm);
53297 if (retval < 0)
53298 - goto out;
53299 + goto out_fail;
53300
53301 bprm->exec = bprm->p;
53302 retval = copy_strings(bprm->envc, envp, bprm);
53303 if (retval < 0)
53304 - goto out;
53305 + goto out_fail;
53306
53307 retval = copy_strings(bprm->argc, argv, bprm);
53308 if (retval < 0)
53309 - goto out;
53310 + goto out_fail;
53311 +
53312 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
53313 +
53314 + gr_handle_exec_args(bprm, argv);
53315
53316 retval = search_binary_handler(bprm);
53317 if (retval < 0)
53318 - goto out;
53319 + goto out_fail;
53320 +#ifdef CONFIG_GRKERNSEC
53321 + if (old_exec_file)
53322 + fput(old_exec_file);
53323 +#endif
53324
53325 /* execve succeeded */
53326 +
53327 + increment_exec_counter();
53328 current->fs->in_exec = 0;
53329 current->in_execve = 0;
53330 acct_update_integrals(current);
53331 @@ -1553,6 +1719,14 @@ static int do_execve_common(const char *filename,
53332 put_files_struct(displaced);
53333 return retval;
53334
53335 +out_fail:
53336 +#ifdef CONFIG_GRKERNSEC
53337 + current->acl = old_acl;
53338 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
53339 + fput(current->exec_file);
53340 + current->exec_file = old_exec_file;
53341 +#endif
53342 +
53343 out:
53344 if (bprm->mm) {
53345 acct_arg_size(bprm, 0);
53346 @@ -1701,3 +1875,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
53347 return error;
53348 }
53349 #endif
53350 +
53351 +int pax_check_flags(unsigned long *flags)
53352 +{
53353 + int retval = 0;
53354 +
53355 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
53356 + if (*flags & MF_PAX_SEGMEXEC)
53357 + {
53358 + *flags &= ~MF_PAX_SEGMEXEC;
53359 + retval = -EINVAL;
53360 + }
53361 +#endif
53362 +
53363 + if ((*flags & MF_PAX_PAGEEXEC)
53364 +
53365 +#ifdef CONFIG_PAX_PAGEEXEC
53366 + && (*flags & MF_PAX_SEGMEXEC)
53367 +#endif
53368 +
53369 + )
53370 + {
53371 + *flags &= ~MF_PAX_PAGEEXEC;
53372 + retval = -EINVAL;
53373 + }
53374 +
53375 + if ((*flags & MF_PAX_MPROTECT)
53376 +
53377 +#ifdef CONFIG_PAX_MPROTECT
53378 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
53379 +#endif
53380 +
53381 + )
53382 + {
53383 + *flags &= ~MF_PAX_MPROTECT;
53384 + retval = -EINVAL;
53385 + }
53386 +
53387 + if ((*flags & MF_PAX_EMUTRAMP)
53388 +
53389 +#ifdef CONFIG_PAX_EMUTRAMP
53390 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
53391 +#endif
53392 +
53393 + )
53394 + {
53395 + *flags &= ~MF_PAX_EMUTRAMP;
53396 + retval = -EINVAL;
53397 + }
53398 +
53399 + return retval;
53400 +}
53401 +
53402 +EXPORT_SYMBOL(pax_check_flags);
53403 +
53404 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
53405 +char *pax_get_path(const struct path *path, char *buf, int buflen)
53406 +{
53407 + char *pathname = d_path(path, buf, buflen);
53408 +
53409 + if (IS_ERR(pathname))
53410 + goto toolong;
53411 +
53412 + pathname = mangle_path(buf, pathname, "\t\n\\");
53413 + if (!pathname)
53414 + goto toolong;
53415 +
53416 + *pathname = 0;
53417 + return buf;
53418 +
53419 +toolong:
53420 + return "<path too long>";
53421 +}
53422 +EXPORT_SYMBOL(pax_get_path);
53423 +
53424 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
53425 +{
53426 + struct task_struct *tsk = current;
53427 + struct mm_struct *mm = current->mm;
53428 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
53429 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
53430 + char *path_exec = NULL;
53431 + char *path_fault = NULL;
53432 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
53433 + siginfo_t info = { };
53434 +
53435 + if (buffer_exec && buffer_fault) {
53436 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
53437 +
53438 + down_read(&mm->mmap_sem);
53439 + vma = mm->mmap;
53440 + while (vma && (!vma_exec || !vma_fault)) {
53441 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
53442 + vma_exec = vma;
53443 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
53444 + vma_fault = vma;
53445 + vma = vma->vm_next;
53446 + }
53447 + if (vma_exec)
53448 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
53449 + if (vma_fault) {
53450 + start = vma_fault->vm_start;
53451 + end = vma_fault->vm_end;
53452 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
53453 + if (vma_fault->vm_file)
53454 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
53455 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
53456 + path_fault = "<heap>";
53457 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
53458 + path_fault = "<stack>";
53459 + else
53460 + path_fault = "<anonymous mapping>";
53461 + }
53462 + up_read(&mm->mmap_sem);
53463 + }
53464 + if (tsk->signal->curr_ip)
53465 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
53466 + else
53467 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
53468 + 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),
53469 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
53470 + free_page((unsigned long)buffer_exec);
53471 + free_page((unsigned long)buffer_fault);
53472 + pax_report_insns(regs, pc, sp);
53473 + info.si_signo = SIGKILL;
53474 + info.si_errno = 0;
53475 + info.si_code = SI_KERNEL;
53476 + info.si_pid = 0;
53477 + info.si_uid = 0;
53478 + do_coredump(&info);
53479 +}
53480 +#endif
53481 +
53482 +#ifdef CONFIG_PAX_REFCOUNT
53483 +void pax_report_refcount_overflow(struct pt_regs *regs)
53484 +{
53485 + if (current->signal->curr_ip)
53486 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
53487 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
53488 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
53489 + else
53490 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
53491 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
53492 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
53493 + preempt_disable();
53494 + show_regs(regs);
53495 + preempt_enable();
53496 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
53497 +}
53498 +#endif
53499 +
53500 +#ifdef CONFIG_PAX_USERCOPY
53501 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
53502 +static noinline int check_stack_object(const void *obj, unsigned long len)
53503 +{
53504 + const void * const stack = task_stack_page(current);
53505 + const void * const stackend = stack + THREAD_SIZE;
53506 +
53507 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
53508 + const void *frame = NULL;
53509 + const void *oldframe;
53510 +#endif
53511 +
53512 + if (obj + len < obj)
53513 + return -1;
53514 +
53515 + if (obj + len <= stack || stackend <= obj)
53516 + return 0;
53517 +
53518 + if (obj < stack || stackend < obj + len)
53519 + return -1;
53520 +
53521 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
53522 + oldframe = __builtin_frame_address(1);
53523 + if (oldframe)
53524 + frame = __builtin_frame_address(2);
53525 + /*
53526 + low ----------------------------------------------> high
53527 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
53528 + ^----------------^
53529 + allow copies only within here
53530 + */
53531 + while (stack <= frame && frame < stackend) {
53532 + /* if obj + len extends past the last frame, this
53533 + check won't pass and the next frame will be 0,
53534 + causing us to bail out and correctly report
53535 + the copy as invalid
53536 + */
53537 + if (obj + len <= frame)
53538 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
53539 + oldframe = frame;
53540 + frame = *(const void * const *)frame;
53541 + }
53542 + return -1;
53543 +#else
53544 + return 1;
53545 +#endif
53546 +}
53547 +
53548 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
53549 +{
53550 + if (current->signal->curr_ip)
53551 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
53552 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
53553 + else
53554 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
53555 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
53556 + dump_stack();
53557 + gr_handle_kernel_exploit();
53558 + do_group_exit(SIGKILL);
53559 +}
53560 +#endif
53561 +
53562 +#ifdef CONFIG_PAX_USERCOPY
53563 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
53564 +{
53565 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
53566 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
53567 +#ifdef CONFIG_MODULES
53568 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
53569 +#else
53570 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
53571 +#endif
53572 +
53573 +#else
53574 + unsigned long textlow = (unsigned long)_stext;
53575 + unsigned long texthigh = (unsigned long)_etext;
53576 +#endif
53577 +
53578 + if (high <= textlow || low > texthigh)
53579 + return false;
53580 + else
53581 + return true;
53582 +}
53583 +#endif
53584 +
53585 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
53586 +{
53587 +
53588 +#ifdef CONFIG_PAX_USERCOPY
53589 + const char *type;
53590 +
53591 + if (!n)
53592 + return;
53593 +
53594 + type = check_heap_object(ptr, n);
53595 + if (!type) {
53596 + int ret = check_stack_object(ptr, n);
53597 + if (ret == 1 || ret == 2)
53598 + return;
53599 + if (ret == 0) {
53600 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
53601 + type = "<kernel text>";
53602 + else
53603 + return;
53604 + } else
53605 + type = "<process stack>";
53606 + }
53607 +
53608 + pax_report_usercopy(ptr, n, to_user, type);
53609 +#endif
53610 +
53611 +}
53612 +EXPORT_SYMBOL(__check_object_size);
53613 +
53614 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
53615 +void pax_track_stack(void)
53616 +{
53617 + unsigned long sp = (unsigned long)&sp;
53618 + if (sp < current_thread_info()->lowest_stack &&
53619 + sp > (unsigned long)task_stack_page(current))
53620 + current_thread_info()->lowest_stack = sp;
53621 +}
53622 +EXPORT_SYMBOL(pax_track_stack);
53623 +#endif
53624 +
53625 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
53626 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
53627 +{
53628 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
53629 + dump_stack();
53630 + do_group_exit(SIGKILL);
53631 +}
53632 +EXPORT_SYMBOL(report_size_overflow);
53633 +#endif
53634 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
53635 index 9f9992b..8b59411 100644
53636 --- a/fs/ext2/balloc.c
53637 +++ b/fs/ext2/balloc.c
53638 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
53639
53640 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
53641 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
53642 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
53643 + if (free_blocks < root_blocks + 1 &&
53644 !uid_eq(sbi->s_resuid, current_fsuid()) &&
53645 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
53646 - !in_group_p (sbi->s_resgid))) {
53647 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
53648 return 0;
53649 }
53650 return 1;
53651 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
53652 index 22548f5..41521d8 100644
53653 --- a/fs/ext3/balloc.c
53654 +++ b/fs/ext3/balloc.c
53655 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
53656
53657 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
53658 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
53659 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
53660 + if (free_blocks < root_blocks + 1 &&
53661 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
53662 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
53663 - !in_group_p (sbi->s_resgid))) {
53664 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
53665 return 0;
53666 }
53667 return 1;
53668 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
53669 index 3742e4c..69a797f 100644
53670 --- a/fs/ext4/balloc.c
53671 +++ b/fs/ext4/balloc.c
53672 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
53673 /* Hm, nope. Are (enough) root reserved clusters available? */
53674 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
53675 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
53676 - capable(CAP_SYS_RESOURCE) ||
53677 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
53678 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
53679 + capable_nolog(CAP_SYS_RESOURCE)) {
53680
53681 if (free_clusters >= (nclusters + dirty_clusters +
53682 resv_clusters))
53683 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
53684 index 5aae3d1..b5da7f8 100644
53685 --- a/fs/ext4/ext4.h
53686 +++ b/fs/ext4/ext4.h
53687 @@ -1252,19 +1252,19 @@ struct ext4_sb_info {
53688 unsigned long s_mb_last_start;
53689
53690 /* stats for buddy allocator */
53691 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
53692 - atomic_t s_bal_success; /* we found long enough chunks */
53693 - atomic_t s_bal_allocated; /* in blocks */
53694 - atomic_t s_bal_ex_scanned; /* total extents scanned */
53695 - atomic_t s_bal_goals; /* goal hits */
53696 - atomic_t s_bal_breaks; /* too long searches */
53697 - atomic_t s_bal_2orders; /* 2^order hits */
53698 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
53699 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
53700 + atomic_unchecked_t s_bal_allocated; /* in blocks */
53701 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
53702 + atomic_unchecked_t s_bal_goals; /* goal hits */
53703 + atomic_unchecked_t s_bal_breaks; /* too long searches */
53704 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
53705 spinlock_t s_bal_lock;
53706 unsigned long s_mb_buddies_generated;
53707 unsigned long long s_mb_generation_time;
53708 - atomic_t s_mb_lost_chunks;
53709 - atomic_t s_mb_preallocated;
53710 - atomic_t s_mb_discarded;
53711 + atomic_unchecked_t s_mb_lost_chunks;
53712 + atomic_unchecked_t s_mb_preallocated;
53713 + atomic_unchecked_t s_mb_discarded;
53714 atomic_t s_lock_busy;
53715
53716 /* locality groups */
53717 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
53718 index 59c6750..a549154 100644
53719 --- a/fs/ext4/mballoc.c
53720 +++ b/fs/ext4/mballoc.c
53721 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
53722 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
53723
53724 if (EXT4_SB(sb)->s_mb_stats)
53725 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
53726 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
53727
53728 break;
53729 }
53730 @@ -2170,7 +2170,7 @@ repeat:
53731 ac->ac_status = AC_STATUS_CONTINUE;
53732 ac->ac_flags |= EXT4_MB_HINT_FIRST;
53733 cr = 3;
53734 - atomic_inc(&sbi->s_mb_lost_chunks);
53735 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
53736 goto repeat;
53737 }
53738 }
53739 @@ -2678,25 +2678,25 @@ int ext4_mb_release(struct super_block *sb)
53740 if (sbi->s_mb_stats) {
53741 ext4_msg(sb, KERN_INFO,
53742 "mballoc: %u blocks %u reqs (%u success)",
53743 - atomic_read(&sbi->s_bal_allocated),
53744 - atomic_read(&sbi->s_bal_reqs),
53745 - atomic_read(&sbi->s_bal_success));
53746 + atomic_read_unchecked(&sbi->s_bal_allocated),
53747 + atomic_read_unchecked(&sbi->s_bal_reqs),
53748 + atomic_read_unchecked(&sbi->s_bal_success));
53749 ext4_msg(sb, KERN_INFO,
53750 "mballoc: %u extents scanned, %u goal hits, "
53751 "%u 2^N hits, %u breaks, %u lost",
53752 - atomic_read(&sbi->s_bal_ex_scanned),
53753 - atomic_read(&sbi->s_bal_goals),
53754 - atomic_read(&sbi->s_bal_2orders),
53755 - atomic_read(&sbi->s_bal_breaks),
53756 - atomic_read(&sbi->s_mb_lost_chunks));
53757 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
53758 + atomic_read_unchecked(&sbi->s_bal_goals),
53759 + atomic_read_unchecked(&sbi->s_bal_2orders),
53760 + atomic_read_unchecked(&sbi->s_bal_breaks),
53761 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
53762 ext4_msg(sb, KERN_INFO,
53763 "mballoc: %lu generated and it took %Lu",
53764 sbi->s_mb_buddies_generated,
53765 sbi->s_mb_generation_time);
53766 ext4_msg(sb, KERN_INFO,
53767 "mballoc: %u preallocated, %u discarded",
53768 - atomic_read(&sbi->s_mb_preallocated),
53769 - atomic_read(&sbi->s_mb_discarded));
53770 + atomic_read_unchecked(&sbi->s_mb_preallocated),
53771 + atomic_read_unchecked(&sbi->s_mb_discarded));
53772 }
53773
53774 free_percpu(sbi->s_locality_groups);
53775 @@ -3150,16 +3150,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
53776 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
53777
53778 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
53779 - atomic_inc(&sbi->s_bal_reqs);
53780 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
53781 + atomic_inc_unchecked(&sbi->s_bal_reqs);
53782 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
53783 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
53784 - atomic_inc(&sbi->s_bal_success);
53785 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
53786 + atomic_inc_unchecked(&sbi->s_bal_success);
53787 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
53788 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
53789 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
53790 - atomic_inc(&sbi->s_bal_goals);
53791 + atomic_inc_unchecked(&sbi->s_bal_goals);
53792 if (ac->ac_found > sbi->s_mb_max_to_scan)
53793 - atomic_inc(&sbi->s_bal_breaks);
53794 + atomic_inc_unchecked(&sbi->s_bal_breaks);
53795 }
53796
53797 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
53798 @@ -3559,7 +3559,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
53799 trace_ext4_mb_new_inode_pa(ac, pa);
53800
53801 ext4_mb_use_inode_pa(ac, pa);
53802 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
53803 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
53804
53805 ei = EXT4_I(ac->ac_inode);
53806 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
53807 @@ -3619,7 +3619,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
53808 trace_ext4_mb_new_group_pa(ac, pa);
53809
53810 ext4_mb_use_group_pa(ac, pa);
53811 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
53812 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
53813
53814 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
53815 lg = ac->ac_lg;
53816 @@ -3708,7 +3708,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
53817 * from the bitmap and continue.
53818 */
53819 }
53820 - atomic_add(free, &sbi->s_mb_discarded);
53821 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
53822
53823 return err;
53824 }
53825 @@ -3726,7 +3726,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
53826 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
53827 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
53828 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
53829 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
53830 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
53831 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
53832
53833 return 0;
53834 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
53835 index 214461e..3614c89 100644
53836 --- a/fs/ext4/mmp.c
53837 +++ b/fs/ext4/mmp.c
53838 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
53839 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
53840 const char *function, unsigned int line, const char *msg)
53841 {
53842 - __ext4_warning(sb, function, line, msg);
53843 + __ext4_warning(sb, function, line, "%s", msg);
53844 __ext4_warning(sb, function, line,
53845 "MMP failure info: last update time: %llu, last update "
53846 "node: %s, last update device: %s\n",
53847 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
53848 index 49d3c01..9579efd 100644
53849 --- a/fs/ext4/resize.c
53850 +++ b/fs/ext4/resize.c
53851 @@ -79,12 +79,20 @@ static int verify_group_input(struct super_block *sb,
53852 ext4_fsblk_t end = start + input->blocks_count;
53853 ext4_group_t group = input->group;
53854 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
53855 - unsigned overhead = ext4_group_overhead_blocks(sb, group);
53856 - ext4_fsblk_t metaend = start + overhead;
53857 + unsigned overhead;
53858 + ext4_fsblk_t metaend;
53859 struct buffer_head *bh = NULL;
53860 ext4_grpblk_t free_blocks_count, offset;
53861 int err = -EINVAL;
53862
53863 + if (group != sbi->s_groups_count) {
53864 + ext4_warning(sb, "Cannot add at group %u (only %u groups)",
53865 + input->group, sbi->s_groups_count);
53866 + return -EINVAL;
53867 + }
53868 +
53869 + overhead = ext4_group_overhead_blocks(sb, group);
53870 + metaend = start + overhead;
53871 input->free_blocks_count = free_blocks_count =
53872 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
53873
53874 @@ -96,10 +104,7 @@ static int verify_group_input(struct super_block *sb,
53875 free_blocks_count, input->reserved_blocks);
53876
53877 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
53878 - if (group != sbi->s_groups_count)
53879 - ext4_warning(sb, "Cannot add at group %u (only %u groups)",
53880 - input->group, sbi->s_groups_count);
53881 - else if (offset != 0)
53882 + if (offset != 0)
53883 ext4_warning(sb, "Last group not full");
53884 else if (input->reserved_blocks > input->blocks_count / 5)
53885 ext4_warning(sb, "Reserved blocks too high (%u)",
53886 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
53887 index 3f7c39e..227f24f 100644
53888 --- a/fs/ext4/super.c
53889 +++ b/fs/ext4/super.c
53890 @@ -1236,7 +1236,7 @@ static ext4_fsblk_t get_sb_block(void **data)
53891 }
53892
53893 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
53894 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
53895 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
53896 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
53897
53898 #ifdef CONFIG_QUOTA
53899 @@ -2372,7 +2372,7 @@ struct ext4_attr {
53900 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
53901 const char *, size_t);
53902 int offset;
53903 -};
53904 +} __do_const;
53905
53906 static int parse_strtoull(const char *buf,
53907 unsigned long long max, unsigned long long *value)
53908 diff --git a/fs/fcntl.c b/fs/fcntl.c
53909 index 6599222..e7bf0de 100644
53910 --- a/fs/fcntl.c
53911 +++ b/fs/fcntl.c
53912 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
53913 if (err)
53914 return err;
53915
53916 + if (gr_handle_chroot_fowner(pid, type))
53917 + return -ENOENT;
53918 + if (gr_check_protected_task_fowner(pid, type))
53919 + return -EACCES;
53920 +
53921 f_modown(filp, pid, type, force);
53922 return 0;
53923 }
53924 diff --git a/fs/fhandle.c b/fs/fhandle.c
53925 index 999ff5c..41f4109 100644
53926 --- a/fs/fhandle.c
53927 +++ b/fs/fhandle.c
53928 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
53929 } else
53930 retval = 0;
53931 /* copy the mount id */
53932 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
53933 - sizeof(*mnt_id)) ||
53934 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
53935 copy_to_user(ufh, handle,
53936 sizeof(struct file_handle) + handle_bytes))
53937 retval = -EFAULT;
53938 diff --git a/fs/file.c b/fs/file.c
53939 index 4a78f98..9447397 100644
53940 --- a/fs/file.c
53941 +++ b/fs/file.c
53942 @@ -16,6 +16,7 @@
53943 #include <linux/slab.h>
53944 #include <linux/vmalloc.h>
53945 #include <linux/file.h>
53946 +#include <linux/security.h>
53947 #include <linux/fdtable.h>
53948 #include <linux/bitops.h>
53949 #include <linux/interrupt.h>
53950 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
53951 if (!file)
53952 return __close_fd(files, fd);
53953
53954 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
53955 if (fd >= rlimit(RLIMIT_NOFILE))
53956 return -EBADF;
53957
53958 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
53959 if (unlikely(oldfd == newfd))
53960 return -EINVAL;
53961
53962 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
53963 if (newfd >= rlimit(RLIMIT_NOFILE))
53964 return -EBADF;
53965
53966 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
53967 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
53968 {
53969 int err;
53970 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
53971 if (from >= rlimit(RLIMIT_NOFILE))
53972 return -EINVAL;
53973 err = alloc_fd(from, flags);
53974 diff --git a/fs/filesystems.c b/fs/filesystems.c
53975 index 92567d9..fcd8cbf 100644
53976 --- a/fs/filesystems.c
53977 +++ b/fs/filesystems.c
53978 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
53979 int len = dot ? dot - name : strlen(name);
53980
53981 fs = __get_fs_type(name, len);
53982 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
53983 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
53984 +#else
53985 if (!fs && (request_module("fs-%.*s", len, name) == 0))
53986 +#endif
53987 fs = __get_fs_type(name, len);
53988
53989 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
53990 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
53991 index d8ac61d..79a36f0 100644
53992 --- a/fs/fs_struct.c
53993 +++ b/fs/fs_struct.c
53994 @@ -4,6 +4,7 @@
53995 #include <linux/path.h>
53996 #include <linux/slab.h>
53997 #include <linux/fs_struct.h>
53998 +#include <linux/grsecurity.h>
53999 #include "internal.h"
54000
54001 /*
54002 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
54003 write_seqcount_begin(&fs->seq);
54004 old_root = fs->root;
54005 fs->root = *path;
54006 + gr_set_chroot_entries(current, path);
54007 write_seqcount_end(&fs->seq);
54008 spin_unlock(&fs->lock);
54009 if (old_root.dentry)
54010 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
54011 int hits = 0;
54012 spin_lock(&fs->lock);
54013 write_seqcount_begin(&fs->seq);
54014 + /* this root replacement is only done by pivot_root,
54015 + leave grsec's chroot tagging alone for this task
54016 + so that a pivoted root isn't treated as a chroot
54017 + */
54018 hits += replace_path(&fs->root, old_root, new_root);
54019 hits += replace_path(&fs->pwd, old_root, new_root);
54020 write_seqcount_end(&fs->seq);
54021 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
54022 task_lock(tsk);
54023 spin_lock(&fs->lock);
54024 tsk->fs = NULL;
54025 - kill = !--fs->users;
54026 + gr_clear_chroot_entries(tsk);
54027 + kill = !atomic_dec_return(&fs->users);
54028 spin_unlock(&fs->lock);
54029 task_unlock(tsk);
54030 if (kill)
54031 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
54032 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
54033 /* We don't need to lock fs - think why ;-) */
54034 if (fs) {
54035 - fs->users = 1;
54036 + atomic_set(&fs->users, 1);
54037 fs->in_exec = 0;
54038 spin_lock_init(&fs->lock);
54039 seqcount_init(&fs->seq);
54040 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
54041 spin_lock(&old->lock);
54042 fs->root = old->root;
54043 path_get(&fs->root);
54044 + /* instead of calling gr_set_chroot_entries here,
54045 + we call it from every caller of this function
54046 + */
54047 fs->pwd = old->pwd;
54048 path_get(&fs->pwd);
54049 spin_unlock(&old->lock);
54050 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
54051
54052 task_lock(current);
54053 spin_lock(&fs->lock);
54054 - kill = !--fs->users;
54055 + kill = !atomic_dec_return(&fs->users);
54056 current->fs = new_fs;
54057 + gr_set_chroot_entries(current, &new_fs->root);
54058 spin_unlock(&fs->lock);
54059 task_unlock(current);
54060
54061 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
54062
54063 int current_umask(void)
54064 {
54065 - return current->fs->umask;
54066 + return current->fs->umask | gr_acl_umask();
54067 }
54068 EXPORT_SYMBOL(current_umask);
54069
54070 /* to be mentioned only in INIT_TASK */
54071 struct fs_struct init_fs = {
54072 - .users = 1,
54073 + .users = ATOMIC_INIT(1),
54074 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
54075 .seq = SEQCNT_ZERO,
54076 .umask = 0022,
54077 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
54078 index e2cba1f..17a25bb 100644
54079 --- a/fs/fscache/cookie.c
54080 +++ b/fs/fscache/cookie.c
54081 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
54082 parent ? (char *) parent->def->name : "<no-parent>",
54083 def->name, netfs_data);
54084
54085 - fscache_stat(&fscache_n_acquires);
54086 + fscache_stat_unchecked(&fscache_n_acquires);
54087
54088 /* if there's no parent cookie, then we don't create one here either */
54089 if (!parent) {
54090 - fscache_stat(&fscache_n_acquires_null);
54091 + fscache_stat_unchecked(&fscache_n_acquires_null);
54092 _leave(" [no parent]");
54093 return NULL;
54094 }
54095 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
54096 /* allocate and initialise a cookie */
54097 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
54098 if (!cookie) {
54099 - fscache_stat(&fscache_n_acquires_oom);
54100 + fscache_stat_unchecked(&fscache_n_acquires_oom);
54101 _leave(" [ENOMEM]");
54102 return NULL;
54103 }
54104 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
54105
54106 switch (cookie->def->type) {
54107 case FSCACHE_COOKIE_TYPE_INDEX:
54108 - fscache_stat(&fscache_n_cookie_index);
54109 + fscache_stat_unchecked(&fscache_n_cookie_index);
54110 break;
54111 case FSCACHE_COOKIE_TYPE_DATAFILE:
54112 - fscache_stat(&fscache_n_cookie_data);
54113 + fscache_stat_unchecked(&fscache_n_cookie_data);
54114 break;
54115 default:
54116 - fscache_stat(&fscache_n_cookie_special);
54117 + fscache_stat_unchecked(&fscache_n_cookie_special);
54118 break;
54119 }
54120
54121 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
54122 if (fscache_acquire_non_index_cookie(cookie) < 0) {
54123 atomic_dec(&parent->n_children);
54124 __fscache_cookie_put(cookie);
54125 - fscache_stat(&fscache_n_acquires_nobufs);
54126 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
54127 _leave(" = NULL");
54128 return NULL;
54129 }
54130 }
54131
54132 - fscache_stat(&fscache_n_acquires_ok);
54133 + fscache_stat_unchecked(&fscache_n_acquires_ok);
54134 _leave(" = %p", cookie);
54135 return cookie;
54136 }
54137 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
54138 cache = fscache_select_cache_for_object(cookie->parent);
54139 if (!cache) {
54140 up_read(&fscache_addremove_sem);
54141 - fscache_stat(&fscache_n_acquires_no_cache);
54142 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
54143 _leave(" = -ENOMEDIUM [no cache]");
54144 return -ENOMEDIUM;
54145 }
54146 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
54147 object = cache->ops->alloc_object(cache, cookie);
54148 fscache_stat_d(&fscache_n_cop_alloc_object);
54149 if (IS_ERR(object)) {
54150 - fscache_stat(&fscache_n_object_no_alloc);
54151 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
54152 ret = PTR_ERR(object);
54153 goto error;
54154 }
54155
54156 - fscache_stat(&fscache_n_object_alloc);
54157 + fscache_stat_unchecked(&fscache_n_object_alloc);
54158
54159 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
54160
54161 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
54162
54163 _enter("{%s}", cookie->def->name);
54164
54165 - fscache_stat(&fscache_n_invalidates);
54166 + fscache_stat_unchecked(&fscache_n_invalidates);
54167
54168 /* Only permit invalidation of data files. Invalidating an index will
54169 * require the caller to release all its attachments to the tree rooted
54170 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
54171 {
54172 struct fscache_object *object;
54173
54174 - fscache_stat(&fscache_n_updates);
54175 + fscache_stat_unchecked(&fscache_n_updates);
54176
54177 if (!cookie) {
54178 - fscache_stat(&fscache_n_updates_null);
54179 + fscache_stat_unchecked(&fscache_n_updates_null);
54180 _leave(" [no cookie]");
54181 return;
54182 }
54183 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
54184 struct fscache_object *object;
54185 unsigned long event;
54186
54187 - fscache_stat(&fscache_n_relinquishes);
54188 + fscache_stat_unchecked(&fscache_n_relinquishes);
54189 if (retire)
54190 - fscache_stat(&fscache_n_relinquishes_retire);
54191 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
54192
54193 if (!cookie) {
54194 - fscache_stat(&fscache_n_relinquishes_null);
54195 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
54196 _leave(" [no cookie]");
54197 return;
54198 }
54199 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
54200
54201 /* wait for the cookie to finish being instantiated (or to fail) */
54202 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
54203 - fscache_stat(&fscache_n_relinquishes_waitcrt);
54204 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
54205 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
54206 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
54207 }
54208 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
54209 index ee38fef..0a326d4 100644
54210 --- a/fs/fscache/internal.h
54211 +++ b/fs/fscache/internal.h
54212 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
54213 * stats.c
54214 */
54215 #ifdef CONFIG_FSCACHE_STATS
54216 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
54217 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
54218 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
54219 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
54220
54221 -extern atomic_t fscache_n_op_pend;
54222 -extern atomic_t fscache_n_op_run;
54223 -extern atomic_t fscache_n_op_enqueue;
54224 -extern atomic_t fscache_n_op_deferred_release;
54225 -extern atomic_t fscache_n_op_release;
54226 -extern atomic_t fscache_n_op_gc;
54227 -extern atomic_t fscache_n_op_cancelled;
54228 -extern atomic_t fscache_n_op_rejected;
54229 +extern atomic_unchecked_t fscache_n_op_pend;
54230 +extern atomic_unchecked_t fscache_n_op_run;
54231 +extern atomic_unchecked_t fscache_n_op_enqueue;
54232 +extern atomic_unchecked_t fscache_n_op_deferred_release;
54233 +extern atomic_unchecked_t fscache_n_op_release;
54234 +extern atomic_unchecked_t fscache_n_op_gc;
54235 +extern atomic_unchecked_t fscache_n_op_cancelled;
54236 +extern atomic_unchecked_t fscache_n_op_rejected;
54237
54238 -extern atomic_t fscache_n_attr_changed;
54239 -extern atomic_t fscache_n_attr_changed_ok;
54240 -extern atomic_t fscache_n_attr_changed_nobufs;
54241 -extern atomic_t fscache_n_attr_changed_nomem;
54242 -extern atomic_t fscache_n_attr_changed_calls;
54243 +extern atomic_unchecked_t fscache_n_attr_changed;
54244 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
54245 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
54246 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
54247 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
54248
54249 -extern atomic_t fscache_n_allocs;
54250 -extern atomic_t fscache_n_allocs_ok;
54251 -extern atomic_t fscache_n_allocs_wait;
54252 -extern atomic_t fscache_n_allocs_nobufs;
54253 -extern atomic_t fscache_n_allocs_intr;
54254 -extern atomic_t fscache_n_allocs_object_dead;
54255 -extern atomic_t fscache_n_alloc_ops;
54256 -extern atomic_t fscache_n_alloc_op_waits;
54257 +extern atomic_unchecked_t fscache_n_allocs;
54258 +extern atomic_unchecked_t fscache_n_allocs_ok;
54259 +extern atomic_unchecked_t fscache_n_allocs_wait;
54260 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
54261 +extern atomic_unchecked_t fscache_n_allocs_intr;
54262 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
54263 +extern atomic_unchecked_t fscache_n_alloc_ops;
54264 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
54265
54266 -extern atomic_t fscache_n_retrievals;
54267 -extern atomic_t fscache_n_retrievals_ok;
54268 -extern atomic_t fscache_n_retrievals_wait;
54269 -extern atomic_t fscache_n_retrievals_nodata;
54270 -extern atomic_t fscache_n_retrievals_nobufs;
54271 -extern atomic_t fscache_n_retrievals_intr;
54272 -extern atomic_t fscache_n_retrievals_nomem;
54273 -extern atomic_t fscache_n_retrievals_object_dead;
54274 -extern atomic_t fscache_n_retrieval_ops;
54275 -extern atomic_t fscache_n_retrieval_op_waits;
54276 +extern atomic_unchecked_t fscache_n_retrievals;
54277 +extern atomic_unchecked_t fscache_n_retrievals_ok;
54278 +extern atomic_unchecked_t fscache_n_retrievals_wait;
54279 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
54280 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
54281 +extern atomic_unchecked_t fscache_n_retrievals_intr;
54282 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
54283 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
54284 +extern atomic_unchecked_t fscache_n_retrieval_ops;
54285 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
54286
54287 -extern atomic_t fscache_n_stores;
54288 -extern atomic_t fscache_n_stores_ok;
54289 -extern atomic_t fscache_n_stores_again;
54290 -extern atomic_t fscache_n_stores_nobufs;
54291 -extern atomic_t fscache_n_stores_oom;
54292 -extern atomic_t fscache_n_store_ops;
54293 -extern atomic_t fscache_n_store_calls;
54294 -extern atomic_t fscache_n_store_pages;
54295 -extern atomic_t fscache_n_store_radix_deletes;
54296 -extern atomic_t fscache_n_store_pages_over_limit;
54297 +extern atomic_unchecked_t fscache_n_stores;
54298 +extern atomic_unchecked_t fscache_n_stores_ok;
54299 +extern atomic_unchecked_t fscache_n_stores_again;
54300 +extern atomic_unchecked_t fscache_n_stores_nobufs;
54301 +extern atomic_unchecked_t fscache_n_stores_oom;
54302 +extern atomic_unchecked_t fscache_n_store_ops;
54303 +extern atomic_unchecked_t fscache_n_store_calls;
54304 +extern atomic_unchecked_t fscache_n_store_pages;
54305 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
54306 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
54307
54308 -extern atomic_t fscache_n_store_vmscan_not_storing;
54309 -extern atomic_t fscache_n_store_vmscan_gone;
54310 -extern atomic_t fscache_n_store_vmscan_busy;
54311 -extern atomic_t fscache_n_store_vmscan_cancelled;
54312 -extern atomic_t fscache_n_store_vmscan_wait;
54313 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
54314 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
54315 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
54316 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
54317 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
54318
54319 -extern atomic_t fscache_n_marks;
54320 -extern atomic_t fscache_n_uncaches;
54321 +extern atomic_unchecked_t fscache_n_marks;
54322 +extern atomic_unchecked_t fscache_n_uncaches;
54323
54324 -extern atomic_t fscache_n_acquires;
54325 -extern atomic_t fscache_n_acquires_null;
54326 -extern atomic_t fscache_n_acquires_no_cache;
54327 -extern atomic_t fscache_n_acquires_ok;
54328 -extern atomic_t fscache_n_acquires_nobufs;
54329 -extern atomic_t fscache_n_acquires_oom;
54330 +extern atomic_unchecked_t fscache_n_acquires;
54331 +extern atomic_unchecked_t fscache_n_acquires_null;
54332 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
54333 +extern atomic_unchecked_t fscache_n_acquires_ok;
54334 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
54335 +extern atomic_unchecked_t fscache_n_acquires_oom;
54336
54337 -extern atomic_t fscache_n_invalidates;
54338 -extern atomic_t fscache_n_invalidates_run;
54339 +extern atomic_unchecked_t fscache_n_invalidates;
54340 +extern atomic_unchecked_t fscache_n_invalidates_run;
54341
54342 -extern atomic_t fscache_n_updates;
54343 -extern atomic_t fscache_n_updates_null;
54344 -extern atomic_t fscache_n_updates_run;
54345 +extern atomic_unchecked_t fscache_n_updates;
54346 +extern atomic_unchecked_t fscache_n_updates_null;
54347 +extern atomic_unchecked_t fscache_n_updates_run;
54348
54349 -extern atomic_t fscache_n_relinquishes;
54350 -extern atomic_t fscache_n_relinquishes_null;
54351 -extern atomic_t fscache_n_relinquishes_waitcrt;
54352 -extern atomic_t fscache_n_relinquishes_retire;
54353 +extern atomic_unchecked_t fscache_n_relinquishes;
54354 +extern atomic_unchecked_t fscache_n_relinquishes_null;
54355 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
54356 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
54357
54358 -extern atomic_t fscache_n_cookie_index;
54359 -extern atomic_t fscache_n_cookie_data;
54360 -extern atomic_t fscache_n_cookie_special;
54361 +extern atomic_unchecked_t fscache_n_cookie_index;
54362 +extern atomic_unchecked_t fscache_n_cookie_data;
54363 +extern atomic_unchecked_t fscache_n_cookie_special;
54364
54365 -extern atomic_t fscache_n_object_alloc;
54366 -extern atomic_t fscache_n_object_no_alloc;
54367 -extern atomic_t fscache_n_object_lookups;
54368 -extern atomic_t fscache_n_object_lookups_negative;
54369 -extern atomic_t fscache_n_object_lookups_positive;
54370 -extern atomic_t fscache_n_object_lookups_timed_out;
54371 -extern atomic_t fscache_n_object_created;
54372 -extern atomic_t fscache_n_object_avail;
54373 -extern atomic_t fscache_n_object_dead;
54374 +extern atomic_unchecked_t fscache_n_object_alloc;
54375 +extern atomic_unchecked_t fscache_n_object_no_alloc;
54376 +extern atomic_unchecked_t fscache_n_object_lookups;
54377 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
54378 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
54379 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
54380 +extern atomic_unchecked_t fscache_n_object_created;
54381 +extern atomic_unchecked_t fscache_n_object_avail;
54382 +extern atomic_unchecked_t fscache_n_object_dead;
54383
54384 -extern atomic_t fscache_n_checkaux_none;
54385 -extern atomic_t fscache_n_checkaux_okay;
54386 -extern atomic_t fscache_n_checkaux_update;
54387 -extern atomic_t fscache_n_checkaux_obsolete;
54388 +extern atomic_unchecked_t fscache_n_checkaux_none;
54389 +extern atomic_unchecked_t fscache_n_checkaux_okay;
54390 +extern atomic_unchecked_t fscache_n_checkaux_update;
54391 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
54392
54393 extern atomic_t fscache_n_cop_alloc_object;
54394 extern atomic_t fscache_n_cop_lookup_object;
54395 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
54396 atomic_inc(stat);
54397 }
54398
54399 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
54400 +{
54401 + atomic_inc_unchecked(stat);
54402 +}
54403 +
54404 static inline void fscache_stat_d(atomic_t *stat)
54405 {
54406 atomic_dec(stat);
54407 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
54408
54409 #define __fscache_stat(stat) (NULL)
54410 #define fscache_stat(stat) do {} while (0)
54411 +#define fscache_stat_unchecked(stat) do {} while (0)
54412 #define fscache_stat_d(stat) do {} while (0)
54413 #endif
54414
54415 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
54416 index 50d41c1..10ee117 100644
54417 --- a/fs/fscache/object.c
54418 +++ b/fs/fscache/object.c
54419 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
54420 /* Invalidate an object on disk */
54421 case FSCACHE_OBJECT_INVALIDATING:
54422 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
54423 - fscache_stat(&fscache_n_invalidates_run);
54424 + fscache_stat_unchecked(&fscache_n_invalidates_run);
54425 fscache_stat(&fscache_n_cop_invalidate_object);
54426 fscache_invalidate_object(object);
54427 fscache_stat_d(&fscache_n_cop_invalidate_object);
54428 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
54429 /* update the object metadata on disk */
54430 case FSCACHE_OBJECT_UPDATING:
54431 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
54432 - fscache_stat(&fscache_n_updates_run);
54433 + fscache_stat_unchecked(&fscache_n_updates_run);
54434 fscache_stat(&fscache_n_cop_update_object);
54435 object->cache->ops->update_object(object);
54436 fscache_stat_d(&fscache_n_cop_update_object);
54437 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
54438 spin_lock(&object->lock);
54439 object->state = FSCACHE_OBJECT_DEAD;
54440 spin_unlock(&object->lock);
54441 - fscache_stat(&fscache_n_object_dead);
54442 + fscache_stat_unchecked(&fscache_n_object_dead);
54443 goto terminal_transit;
54444
54445 /* handle the parent cache of this object being withdrawn from
54446 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
54447 spin_lock(&object->lock);
54448 object->state = FSCACHE_OBJECT_DEAD;
54449 spin_unlock(&object->lock);
54450 - fscache_stat(&fscache_n_object_dead);
54451 + fscache_stat_unchecked(&fscache_n_object_dead);
54452 goto terminal_transit;
54453
54454 /* complain about the object being woken up once it is
54455 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
54456 parent->cookie->def->name, cookie->def->name,
54457 object->cache->tag->name);
54458
54459 - fscache_stat(&fscache_n_object_lookups);
54460 + fscache_stat_unchecked(&fscache_n_object_lookups);
54461 fscache_stat(&fscache_n_cop_lookup_object);
54462 ret = object->cache->ops->lookup_object(object);
54463 fscache_stat_d(&fscache_n_cop_lookup_object);
54464 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
54465 if (ret == -ETIMEDOUT) {
54466 /* probably stuck behind another object, so move this one to
54467 * the back of the queue */
54468 - fscache_stat(&fscache_n_object_lookups_timed_out);
54469 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
54470 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
54471 }
54472
54473 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
54474
54475 spin_lock(&object->lock);
54476 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
54477 - fscache_stat(&fscache_n_object_lookups_negative);
54478 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
54479
54480 /* transit here to allow write requests to begin stacking up
54481 * and read requests to begin returning ENODATA */
54482 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
54483 * result, in which case there may be data available */
54484 spin_lock(&object->lock);
54485 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
54486 - fscache_stat(&fscache_n_object_lookups_positive);
54487 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
54488
54489 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
54490
54491 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
54492 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
54493 } else {
54494 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
54495 - fscache_stat(&fscache_n_object_created);
54496 + fscache_stat_unchecked(&fscache_n_object_created);
54497
54498 object->state = FSCACHE_OBJECT_AVAILABLE;
54499 spin_unlock(&object->lock);
54500 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
54501 fscache_enqueue_dependents(object);
54502
54503 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
54504 - fscache_stat(&fscache_n_object_avail);
54505 + fscache_stat_unchecked(&fscache_n_object_avail);
54506
54507 _leave("");
54508 }
54509 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
54510 enum fscache_checkaux result;
54511
54512 if (!object->cookie->def->check_aux) {
54513 - fscache_stat(&fscache_n_checkaux_none);
54514 + fscache_stat_unchecked(&fscache_n_checkaux_none);
54515 return FSCACHE_CHECKAUX_OKAY;
54516 }
54517
54518 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
54519 switch (result) {
54520 /* entry okay as is */
54521 case FSCACHE_CHECKAUX_OKAY:
54522 - fscache_stat(&fscache_n_checkaux_okay);
54523 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
54524 break;
54525
54526 /* entry requires update */
54527 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
54528 - fscache_stat(&fscache_n_checkaux_update);
54529 + fscache_stat_unchecked(&fscache_n_checkaux_update);
54530 break;
54531
54532 /* entry requires deletion */
54533 case FSCACHE_CHECKAUX_OBSOLETE:
54534 - fscache_stat(&fscache_n_checkaux_obsolete);
54535 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
54536 break;
54537
54538 default:
54539 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
54540 index 762a9ec..2023284 100644
54541 --- a/fs/fscache/operation.c
54542 +++ b/fs/fscache/operation.c
54543 @@ -17,7 +17,7 @@
54544 #include <linux/slab.h>
54545 #include "internal.h"
54546
54547 -atomic_t fscache_op_debug_id;
54548 +atomic_unchecked_t fscache_op_debug_id;
54549 EXPORT_SYMBOL(fscache_op_debug_id);
54550
54551 /**
54552 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
54553 ASSERTCMP(atomic_read(&op->usage), >, 0);
54554 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
54555
54556 - fscache_stat(&fscache_n_op_enqueue);
54557 + fscache_stat_unchecked(&fscache_n_op_enqueue);
54558 switch (op->flags & FSCACHE_OP_TYPE) {
54559 case FSCACHE_OP_ASYNC:
54560 _debug("queue async");
54561 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
54562 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
54563 if (op->processor)
54564 fscache_enqueue_operation(op);
54565 - fscache_stat(&fscache_n_op_run);
54566 + fscache_stat_unchecked(&fscache_n_op_run);
54567 }
54568
54569 /*
54570 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
54571 if (object->n_in_progress > 0) {
54572 atomic_inc(&op->usage);
54573 list_add_tail(&op->pend_link, &object->pending_ops);
54574 - fscache_stat(&fscache_n_op_pend);
54575 + fscache_stat_unchecked(&fscache_n_op_pend);
54576 } else if (!list_empty(&object->pending_ops)) {
54577 atomic_inc(&op->usage);
54578 list_add_tail(&op->pend_link, &object->pending_ops);
54579 - fscache_stat(&fscache_n_op_pend);
54580 + fscache_stat_unchecked(&fscache_n_op_pend);
54581 fscache_start_operations(object);
54582 } else {
54583 ASSERTCMP(object->n_in_progress, ==, 0);
54584 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
54585 object->n_exclusive++; /* reads and writes must wait */
54586 atomic_inc(&op->usage);
54587 list_add_tail(&op->pend_link, &object->pending_ops);
54588 - fscache_stat(&fscache_n_op_pend);
54589 + fscache_stat_unchecked(&fscache_n_op_pend);
54590 ret = 0;
54591 } else {
54592 /* If we're in any other state, there must have been an I/O
54593 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
54594 if (object->n_exclusive > 0) {
54595 atomic_inc(&op->usage);
54596 list_add_tail(&op->pend_link, &object->pending_ops);
54597 - fscache_stat(&fscache_n_op_pend);
54598 + fscache_stat_unchecked(&fscache_n_op_pend);
54599 } else if (!list_empty(&object->pending_ops)) {
54600 atomic_inc(&op->usage);
54601 list_add_tail(&op->pend_link, &object->pending_ops);
54602 - fscache_stat(&fscache_n_op_pend);
54603 + fscache_stat_unchecked(&fscache_n_op_pend);
54604 fscache_start_operations(object);
54605 } else {
54606 ASSERTCMP(object->n_exclusive, ==, 0);
54607 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
54608 object->n_ops++;
54609 atomic_inc(&op->usage);
54610 list_add_tail(&op->pend_link, &object->pending_ops);
54611 - fscache_stat(&fscache_n_op_pend);
54612 + fscache_stat_unchecked(&fscache_n_op_pend);
54613 ret = 0;
54614 } else if (object->state == FSCACHE_OBJECT_DYING ||
54615 object->state == FSCACHE_OBJECT_LC_DYING ||
54616 object->state == FSCACHE_OBJECT_WITHDRAWING) {
54617 - fscache_stat(&fscache_n_op_rejected);
54618 + fscache_stat_unchecked(&fscache_n_op_rejected);
54619 op->state = FSCACHE_OP_ST_CANCELLED;
54620 ret = -ENOBUFS;
54621 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
54622 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
54623 ret = -EBUSY;
54624 if (op->state == FSCACHE_OP_ST_PENDING) {
54625 ASSERT(!list_empty(&op->pend_link));
54626 - fscache_stat(&fscache_n_op_cancelled);
54627 + fscache_stat_unchecked(&fscache_n_op_cancelled);
54628 list_del_init(&op->pend_link);
54629 if (do_cancel)
54630 do_cancel(op);
54631 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
54632 while (!list_empty(&object->pending_ops)) {
54633 op = list_entry(object->pending_ops.next,
54634 struct fscache_operation, pend_link);
54635 - fscache_stat(&fscache_n_op_cancelled);
54636 + fscache_stat_unchecked(&fscache_n_op_cancelled);
54637 list_del_init(&op->pend_link);
54638
54639 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
54640 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
54641 op->state, ==, FSCACHE_OP_ST_CANCELLED);
54642 op->state = FSCACHE_OP_ST_DEAD;
54643
54644 - fscache_stat(&fscache_n_op_release);
54645 + fscache_stat_unchecked(&fscache_n_op_release);
54646
54647 if (op->release) {
54648 op->release(op);
54649 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
54650 * lock, and defer it otherwise */
54651 if (!spin_trylock(&object->lock)) {
54652 _debug("defer put");
54653 - fscache_stat(&fscache_n_op_deferred_release);
54654 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
54655
54656 cache = object->cache;
54657 spin_lock(&cache->op_gc_list_lock);
54658 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
54659
54660 _debug("GC DEFERRED REL OBJ%x OP%x",
54661 object->debug_id, op->debug_id);
54662 - fscache_stat(&fscache_n_op_gc);
54663 + fscache_stat_unchecked(&fscache_n_op_gc);
54664
54665 ASSERTCMP(atomic_read(&op->usage), ==, 0);
54666 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
54667 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
54668 index ff000e5..c44ec6d 100644
54669 --- a/fs/fscache/page.c
54670 +++ b/fs/fscache/page.c
54671 @@ -61,7 +61,7 @@ try_again:
54672 val = radix_tree_lookup(&cookie->stores, page->index);
54673 if (!val) {
54674 rcu_read_unlock();
54675 - fscache_stat(&fscache_n_store_vmscan_not_storing);
54676 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
54677 __fscache_uncache_page(cookie, page);
54678 return true;
54679 }
54680 @@ -91,11 +91,11 @@ try_again:
54681 spin_unlock(&cookie->stores_lock);
54682
54683 if (xpage) {
54684 - fscache_stat(&fscache_n_store_vmscan_cancelled);
54685 - fscache_stat(&fscache_n_store_radix_deletes);
54686 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
54687 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
54688 ASSERTCMP(xpage, ==, page);
54689 } else {
54690 - fscache_stat(&fscache_n_store_vmscan_gone);
54691 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
54692 }
54693
54694 wake_up_bit(&cookie->flags, 0);
54695 @@ -110,11 +110,11 @@ page_busy:
54696 * sleeping on memory allocation, so we may need to impose a timeout
54697 * too. */
54698 if (!(gfp & __GFP_WAIT)) {
54699 - fscache_stat(&fscache_n_store_vmscan_busy);
54700 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
54701 return false;
54702 }
54703
54704 - fscache_stat(&fscache_n_store_vmscan_wait);
54705 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
54706 __fscache_wait_on_page_write(cookie, page);
54707 gfp &= ~__GFP_WAIT;
54708 goto try_again;
54709 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
54710 FSCACHE_COOKIE_STORING_TAG);
54711 if (!radix_tree_tag_get(&cookie->stores, page->index,
54712 FSCACHE_COOKIE_PENDING_TAG)) {
54713 - fscache_stat(&fscache_n_store_radix_deletes);
54714 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
54715 xpage = radix_tree_delete(&cookie->stores, page->index);
54716 }
54717 spin_unlock(&cookie->stores_lock);
54718 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
54719
54720 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
54721
54722 - fscache_stat(&fscache_n_attr_changed_calls);
54723 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
54724
54725 if (fscache_object_is_active(object)) {
54726 fscache_stat(&fscache_n_cop_attr_changed);
54727 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
54728
54729 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
54730
54731 - fscache_stat(&fscache_n_attr_changed);
54732 + fscache_stat_unchecked(&fscache_n_attr_changed);
54733
54734 op = kzalloc(sizeof(*op), GFP_KERNEL);
54735 if (!op) {
54736 - fscache_stat(&fscache_n_attr_changed_nomem);
54737 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
54738 _leave(" = -ENOMEM");
54739 return -ENOMEM;
54740 }
54741 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
54742 if (fscache_submit_exclusive_op(object, op) < 0)
54743 goto nobufs;
54744 spin_unlock(&cookie->lock);
54745 - fscache_stat(&fscache_n_attr_changed_ok);
54746 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
54747 fscache_put_operation(op);
54748 _leave(" = 0");
54749 return 0;
54750 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
54751 nobufs:
54752 spin_unlock(&cookie->lock);
54753 kfree(op);
54754 - fscache_stat(&fscache_n_attr_changed_nobufs);
54755 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
54756 _leave(" = %d", -ENOBUFS);
54757 return -ENOBUFS;
54758 }
54759 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
54760 /* allocate a retrieval operation and attempt to submit it */
54761 op = kzalloc(sizeof(*op), GFP_NOIO);
54762 if (!op) {
54763 - fscache_stat(&fscache_n_retrievals_nomem);
54764 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
54765 return NULL;
54766 }
54767
54768 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
54769 return 0;
54770 }
54771
54772 - fscache_stat(&fscache_n_retrievals_wait);
54773 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
54774
54775 jif = jiffies;
54776 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
54777 fscache_wait_bit_interruptible,
54778 TASK_INTERRUPTIBLE) != 0) {
54779 - fscache_stat(&fscache_n_retrievals_intr);
54780 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
54781 _leave(" = -ERESTARTSYS");
54782 return -ERESTARTSYS;
54783 }
54784 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
54785 */
54786 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
54787 struct fscache_retrieval *op,
54788 - atomic_t *stat_op_waits,
54789 - atomic_t *stat_object_dead)
54790 + atomic_unchecked_t *stat_op_waits,
54791 + atomic_unchecked_t *stat_object_dead)
54792 {
54793 int ret;
54794
54795 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
54796 goto check_if_dead;
54797
54798 _debug(">>> WT");
54799 - fscache_stat(stat_op_waits);
54800 + fscache_stat_unchecked(stat_op_waits);
54801 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
54802 fscache_wait_bit_interruptible,
54803 TASK_INTERRUPTIBLE) != 0) {
54804 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
54805
54806 check_if_dead:
54807 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
54808 - fscache_stat(stat_object_dead);
54809 + fscache_stat_unchecked(stat_object_dead);
54810 _leave(" = -ENOBUFS [cancelled]");
54811 return -ENOBUFS;
54812 }
54813 if (unlikely(fscache_object_is_dead(object))) {
54814 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
54815 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
54816 - fscache_stat(stat_object_dead);
54817 + fscache_stat_unchecked(stat_object_dead);
54818 return -ENOBUFS;
54819 }
54820 return 0;
54821 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
54822
54823 _enter("%p,%p,,,", cookie, page);
54824
54825 - fscache_stat(&fscache_n_retrievals);
54826 + fscache_stat_unchecked(&fscache_n_retrievals);
54827
54828 if (hlist_empty(&cookie->backing_objects))
54829 goto nobufs;
54830 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
54831 goto nobufs_unlock_dec;
54832 spin_unlock(&cookie->lock);
54833
54834 - fscache_stat(&fscache_n_retrieval_ops);
54835 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
54836
54837 /* pin the netfs read context in case we need to do the actual netfs
54838 * read because we've encountered a cache read failure */
54839 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
54840
54841 error:
54842 if (ret == -ENOMEM)
54843 - fscache_stat(&fscache_n_retrievals_nomem);
54844 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
54845 else if (ret == -ERESTARTSYS)
54846 - fscache_stat(&fscache_n_retrievals_intr);
54847 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
54848 else if (ret == -ENODATA)
54849 - fscache_stat(&fscache_n_retrievals_nodata);
54850 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
54851 else if (ret < 0)
54852 - fscache_stat(&fscache_n_retrievals_nobufs);
54853 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
54854 else
54855 - fscache_stat(&fscache_n_retrievals_ok);
54856 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
54857
54858 fscache_put_retrieval(op);
54859 _leave(" = %d", ret);
54860 @@ -467,7 +467,7 @@ nobufs_unlock:
54861 spin_unlock(&cookie->lock);
54862 kfree(op);
54863 nobufs:
54864 - fscache_stat(&fscache_n_retrievals_nobufs);
54865 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
54866 _leave(" = -ENOBUFS");
54867 return -ENOBUFS;
54868 }
54869 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
54870
54871 _enter("%p,,%d,,,", cookie, *nr_pages);
54872
54873 - fscache_stat(&fscache_n_retrievals);
54874 + fscache_stat_unchecked(&fscache_n_retrievals);
54875
54876 if (hlist_empty(&cookie->backing_objects))
54877 goto nobufs;
54878 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
54879 goto nobufs_unlock_dec;
54880 spin_unlock(&cookie->lock);
54881
54882 - fscache_stat(&fscache_n_retrieval_ops);
54883 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
54884
54885 /* pin the netfs read context in case we need to do the actual netfs
54886 * read because we've encountered a cache read failure */
54887 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
54888
54889 error:
54890 if (ret == -ENOMEM)
54891 - fscache_stat(&fscache_n_retrievals_nomem);
54892 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
54893 else if (ret == -ERESTARTSYS)
54894 - fscache_stat(&fscache_n_retrievals_intr);
54895 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
54896 else if (ret == -ENODATA)
54897 - fscache_stat(&fscache_n_retrievals_nodata);
54898 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
54899 else if (ret < 0)
54900 - fscache_stat(&fscache_n_retrievals_nobufs);
54901 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
54902 else
54903 - fscache_stat(&fscache_n_retrievals_ok);
54904 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
54905
54906 fscache_put_retrieval(op);
54907 _leave(" = %d", ret);
54908 @@ -591,7 +591,7 @@ nobufs_unlock:
54909 spin_unlock(&cookie->lock);
54910 kfree(op);
54911 nobufs:
54912 - fscache_stat(&fscache_n_retrievals_nobufs);
54913 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
54914 _leave(" = -ENOBUFS");
54915 return -ENOBUFS;
54916 }
54917 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
54918
54919 _enter("%p,%p,,,", cookie, page);
54920
54921 - fscache_stat(&fscache_n_allocs);
54922 + fscache_stat_unchecked(&fscache_n_allocs);
54923
54924 if (hlist_empty(&cookie->backing_objects))
54925 goto nobufs;
54926 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
54927 goto nobufs_unlock;
54928 spin_unlock(&cookie->lock);
54929
54930 - fscache_stat(&fscache_n_alloc_ops);
54931 + fscache_stat_unchecked(&fscache_n_alloc_ops);
54932
54933 ret = fscache_wait_for_retrieval_activation(
54934 object, op,
54935 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
54936
54937 error:
54938 if (ret == -ERESTARTSYS)
54939 - fscache_stat(&fscache_n_allocs_intr);
54940 + fscache_stat_unchecked(&fscache_n_allocs_intr);
54941 else if (ret < 0)
54942 - fscache_stat(&fscache_n_allocs_nobufs);
54943 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
54944 else
54945 - fscache_stat(&fscache_n_allocs_ok);
54946 + fscache_stat_unchecked(&fscache_n_allocs_ok);
54947
54948 fscache_put_retrieval(op);
54949 _leave(" = %d", ret);
54950 @@ -677,7 +677,7 @@ nobufs_unlock:
54951 spin_unlock(&cookie->lock);
54952 kfree(op);
54953 nobufs:
54954 - fscache_stat(&fscache_n_allocs_nobufs);
54955 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
54956 _leave(" = -ENOBUFS");
54957 return -ENOBUFS;
54958 }
54959 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
54960
54961 spin_lock(&cookie->stores_lock);
54962
54963 - fscache_stat(&fscache_n_store_calls);
54964 + fscache_stat_unchecked(&fscache_n_store_calls);
54965
54966 /* find a page to store */
54967 page = NULL;
54968 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
54969 page = results[0];
54970 _debug("gang %d [%lx]", n, page->index);
54971 if (page->index > op->store_limit) {
54972 - fscache_stat(&fscache_n_store_pages_over_limit);
54973 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
54974 goto superseded;
54975 }
54976
54977 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
54978 spin_unlock(&cookie->stores_lock);
54979 spin_unlock(&object->lock);
54980
54981 - fscache_stat(&fscache_n_store_pages);
54982 + fscache_stat_unchecked(&fscache_n_store_pages);
54983 fscache_stat(&fscache_n_cop_write_page);
54984 ret = object->cache->ops->write_page(op, page);
54985 fscache_stat_d(&fscache_n_cop_write_page);
54986 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
54987 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
54988 ASSERT(PageFsCache(page));
54989
54990 - fscache_stat(&fscache_n_stores);
54991 + fscache_stat_unchecked(&fscache_n_stores);
54992
54993 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
54994 _leave(" = -ENOBUFS [invalidating]");
54995 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
54996 spin_unlock(&cookie->stores_lock);
54997 spin_unlock(&object->lock);
54998
54999 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
55000 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
55001 op->store_limit = object->store_limit;
55002
55003 if (fscache_submit_op(object, &op->op) < 0)
55004 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
55005
55006 spin_unlock(&cookie->lock);
55007 radix_tree_preload_end();
55008 - fscache_stat(&fscache_n_store_ops);
55009 - fscache_stat(&fscache_n_stores_ok);
55010 + fscache_stat_unchecked(&fscache_n_store_ops);
55011 + fscache_stat_unchecked(&fscache_n_stores_ok);
55012
55013 /* the work queue now carries its own ref on the object */
55014 fscache_put_operation(&op->op);
55015 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
55016 return 0;
55017
55018 already_queued:
55019 - fscache_stat(&fscache_n_stores_again);
55020 + fscache_stat_unchecked(&fscache_n_stores_again);
55021 already_pending:
55022 spin_unlock(&cookie->stores_lock);
55023 spin_unlock(&object->lock);
55024 spin_unlock(&cookie->lock);
55025 radix_tree_preload_end();
55026 kfree(op);
55027 - fscache_stat(&fscache_n_stores_ok);
55028 + fscache_stat_unchecked(&fscache_n_stores_ok);
55029 _leave(" = 0");
55030 return 0;
55031
55032 @@ -959,14 +959,14 @@ nobufs:
55033 spin_unlock(&cookie->lock);
55034 radix_tree_preload_end();
55035 kfree(op);
55036 - fscache_stat(&fscache_n_stores_nobufs);
55037 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
55038 _leave(" = -ENOBUFS");
55039 return -ENOBUFS;
55040
55041 nomem_free:
55042 kfree(op);
55043 nomem:
55044 - fscache_stat(&fscache_n_stores_oom);
55045 + fscache_stat_unchecked(&fscache_n_stores_oom);
55046 _leave(" = -ENOMEM");
55047 return -ENOMEM;
55048 }
55049 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
55050 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
55051 ASSERTCMP(page, !=, NULL);
55052
55053 - fscache_stat(&fscache_n_uncaches);
55054 + fscache_stat_unchecked(&fscache_n_uncaches);
55055
55056 /* cache withdrawal may beat us to it */
55057 if (!PageFsCache(page))
55058 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
55059 struct fscache_cookie *cookie = op->op.object->cookie;
55060
55061 #ifdef CONFIG_FSCACHE_STATS
55062 - atomic_inc(&fscache_n_marks);
55063 + atomic_inc_unchecked(&fscache_n_marks);
55064 #endif
55065
55066 _debug("- mark %p{%lx}", page, page->index);
55067 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
55068 index 40d13c7..ddf52b9 100644
55069 --- a/fs/fscache/stats.c
55070 +++ b/fs/fscache/stats.c
55071 @@ -18,99 +18,99 @@
55072 /*
55073 * operation counters
55074 */
55075 -atomic_t fscache_n_op_pend;
55076 -atomic_t fscache_n_op_run;
55077 -atomic_t fscache_n_op_enqueue;
55078 -atomic_t fscache_n_op_requeue;
55079 -atomic_t fscache_n_op_deferred_release;
55080 -atomic_t fscache_n_op_release;
55081 -atomic_t fscache_n_op_gc;
55082 -atomic_t fscache_n_op_cancelled;
55083 -atomic_t fscache_n_op_rejected;
55084 +atomic_unchecked_t fscache_n_op_pend;
55085 +atomic_unchecked_t fscache_n_op_run;
55086 +atomic_unchecked_t fscache_n_op_enqueue;
55087 +atomic_unchecked_t fscache_n_op_requeue;
55088 +atomic_unchecked_t fscache_n_op_deferred_release;
55089 +atomic_unchecked_t fscache_n_op_release;
55090 +atomic_unchecked_t fscache_n_op_gc;
55091 +atomic_unchecked_t fscache_n_op_cancelled;
55092 +atomic_unchecked_t fscache_n_op_rejected;
55093
55094 -atomic_t fscache_n_attr_changed;
55095 -atomic_t fscache_n_attr_changed_ok;
55096 -atomic_t fscache_n_attr_changed_nobufs;
55097 -atomic_t fscache_n_attr_changed_nomem;
55098 -atomic_t fscache_n_attr_changed_calls;
55099 +atomic_unchecked_t fscache_n_attr_changed;
55100 +atomic_unchecked_t fscache_n_attr_changed_ok;
55101 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
55102 +atomic_unchecked_t fscache_n_attr_changed_nomem;
55103 +atomic_unchecked_t fscache_n_attr_changed_calls;
55104
55105 -atomic_t fscache_n_allocs;
55106 -atomic_t fscache_n_allocs_ok;
55107 -atomic_t fscache_n_allocs_wait;
55108 -atomic_t fscache_n_allocs_nobufs;
55109 -atomic_t fscache_n_allocs_intr;
55110 -atomic_t fscache_n_allocs_object_dead;
55111 -atomic_t fscache_n_alloc_ops;
55112 -atomic_t fscache_n_alloc_op_waits;
55113 +atomic_unchecked_t fscache_n_allocs;
55114 +atomic_unchecked_t fscache_n_allocs_ok;
55115 +atomic_unchecked_t fscache_n_allocs_wait;
55116 +atomic_unchecked_t fscache_n_allocs_nobufs;
55117 +atomic_unchecked_t fscache_n_allocs_intr;
55118 +atomic_unchecked_t fscache_n_allocs_object_dead;
55119 +atomic_unchecked_t fscache_n_alloc_ops;
55120 +atomic_unchecked_t fscache_n_alloc_op_waits;
55121
55122 -atomic_t fscache_n_retrievals;
55123 -atomic_t fscache_n_retrievals_ok;
55124 -atomic_t fscache_n_retrievals_wait;
55125 -atomic_t fscache_n_retrievals_nodata;
55126 -atomic_t fscache_n_retrievals_nobufs;
55127 -atomic_t fscache_n_retrievals_intr;
55128 -atomic_t fscache_n_retrievals_nomem;
55129 -atomic_t fscache_n_retrievals_object_dead;
55130 -atomic_t fscache_n_retrieval_ops;
55131 -atomic_t fscache_n_retrieval_op_waits;
55132 +atomic_unchecked_t fscache_n_retrievals;
55133 +atomic_unchecked_t fscache_n_retrievals_ok;
55134 +atomic_unchecked_t fscache_n_retrievals_wait;
55135 +atomic_unchecked_t fscache_n_retrievals_nodata;
55136 +atomic_unchecked_t fscache_n_retrievals_nobufs;
55137 +atomic_unchecked_t fscache_n_retrievals_intr;
55138 +atomic_unchecked_t fscache_n_retrievals_nomem;
55139 +atomic_unchecked_t fscache_n_retrievals_object_dead;
55140 +atomic_unchecked_t fscache_n_retrieval_ops;
55141 +atomic_unchecked_t fscache_n_retrieval_op_waits;
55142
55143 -atomic_t fscache_n_stores;
55144 -atomic_t fscache_n_stores_ok;
55145 -atomic_t fscache_n_stores_again;
55146 -atomic_t fscache_n_stores_nobufs;
55147 -atomic_t fscache_n_stores_oom;
55148 -atomic_t fscache_n_store_ops;
55149 -atomic_t fscache_n_store_calls;
55150 -atomic_t fscache_n_store_pages;
55151 -atomic_t fscache_n_store_radix_deletes;
55152 -atomic_t fscache_n_store_pages_over_limit;
55153 +atomic_unchecked_t fscache_n_stores;
55154 +atomic_unchecked_t fscache_n_stores_ok;
55155 +atomic_unchecked_t fscache_n_stores_again;
55156 +atomic_unchecked_t fscache_n_stores_nobufs;
55157 +atomic_unchecked_t fscache_n_stores_oom;
55158 +atomic_unchecked_t fscache_n_store_ops;
55159 +atomic_unchecked_t fscache_n_store_calls;
55160 +atomic_unchecked_t fscache_n_store_pages;
55161 +atomic_unchecked_t fscache_n_store_radix_deletes;
55162 +atomic_unchecked_t fscache_n_store_pages_over_limit;
55163
55164 -atomic_t fscache_n_store_vmscan_not_storing;
55165 -atomic_t fscache_n_store_vmscan_gone;
55166 -atomic_t fscache_n_store_vmscan_busy;
55167 -atomic_t fscache_n_store_vmscan_cancelled;
55168 -atomic_t fscache_n_store_vmscan_wait;
55169 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
55170 +atomic_unchecked_t fscache_n_store_vmscan_gone;
55171 +atomic_unchecked_t fscache_n_store_vmscan_busy;
55172 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
55173 +atomic_unchecked_t fscache_n_store_vmscan_wait;
55174
55175 -atomic_t fscache_n_marks;
55176 -atomic_t fscache_n_uncaches;
55177 +atomic_unchecked_t fscache_n_marks;
55178 +atomic_unchecked_t fscache_n_uncaches;
55179
55180 -atomic_t fscache_n_acquires;
55181 -atomic_t fscache_n_acquires_null;
55182 -atomic_t fscache_n_acquires_no_cache;
55183 -atomic_t fscache_n_acquires_ok;
55184 -atomic_t fscache_n_acquires_nobufs;
55185 -atomic_t fscache_n_acquires_oom;
55186 +atomic_unchecked_t fscache_n_acquires;
55187 +atomic_unchecked_t fscache_n_acquires_null;
55188 +atomic_unchecked_t fscache_n_acquires_no_cache;
55189 +atomic_unchecked_t fscache_n_acquires_ok;
55190 +atomic_unchecked_t fscache_n_acquires_nobufs;
55191 +atomic_unchecked_t fscache_n_acquires_oom;
55192
55193 -atomic_t fscache_n_invalidates;
55194 -atomic_t fscache_n_invalidates_run;
55195 +atomic_unchecked_t fscache_n_invalidates;
55196 +atomic_unchecked_t fscache_n_invalidates_run;
55197
55198 -atomic_t fscache_n_updates;
55199 -atomic_t fscache_n_updates_null;
55200 -atomic_t fscache_n_updates_run;
55201 +atomic_unchecked_t fscache_n_updates;
55202 +atomic_unchecked_t fscache_n_updates_null;
55203 +atomic_unchecked_t fscache_n_updates_run;
55204
55205 -atomic_t fscache_n_relinquishes;
55206 -atomic_t fscache_n_relinquishes_null;
55207 -atomic_t fscache_n_relinquishes_waitcrt;
55208 -atomic_t fscache_n_relinquishes_retire;
55209 +atomic_unchecked_t fscache_n_relinquishes;
55210 +atomic_unchecked_t fscache_n_relinquishes_null;
55211 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
55212 +atomic_unchecked_t fscache_n_relinquishes_retire;
55213
55214 -atomic_t fscache_n_cookie_index;
55215 -atomic_t fscache_n_cookie_data;
55216 -atomic_t fscache_n_cookie_special;
55217 +atomic_unchecked_t fscache_n_cookie_index;
55218 +atomic_unchecked_t fscache_n_cookie_data;
55219 +atomic_unchecked_t fscache_n_cookie_special;
55220
55221 -atomic_t fscache_n_object_alloc;
55222 -atomic_t fscache_n_object_no_alloc;
55223 -atomic_t fscache_n_object_lookups;
55224 -atomic_t fscache_n_object_lookups_negative;
55225 -atomic_t fscache_n_object_lookups_positive;
55226 -atomic_t fscache_n_object_lookups_timed_out;
55227 -atomic_t fscache_n_object_created;
55228 -atomic_t fscache_n_object_avail;
55229 -atomic_t fscache_n_object_dead;
55230 +atomic_unchecked_t fscache_n_object_alloc;
55231 +atomic_unchecked_t fscache_n_object_no_alloc;
55232 +atomic_unchecked_t fscache_n_object_lookups;
55233 +atomic_unchecked_t fscache_n_object_lookups_negative;
55234 +atomic_unchecked_t fscache_n_object_lookups_positive;
55235 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
55236 +atomic_unchecked_t fscache_n_object_created;
55237 +atomic_unchecked_t fscache_n_object_avail;
55238 +atomic_unchecked_t fscache_n_object_dead;
55239
55240 -atomic_t fscache_n_checkaux_none;
55241 -atomic_t fscache_n_checkaux_okay;
55242 -atomic_t fscache_n_checkaux_update;
55243 -atomic_t fscache_n_checkaux_obsolete;
55244 +atomic_unchecked_t fscache_n_checkaux_none;
55245 +atomic_unchecked_t fscache_n_checkaux_okay;
55246 +atomic_unchecked_t fscache_n_checkaux_update;
55247 +atomic_unchecked_t fscache_n_checkaux_obsolete;
55248
55249 atomic_t fscache_n_cop_alloc_object;
55250 atomic_t fscache_n_cop_lookup_object;
55251 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
55252 seq_puts(m, "FS-Cache statistics\n");
55253
55254 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
55255 - atomic_read(&fscache_n_cookie_index),
55256 - atomic_read(&fscache_n_cookie_data),
55257 - atomic_read(&fscache_n_cookie_special));
55258 + atomic_read_unchecked(&fscache_n_cookie_index),
55259 + atomic_read_unchecked(&fscache_n_cookie_data),
55260 + atomic_read_unchecked(&fscache_n_cookie_special));
55261
55262 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
55263 - atomic_read(&fscache_n_object_alloc),
55264 - atomic_read(&fscache_n_object_no_alloc),
55265 - atomic_read(&fscache_n_object_avail),
55266 - atomic_read(&fscache_n_object_dead));
55267 + atomic_read_unchecked(&fscache_n_object_alloc),
55268 + atomic_read_unchecked(&fscache_n_object_no_alloc),
55269 + atomic_read_unchecked(&fscache_n_object_avail),
55270 + atomic_read_unchecked(&fscache_n_object_dead));
55271 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
55272 - atomic_read(&fscache_n_checkaux_none),
55273 - atomic_read(&fscache_n_checkaux_okay),
55274 - atomic_read(&fscache_n_checkaux_update),
55275 - atomic_read(&fscache_n_checkaux_obsolete));
55276 + atomic_read_unchecked(&fscache_n_checkaux_none),
55277 + atomic_read_unchecked(&fscache_n_checkaux_okay),
55278 + atomic_read_unchecked(&fscache_n_checkaux_update),
55279 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
55280
55281 seq_printf(m, "Pages : mrk=%u unc=%u\n",
55282 - atomic_read(&fscache_n_marks),
55283 - atomic_read(&fscache_n_uncaches));
55284 + atomic_read_unchecked(&fscache_n_marks),
55285 + atomic_read_unchecked(&fscache_n_uncaches));
55286
55287 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
55288 " oom=%u\n",
55289 - atomic_read(&fscache_n_acquires),
55290 - atomic_read(&fscache_n_acquires_null),
55291 - atomic_read(&fscache_n_acquires_no_cache),
55292 - atomic_read(&fscache_n_acquires_ok),
55293 - atomic_read(&fscache_n_acquires_nobufs),
55294 - atomic_read(&fscache_n_acquires_oom));
55295 + atomic_read_unchecked(&fscache_n_acquires),
55296 + atomic_read_unchecked(&fscache_n_acquires_null),
55297 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
55298 + atomic_read_unchecked(&fscache_n_acquires_ok),
55299 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
55300 + atomic_read_unchecked(&fscache_n_acquires_oom));
55301
55302 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
55303 - atomic_read(&fscache_n_object_lookups),
55304 - atomic_read(&fscache_n_object_lookups_negative),
55305 - atomic_read(&fscache_n_object_lookups_positive),
55306 - atomic_read(&fscache_n_object_created),
55307 - atomic_read(&fscache_n_object_lookups_timed_out));
55308 + atomic_read_unchecked(&fscache_n_object_lookups),
55309 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
55310 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
55311 + atomic_read_unchecked(&fscache_n_object_created),
55312 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
55313
55314 seq_printf(m, "Invals : n=%u run=%u\n",
55315 - atomic_read(&fscache_n_invalidates),
55316 - atomic_read(&fscache_n_invalidates_run));
55317 + atomic_read_unchecked(&fscache_n_invalidates),
55318 + atomic_read_unchecked(&fscache_n_invalidates_run));
55319
55320 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
55321 - atomic_read(&fscache_n_updates),
55322 - atomic_read(&fscache_n_updates_null),
55323 - atomic_read(&fscache_n_updates_run));
55324 + atomic_read_unchecked(&fscache_n_updates),
55325 + atomic_read_unchecked(&fscache_n_updates_null),
55326 + atomic_read_unchecked(&fscache_n_updates_run));
55327
55328 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
55329 - atomic_read(&fscache_n_relinquishes),
55330 - atomic_read(&fscache_n_relinquishes_null),
55331 - atomic_read(&fscache_n_relinquishes_waitcrt),
55332 - atomic_read(&fscache_n_relinquishes_retire));
55333 + atomic_read_unchecked(&fscache_n_relinquishes),
55334 + atomic_read_unchecked(&fscache_n_relinquishes_null),
55335 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
55336 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
55337
55338 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
55339 - atomic_read(&fscache_n_attr_changed),
55340 - atomic_read(&fscache_n_attr_changed_ok),
55341 - atomic_read(&fscache_n_attr_changed_nobufs),
55342 - atomic_read(&fscache_n_attr_changed_nomem),
55343 - atomic_read(&fscache_n_attr_changed_calls));
55344 + atomic_read_unchecked(&fscache_n_attr_changed),
55345 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
55346 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
55347 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
55348 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
55349
55350 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
55351 - atomic_read(&fscache_n_allocs),
55352 - atomic_read(&fscache_n_allocs_ok),
55353 - atomic_read(&fscache_n_allocs_wait),
55354 - atomic_read(&fscache_n_allocs_nobufs),
55355 - atomic_read(&fscache_n_allocs_intr));
55356 + atomic_read_unchecked(&fscache_n_allocs),
55357 + atomic_read_unchecked(&fscache_n_allocs_ok),
55358 + atomic_read_unchecked(&fscache_n_allocs_wait),
55359 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
55360 + atomic_read_unchecked(&fscache_n_allocs_intr));
55361 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
55362 - atomic_read(&fscache_n_alloc_ops),
55363 - atomic_read(&fscache_n_alloc_op_waits),
55364 - atomic_read(&fscache_n_allocs_object_dead));
55365 + atomic_read_unchecked(&fscache_n_alloc_ops),
55366 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
55367 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
55368
55369 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
55370 " int=%u oom=%u\n",
55371 - atomic_read(&fscache_n_retrievals),
55372 - atomic_read(&fscache_n_retrievals_ok),
55373 - atomic_read(&fscache_n_retrievals_wait),
55374 - atomic_read(&fscache_n_retrievals_nodata),
55375 - atomic_read(&fscache_n_retrievals_nobufs),
55376 - atomic_read(&fscache_n_retrievals_intr),
55377 - atomic_read(&fscache_n_retrievals_nomem));
55378 + atomic_read_unchecked(&fscache_n_retrievals),
55379 + atomic_read_unchecked(&fscache_n_retrievals_ok),
55380 + atomic_read_unchecked(&fscache_n_retrievals_wait),
55381 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
55382 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
55383 + atomic_read_unchecked(&fscache_n_retrievals_intr),
55384 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
55385 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
55386 - atomic_read(&fscache_n_retrieval_ops),
55387 - atomic_read(&fscache_n_retrieval_op_waits),
55388 - atomic_read(&fscache_n_retrievals_object_dead));
55389 + atomic_read_unchecked(&fscache_n_retrieval_ops),
55390 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
55391 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
55392
55393 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
55394 - atomic_read(&fscache_n_stores),
55395 - atomic_read(&fscache_n_stores_ok),
55396 - atomic_read(&fscache_n_stores_again),
55397 - atomic_read(&fscache_n_stores_nobufs),
55398 - atomic_read(&fscache_n_stores_oom));
55399 + atomic_read_unchecked(&fscache_n_stores),
55400 + atomic_read_unchecked(&fscache_n_stores_ok),
55401 + atomic_read_unchecked(&fscache_n_stores_again),
55402 + atomic_read_unchecked(&fscache_n_stores_nobufs),
55403 + atomic_read_unchecked(&fscache_n_stores_oom));
55404 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
55405 - atomic_read(&fscache_n_store_ops),
55406 - atomic_read(&fscache_n_store_calls),
55407 - atomic_read(&fscache_n_store_pages),
55408 - atomic_read(&fscache_n_store_radix_deletes),
55409 - atomic_read(&fscache_n_store_pages_over_limit));
55410 + atomic_read_unchecked(&fscache_n_store_ops),
55411 + atomic_read_unchecked(&fscache_n_store_calls),
55412 + atomic_read_unchecked(&fscache_n_store_pages),
55413 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
55414 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
55415
55416 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
55417 - atomic_read(&fscache_n_store_vmscan_not_storing),
55418 - atomic_read(&fscache_n_store_vmscan_gone),
55419 - atomic_read(&fscache_n_store_vmscan_busy),
55420 - atomic_read(&fscache_n_store_vmscan_cancelled),
55421 - atomic_read(&fscache_n_store_vmscan_wait));
55422 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
55423 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
55424 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
55425 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
55426 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
55427
55428 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
55429 - atomic_read(&fscache_n_op_pend),
55430 - atomic_read(&fscache_n_op_run),
55431 - atomic_read(&fscache_n_op_enqueue),
55432 - atomic_read(&fscache_n_op_cancelled),
55433 - atomic_read(&fscache_n_op_rejected));
55434 + atomic_read_unchecked(&fscache_n_op_pend),
55435 + atomic_read_unchecked(&fscache_n_op_run),
55436 + atomic_read_unchecked(&fscache_n_op_enqueue),
55437 + atomic_read_unchecked(&fscache_n_op_cancelled),
55438 + atomic_read_unchecked(&fscache_n_op_rejected));
55439 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
55440 - atomic_read(&fscache_n_op_deferred_release),
55441 - atomic_read(&fscache_n_op_release),
55442 - atomic_read(&fscache_n_op_gc));
55443 + atomic_read_unchecked(&fscache_n_op_deferred_release),
55444 + atomic_read_unchecked(&fscache_n_op_release),
55445 + atomic_read_unchecked(&fscache_n_op_gc));
55446
55447 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
55448 atomic_read(&fscache_n_cop_alloc_object),
55449 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
55450 index aef34b1..59bfd7b 100644
55451 --- a/fs/fuse/cuse.c
55452 +++ b/fs/fuse/cuse.c
55453 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
55454 INIT_LIST_HEAD(&cuse_conntbl[i]);
55455
55456 /* inherit and extend fuse_dev_operations */
55457 - cuse_channel_fops = fuse_dev_operations;
55458 - cuse_channel_fops.owner = THIS_MODULE;
55459 - cuse_channel_fops.open = cuse_channel_open;
55460 - cuse_channel_fops.release = cuse_channel_release;
55461 + pax_open_kernel();
55462 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
55463 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
55464 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
55465 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
55466 + pax_close_kernel();
55467
55468 cuse_class = class_create(THIS_MODULE, "cuse");
55469 if (IS_ERR(cuse_class))
55470 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
55471 index 1d55f94..088da65 100644
55472 --- a/fs/fuse/dev.c
55473 +++ b/fs/fuse/dev.c
55474 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
55475 ret = 0;
55476 pipe_lock(pipe);
55477
55478 - if (!pipe->readers) {
55479 + if (!atomic_read(&pipe->readers)) {
55480 send_sig(SIGPIPE, current, 0);
55481 if (!ret)
55482 ret = -EPIPE;
55483 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
55484 page_nr++;
55485 ret += buf->len;
55486
55487 - if (pipe->files)
55488 + if (atomic_read(&pipe->files))
55489 do_wakeup = 1;
55490 }
55491
55492 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
55493 index 5b12746..b481b03 100644
55494 --- a/fs/fuse/dir.c
55495 +++ b/fs/fuse/dir.c
55496 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
55497 return link;
55498 }
55499
55500 -static void free_link(char *link)
55501 +static void free_link(const char *link)
55502 {
55503 if (!IS_ERR(link))
55504 free_page((unsigned long) link);
55505 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
55506 index 62b484e..0f9a140 100644
55507 --- a/fs/gfs2/inode.c
55508 +++ b/fs/gfs2/inode.c
55509 @@ -1441,7 +1441,7 @@ out:
55510
55511 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
55512 {
55513 - char *s = nd_get_link(nd);
55514 + const char *s = nd_get_link(nd);
55515 if (!IS_ERR(s))
55516 kfree(s);
55517 }
55518 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
55519 index a3f868a..bb308ae 100644
55520 --- a/fs/hugetlbfs/inode.c
55521 +++ b/fs/hugetlbfs/inode.c
55522 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
55523 struct mm_struct *mm = current->mm;
55524 struct vm_area_struct *vma;
55525 struct hstate *h = hstate_file(file);
55526 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
55527 struct vm_unmapped_area_info info;
55528
55529 if (len & ~huge_page_mask(h))
55530 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
55531 return addr;
55532 }
55533
55534 +#ifdef CONFIG_PAX_RANDMMAP
55535 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
55536 +#endif
55537 +
55538 if (addr) {
55539 addr = ALIGN(addr, huge_page_size(h));
55540 vma = find_vma(mm, addr);
55541 - if (TASK_SIZE - len >= addr &&
55542 - (!vma || addr + len <= vma->vm_start))
55543 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
55544 return addr;
55545 }
55546
55547 info.flags = 0;
55548 info.length = len;
55549 info.low_limit = TASK_UNMAPPED_BASE;
55550 +
55551 +#ifdef CONFIG_PAX_RANDMMAP
55552 + if (mm->pax_flags & MF_PAX_RANDMMAP)
55553 + info.low_limit += mm->delta_mmap;
55554 +#endif
55555 +
55556 info.high_limit = TASK_SIZE;
55557 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
55558 info.align_offset = 0;
55559 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
55560 };
55561 MODULE_ALIAS_FS("hugetlbfs");
55562
55563 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
55564 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
55565
55566 static int can_do_hugetlb_shm(void)
55567 {
55568 diff --git a/fs/inode.c b/fs/inode.c
55569 index 00d5fc3..98ce7d7 100644
55570 --- a/fs/inode.c
55571 +++ b/fs/inode.c
55572 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
55573
55574 #ifdef CONFIG_SMP
55575 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
55576 - static atomic_t shared_last_ino;
55577 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
55578 + static atomic_unchecked_t shared_last_ino;
55579 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
55580
55581 res = next - LAST_INO_BATCH;
55582 }
55583 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
55584 index 4a6cf28..d3a29d3 100644
55585 --- a/fs/jffs2/erase.c
55586 +++ b/fs/jffs2/erase.c
55587 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
55588 struct jffs2_unknown_node marker = {
55589 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
55590 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
55591 - .totlen = cpu_to_je32(c->cleanmarker_size)
55592 + .totlen = cpu_to_je32(c->cleanmarker_size),
55593 + .hdr_crc = cpu_to_je32(0)
55594 };
55595
55596 jffs2_prealloc_raw_node_refs(c, jeb, 1);
55597 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
55598 index a6597d6..41b30ec 100644
55599 --- a/fs/jffs2/wbuf.c
55600 +++ b/fs/jffs2/wbuf.c
55601 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
55602 {
55603 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
55604 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
55605 - .totlen = constant_cpu_to_je32(8)
55606 + .totlen = constant_cpu_to_je32(8),
55607 + .hdr_crc = constant_cpu_to_je32(0)
55608 };
55609
55610 /*
55611 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
55612 index 788e0a9..8433098 100644
55613 --- a/fs/jfs/super.c
55614 +++ b/fs/jfs/super.c
55615 @@ -878,7 +878,7 @@ static int __init init_jfs_fs(void)
55616
55617 jfs_inode_cachep =
55618 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
55619 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
55620 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
55621 init_once);
55622 if (jfs_inode_cachep == NULL)
55623 return -ENOMEM;
55624 diff --git a/fs/libfs.c b/fs/libfs.c
55625 index 916da8c..1588998 100644
55626 --- a/fs/libfs.c
55627 +++ b/fs/libfs.c
55628 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
55629
55630 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
55631 struct dentry *next;
55632 + char d_name[sizeof(next->d_iname)];
55633 + const unsigned char *name;
55634 +
55635 next = list_entry(p, struct dentry, d_u.d_child);
55636 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
55637 if (!simple_positive(next)) {
55638 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
55639
55640 spin_unlock(&next->d_lock);
55641 spin_unlock(&dentry->d_lock);
55642 - if (filldir(dirent, next->d_name.name,
55643 + name = next->d_name.name;
55644 + if (name == next->d_iname) {
55645 + memcpy(d_name, name, next->d_name.len);
55646 + name = d_name;
55647 + }
55648 + if (filldir(dirent, name,
55649 next->d_name.len, filp->f_pos,
55650 next->d_inode->i_ino,
55651 dt_type(next->d_inode)) < 0)
55652 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
55653 index acd3947..1f896e2 100644
55654 --- a/fs/lockd/clntproc.c
55655 +++ b/fs/lockd/clntproc.c
55656 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
55657 /*
55658 * Cookie counter for NLM requests
55659 */
55660 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
55661 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
55662
55663 void nlmclnt_next_cookie(struct nlm_cookie *c)
55664 {
55665 - u32 cookie = atomic_inc_return(&nlm_cookie);
55666 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
55667
55668 memcpy(c->data, &cookie, 4);
55669 c->len=4;
55670 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
55671 index a2aa97d..10d6c41 100644
55672 --- a/fs/lockd/svc.c
55673 +++ b/fs/lockd/svc.c
55674 @@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
55675 svc_sock_update_bufs(serv);
55676 serv->sv_maxconn = nlm_max_connections;
55677
55678 - nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
55679 + nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
55680 if (IS_ERR(nlmsvc_task)) {
55681 error = PTR_ERR(nlmsvc_task);
55682 printk(KERN_WARNING
55683 diff --git a/fs/locks.c b/fs/locks.c
55684 index cb424a4..850e4dd 100644
55685 --- a/fs/locks.c
55686 +++ b/fs/locks.c
55687 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
55688 return;
55689
55690 if (filp->f_op && filp->f_op->flock) {
55691 - struct file_lock fl = {
55692 + struct file_lock flock = {
55693 .fl_pid = current->tgid,
55694 .fl_file = filp,
55695 .fl_flags = FL_FLOCK,
55696 .fl_type = F_UNLCK,
55697 .fl_end = OFFSET_MAX,
55698 };
55699 - filp->f_op->flock(filp, F_SETLKW, &fl);
55700 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
55701 - fl.fl_ops->fl_release_private(&fl);
55702 + filp->f_op->flock(filp, F_SETLKW, &flock);
55703 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
55704 + flock.fl_ops->fl_release_private(&flock);
55705 }
55706
55707 lock_flocks();
55708 diff --git a/fs/namei.c b/fs/namei.c
55709 index 9ed9361..2b72db1 100644
55710 --- a/fs/namei.c
55711 +++ b/fs/namei.c
55712 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
55713 if (ret != -EACCES)
55714 return ret;
55715
55716 +#ifdef CONFIG_GRKERNSEC
55717 + /* we'll block if we have to log due to a denied capability use */
55718 + if (mask & MAY_NOT_BLOCK)
55719 + return -ECHILD;
55720 +#endif
55721 +
55722 if (S_ISDIR(inode->i_mode)) {
55723 /* DACs are overridable for directories */
55724 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
55725 - return 0;
55726 if (!(mask & MAY_WRITE))
55727 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
55728 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
55729 + inode_capable(inode, CAP_DAC_READ_SEARCH))
55730 return 0;
55731 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
55732 + return 0;
55733 return -EACCES;
55734 }
55735 /*
55736 + * Searching includes executable on directories, else just read.
55737 + */
55738 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
55739 + if (mask == MAY_READ)
55740 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
55741 + inode_capable(inode, CAP_DAC_READ_SEARCH))
55742 + return 0;
55743 +
55744 + /*
55745 * Read/write DACs are always overridable.
55746 * Executable DACs are overridable when there is
55747 * at least one exec bit set.
55748 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
55749 if (inode_capable(inode, CAP_DAC_OVERRIDE))
55750 return 0;
55751
55752 - /*
55753 - * Searching includes executable on directories, else just read.
55754 - */
55755 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
55756 - if (mask == MAY_READ)
55757 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
55758 - return 0;
55759 -
55760 return -EACCES;
55761 }
55762
55763 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
55764 {
55765 struct dentry *dentry = link->dentry;
55766 int error;
55767 - char *s;
55768 + const char *s;
55769
55770 BUG_ON(nd->flags & LOOKUP_RCU);
55771
55772 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
55773 if (error)
55774 goto out_put_nd_path;
55775
55776 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
55777 + dentry->d_inode, dentry, nd->path.mnt)) {
55778 + error = -EACCES;
55779 + goto out_put_nd_path;
55780 + }
55781 +
55782 nd->last_type = LAST_BIND;
55783 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
55784 error = PTR_ERR(*p);
55785 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
55786 if (res)
55787 break;
55788 res = walk_component(nd, path, LOOKUP_FOLLOW);
55789 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
55790 + res = -EACCES;
55791 put_link(nd, &link, cookie);
55792 } while (res > 0);
55793
55794 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
55795 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
55796 {
55797 unsigned long a, b, adata, bdata, mask, hash, len;
55798 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
55799 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
55800
55801 hash = a = 0;
55802 len = -sizeof(unsigned long);
55803 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
55804 if (err)
55805 break;
55806 err = lookup_last(nd, &path);
55807 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
55808 + err = -EACCES;
55809 put_link(nd, &link, cookie);
55810 }
55811 }
55812 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
55813 if (!err)
55814 err = complete_walk(nd);
55815
55816 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
55817 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
55818 + path_put(&nd->path);
55819 + err = -ENOENT;
55820 + }
55821 + }
55822 +
55823 if (!err && nd->flags & LOOKUP_DIRECTORY) {
55824 if (!can_lookup(nd->inode)) {
55825 path_put(&nd->path);
55826 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
55827 retval = path_lookupat(dfd, name->name,
55828 flags | LOOKUP_REVAL, nd);
55829
55830 - if (likely(!retval))
55831 + if (likely(!retval)) {
55832 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
55833 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
55834 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
55835 + path_put(&nd->path);
55836 + return -ENOENT;
55837 + }
55838 + }
55839 + }
55840 return retval;
55841 }
55842
55843 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
55844 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
55845 return -EPERM;
55846
55847 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
55848 + return -EPERM;
55849 + if (gr_handle_rawio(inode))
55850 + return -EPERM;
55851 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
55852 + return -EACCES;
55853 +
55854 return 0;
55855 }
55856
55857 @@ -2602,7 +2641,7 @@ looked_up:
55858 * cleared otherwise prior to returning.
55859 */
55860 static int lookup_open(struct nameidata *nd, struct path *path,
55861 - struct file *file,
55862 + struct path *link, struct file *file,
55863 const struct open_flags *op,
55864 bool got_write, int *opened)
55865 {
55866 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
55867 /* Negative dentry, just create the file */
55868 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
55869 umode_t mode = op->mode;
55870 +
55871 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
55872 + error = -EACCES;
55873 + goto out_dput;
55874 + }
55875 +
55876 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
55877 + error = -EACCES;
55878 + goto out_dput;
55879 + }
55880 +
55881 if (!IS_POSIXACL(dir->d_inode))
55882 mode &= ~current_umask();
55883 /*
55884 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
55885 nd->flags & LOOKUP_EXCL);
55886 if (error)
55887 goto out_dput;
55888 + else
55889 + gr_handle_create(dentry, nd->path.mnt);
55890 }
55891 out_no_open:
55892 path->dentry = dentry;
55893 @@ -2672,7 +2724,7 @@ out_dput:
55894 /*
55895 * Handle the last step of open()
55896 */
55897 -static int do_last(struct nameidata *nd, struct path *path,
55898 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
55899 struct file *file, const struct open_flags *op,
55900 int *opened, struct filename *name)
55901 {
55902 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
55903 error = complete_walk(nd);
55904 if (error)
55905 return error;
55906 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
55907 + error = -ENOENT;
55908 + goto out;
55909 + }
55910 audit_inode(name, nd->path.dentry, 0);
55911 if (open_flag & O_CREAT) {
55912 error = -EISDIR;
55913 goto out;
55914 }
55915 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
55916 + error = -EACCES;
55917 + goto out;
55918 + }
55919 goto finish_open;
55920 case LAST_BIND:
55921 error = complete_walk(nd);
55922 if (error)
55923 return error;
55924 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
55925 + error = -ENOENT;
55926 + goto out;
55927 + }
55928 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
55929 + error = -EACCES;
55930 + goto out;
55931 + }
55932 audit_inode(name, dir, 0);
55933 goto finish_open;
55934 }
55935 @@ -2759,7 +2827,7 @@ retry_lookup:
55936 */
55937 }
55938 mutex_lock(&dir->d_inode->i_mutex);
55939 - error = lookup_open(nd, path, file, op, got_write, opened);
55940 + error = lookup_open(nd, path, link, file, op, got_write, opened);
55941 mutex_unlock(&dir->d_inode->i_mutex);
55942
55943 if (error <= 0) {
55944 @@ -2783,11 +2851,28 @@ retry_lookup:
55945 goto finish_open_created;
55946 }
55947
55948 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
55949 + error = -ENOENT;
55950 + goto exit_dput;
55951 + }
55952 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
55953 + error = -EACCES;
55954 + goto exit_dput;
55955 + }
55956 +
55957 /*
55958 * create/update audit record if it already exists.
55959 */
55960 - if (path->dentry->d_inode)
55961 + if (path->dentry->d_inode) {
55962 + /* only check if O_CREAT is specified, all other checks need to go
55963 + into may_open */
55964 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
55965 + error = -EACCES;
55966 + goto exit_dput;
55967 + }
55968 +
55969 audit_inode(name, path->dentry, 0);
55970 + }
55971
55972 /*
55973 * If atomic_open() acquired write access it is dropped now due to
55974 @@ -2828,6 +2913,11 @@ finish_lookup:
55975 }
55976 }
55977 BUG_ON(inode != path->dentry->d_inode);
55978 + /* if we're resolving a symlink to another symlink */
55979 + if (link && gr_handle_symlink_owner(link, inode)) {
55980 + error = -EACCES;
55981 + goto out;
55982 + }
55983 return 1;
55984 }
55985
55986 @@ -2837,7 +2927,6 @@ finish_lookup:
55987 save_parent.dentry = nd->path.dentry;
55988 save_parent.mnt = mntget(path->mnt);
55989 nd->path.dentry = path->dentry;
55990 -
55991 }
55992 nd->inode = inode;
55993 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
55994 @@ -2846,6 +2935,16 @@ finish_lookup:
55995 path_put(&save_parent);
55996 return error;
55997 }
55998 +
55999 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
56000 + error = -ENOENT;
56001 + goto out;
56002 + }
56003 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
56004 + error = -EACCES;
56005 + goto out;
56006 + }
56007 +
56008 error = -EISDIR;
56009 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
56010 goto out;
56011 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
56012 if (unlikely(error))
56013 goto out;
56014
56015 - error = do_last(nd, &path, file, op, &opened, pathname);
56016 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
56017 while (unlikely(error > 0)) { /* trailing symlink */
56018 struct path link = path;
56019 void *cookie;
56020 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
56021 error = follow_link(&link, nd, &cookie);
56022 if (unlikely(error))
56023 break;
56024 - error = do_last(nd, &path, file, op, &opened, pathname);
56025 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
56026 put_link(nd, &link, cookie);
56027 }
56028 out:
56029 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
56030 goto unlock;
56031
56032 error = -EEXIST;
56033 - if (dentry->d_inode)
56034 + if (dentry->d_inode) {
56035 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
56036 + error = -ENOENT;
56037 + }
56038 goto fail;
56039 + }
56040 /*
56041 * Special case - lookup gave negative, but... we had foo/bar/
56042 * From the vfs_mknod() POV we just have a negative dentry -
56043 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
56044 }
56045 EXPORT_SYMBOL(user_path_create);
56046
56047 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
56048 +{
56049 + struct filename *tmp = getname(pathname);
56050 + struct dentry *res;
56051 + if (IS_ERR(tmp))
56052 + return ERR_CAST(tmp);
56053 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
56054 + if (IS_ERR(res))
56055 + putname(tmp);
56056 + else
56057 + *to = tmp;
56058 + return res;
56059 +}
56060 +
56061 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
56062 {
56063 int error = may_create(dir, dentry);
56064 @@ -3177,6 +3294,17 @@ retry:
56065
56066 if (!IS_POSIXACL(path.dentry->d_inode))
56067 mode &= ~current_umask();
56068 +
56069 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
56070 + error = -EPERM;
56071 + goto out;
56072 + }
56073 +
56074 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
56075 + error = -EACCES;
56076 + goto out;
56077 + }
56078 +
56079 error = security_path_mknod(&path, dentry, mode, dev);
56080 if (error)
56081 goto out;
56082 @@ -3193,6 +3321,8 @@ retry:
56083 break;
56084 }
56085 out:
56086 + if (!error)
56087 + gr_handle_create(dentry, path.mnt);
56088 done_path_create(&path, dentry);
56089 if (retry_estale(error, lookup_flags)) {
56090 lookup_flags |= LOOKUP_REVAL;
56091 @@ -3245,9 +3375,16 @@ retry:
56092
56093 if (!IS_POSIXACL(path.dentry->d_inode))
56094 mode &= ~current_umask();
56095 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
56096 + error = -EACCES;
56097 + goto out;
56098 + }
56099 error = security_path_mkdir(&path, dentry, mode);
56100 if (!error)
56101 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
56102 + if (!error)
56103 + gr_handle_create(dentry, path.mnt);
56104 +out:
56105 done_path_create(&path, dentry);
56106 if (retry_estale(error, lookup_flags)) {
56107 lookup_flags |= LOOKUP_REVAL;
56108 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
56109 struct filename *name;
56110 struct dentry *dentry;
56111 struct nameidata nd;
56112 + ino_t saved_ino = 0;
56113 + dev_t saved_dev = 0;
56114 unsigned int lookup_flags = 0;
56115 retry:
56116 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
56117 @@ -3360,10 +3499,21 @@ retry:
56118 error = -ENOENT;
56119 goto exit3;
56120 }
56121 +
56122 + saved_ino = dentry->d_inode->i_ino;
56123 + saved_dev = gr_get_dev_from_dentry(dentry);
56124 +
56125 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
56126 + error = -EACCES;
56127 + goto exit3;
56128 + }
56129 +
56130 error = security_path_rmdir(&nd.path, dentry);
56131 if (error)
56132 goto exit3;
56133 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
56134 + if (!error && (saved_dev || saved_ino))
56135 + gr_handle_delete(saved_ino, saved_dev);
56136 exit3:
56137 dput(dentry);
56138 exit2:
56139 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
56140 struct dentry *dentry;
56141 struct nameidata nd;
56142 struct inode *inode = NULL;
56143 + ino_t saved_ino = 0;
56144 + dev_t saved_dev = 0;
56145 unsigned int lookup_flags = 0;
56146 retry:
56147 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
56148 @@ -3455,10 +3607,22 @@ retry:
56149 if (!inode)
56150 goto slashes;
56151 ihold(inode);
56152 +
56153 + if (inode->i_nlink <= 1) {
56154 + saved_ino = inode->i_ino;
56155 + saved_dev = gr_get_dev_from_dentry(dentry);
56156 + }
56157 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
56158 + error = -EACCES;
56159 + goto exit2;
56160 + }
56161 +
56162 error = security_path_unlink(&nd.path, dentry);
56163 if (error)
56164 goto exit2;
56165 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
56166 + if (!error && (saved_ino || saved_dev))
56167 + gr_handle_delete(saved_ino, saved_dev);
56168 exit2:
56169 dput(dentry);
56170 }
56171 @@ -3536,9 +3700,17 @@ retry:
56172 if (IS_ERR(dentry))
56173 goto out_putname;
56174
56175 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
56176 + error = -EACCES;
56177 + goto out;
56178 + }
56179 +
56180 error = security_path_symlink(&path, dentry, from->name);
56181 if (!error)
56182 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
56183 + if (!error)
56184 + gr_handle_create(dentry, path.mnt);
56185 +out:
56186 done_path_create(&path, dentry);
56187 if (retry_estale(error, lookup_flags)) {
56188 lookup_flags |= LOOKUP_REVAL;
56189 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
56190 {
56191 struct dentry *new_dentry;
56192 struct path old_path, new_path;
56193 + struct filename *to = NULL;
56194 int how = 0;
56195 int error;
56196
56197 @@ -3635,7 +3808,7 @@ retry:
56198 if (error)
56199 return error;
56200
56201 - new_dentry = user_path_create(newdfd, newname, &new_path,
56202 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
56203 (how & LOOKUP_REVAL));
56204 error = PTR_ERR(new_dentry);
56205 if (IS_ERR(new_dentry))
56206 @@ -3647,11 +3820,28 @@ retry:
56207 error = may_linkat(&old_path);
56208 if (unlikely(error))
56209 goto out_dput;
56210 +
56211 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
56212 + old_path.dentry->d_inode,
56213 + old_path.dentry->d_inode->i_mode, to)) {
56214 + error = -EACCES;
56215 + goto out_dput;
56216 + }
56217 +
56218 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
56219 + old_path.dentry, old_path.mnt, to)) {
56220 + error = -EACCES;
56221 + goto out_dput;
56222 + }
56223 +
56224 error = security_path_link(old_path.dentry, &new_path, new_dentry);
56225 if (error)
56226 goto out_dput;
56227 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
56228 + if (!error)
56229 + gr_handle_create(new_dentry, new_path.mnt);
56230 out_dput:
56231 + putname(to);
56232 done_path_create(&new_path, new_dentry);
56233 if (retry_estale(error, how)) {
56234 how |= LOOKUP_REVAL;
56235 @@ -3897,12 +4087,21 @@ retry:
56236 if (new_dentry == trap)
56237 goto exit5;
56238
56239 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
56240 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
56241 + to);
56242 + if (error)
56243 + goto exit5;
56244 +
56245 error = security_path_rename(&oldnd.path, old_dentry,
56246 &newnd.path, new_dentry);
56247 if (error)
56248 goto exit5;
56249 error = vfs_rename(old_dir->d_inode, old_dentry,
56250 new_dir->d_inode, new_dentry);
56251 + if (!error)
56252 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
56253 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
56254 exit5:
56255 dput(new_dentry);
56256 exit4:
56257 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
56258
56259 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
56260 {
56261 + char tmpbuf[64];
56262 + const char *newlink;
56263 int len;
56264
56265 len = PTR_ERR(link);
56266 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
56267 len = strlen(link);
56268 if (len > (unsigned) buflen)
56269 len = buflen;
56270 - if (copy_to_user(buffer, link, len))
56271 +
56272 + if (len < sizeof(tmpbuf)) {
56273 + memcpy(tmpbuf, link, len);
56274 + newlink = tmpbuf;
56275 + } else
56276 + newlink = link;
56277 +
56278 + if (copy_to_user(buffer, newlink, len))
56279 len = -EFAULT;
56280 out:
56281 return len;
56282 diff --git a/fs/namespace.c b/fs/namespace.c
56283 index 7b1ca9b..6faeccf 100644
56284 --- a/fs/namespace.c
56285 +++ b/fs/namespace.c
56286 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
56287 if (!(sb->s_flags & MS_RDONLY))
56288 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
56289 up_write(&sb->s_umount);
56290 +
56291 + gr_log_remount(mnt->mnt_devname, retval);
56292 +
56293 return retval;
56294 }
56295
56296 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
56297 }
56298 br_write_unlock(&vfsmount_lock);
56299 namespace_unlock();
56300 +
56301 + gr_log_unmount(mnt->mnt_devname, retval);
56302 +
56303 return retval;
56304 }
56305
56306 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
56307 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
56308 */
56309
56310 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
56311 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
56312 {
56313 struct path path;
56314 struct mount *mnt;
56315 @@ -1342,7 +1348,7 @@ out:
56316 /*
56317 * The 2.0 compatible umount. No flags.
56318 */
56319 -SYSCALL_DEFINE1(oldumount, char __user *, name)
56320 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
56321 {
56322 return sys_umount(name, 0);
56323 }
56324 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
56325 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
56326 MS_STRICTATIME);
56327
56328 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
56329 + retval = -EPERM;
56330 + goto dput_out;
56331 + }
56332 +
56333 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
56334 + retval = -EPERM;
56335 + goto dput_out;
56336 + }
56337 +
56338 if (flags & MS_REMOUNT)
56339 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
56340 data_page);
56341 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
56342 dev_name, data_page);
56343 dput_out:
56344 path_put(&path);
56345 +
56346 + gr_log_mount(dev_name, dir_name, retval);
56347 +
56348 return retval;
56349 }
56350
56351 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
56352 }
56353 EXPORT_SYMBOL(mount_subtree);
56354
56355 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
56356 - char __user *, type, unsigned long, flags, void __user *, data)
56357 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
56358 + const char __user *, type, unsigned long, flags, void __user *, data)
56359 {
56360 int ret;
56361 char *kernel_type;
56362 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
56363 if (error)
56364 goto out2;
56365
56366 + if (gr_handle_chroot_pivot()) {
56367 + error = -EPERM;
56368 + goto out2;
56369 + }
56370 +
56371 get_fs_root(current->fs, &root);
56372 old_mp = lock_mount(&old);
56373 error = PTR_ERR(old_mp);
56374 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
56375 !nsown_capable(CAP_SYS_ADMIN))
56376 return -EPERM;
56377
56378 - if (fs->users != 1)
56379 + if (atomic_read(&fs->users) != 1)
56380 return -EINVAL;
56381
56382 get_mnt_ns(mnt_ns);
56383 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
56384 index cff089a..4c3d57a 100644
56385 --- a/fs/nfs/callback.c
56386 +++ b/fs/nfs/callback.c
56387 @@ -211,7 +211,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
56388 struct svc_rqst *rqstp;
56389 int (*callback_svc)(void *vrqstp);
56390 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
56391 - char svc_name[12];
56392 int ret;
56393
56394 nfs_callback_bc_serv(minorversion, xprt, serv);
56395 @@ -235,10 +234,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
56396
56397 svc_sock_update_bufs(serv);
56398
56399 - sprintf(svc_name, "nfsv4.%u-svc", minorversion);
56400 cb_info->serv = serv;
56401 cb_info->rqst = rqstp;
56402 - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
56403 + cb_info->task = kthread_run(callback_svc, cb_info->rqst, "nfsv4.%u-svc", minorversion);
56404 if (IS_ERR(cb_info->task)) {
56405 ret = PTR_ERR(cb_info->task);
56406 svc_exit_thread(cb_info->rqst);
56407 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
56408 index a35582c..ebbdcd5 100644
56409 --- a/fs/nfs/callback_xdr.c
56410 +++ b/fs/nfs/callback_xdr.c
56411 @@ -51,7 +51,7 @@ struct callback_op {
56412 callback_decode_arg_t decode_args;
56413 callback_encode_res_t encode_res;
56414 long res_maxsize;
56415 -};
56416 +} __do_const;
56417
56418 static struct callback_op callback_ops[];
56419
56420 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
56421 index c1c7a9d..7afa0b8 100644
56422 --- a/fs/nfs/inode.c
56423 +++ b/fs/nfs/inode.c
56424 @@ -1043,16 +1043,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
56425 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
56426 }
56427
56428 -static atomic_long_t nfs_attr_generation_counter;
56429 +static atomic_long_unchecked_t nfs_attr_generation_counter;
56430
56431 static unsigned long nfs_read_attr_generation_counter(void)
56432 {
56433 - return atomic_long_read(&nfs_attr_generation_counter);
56434 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
56435 }
56436
56437 unsigned long nfs_inc_attr_generation_counter(void)
56438 {
56439 - return atomic_long_inc_return(&nfs_attr_generation_counter);
56440 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
56441 }
56442
56443 void nfs_fattr_init(struct nfs_fattr *fattr)
56444 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
56445 index 2c37442..9b9538b 100644
56446 --- a/fs/nfs/nfs4state.c
56447 +++ b/fs/nfs/nfs4state.c
56448 @@ -1193,7 +1193,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
56449 snprintf(buf, sizeof(buf), "%s-manager",
56450 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
56451 rcu_read_unlock();
56452 - task = kthread_run(nfs4_run_state_manager, clp, buf);
56453 + task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
56454 if (IS_ERR(task)) {
56455 printk(KERN_ERR "%s: kthread_run: %ld\n",
56456 __func__, PTR_ERR(task));
56457 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
56458 index 27d74a2..c4c2a73 100644
56459 --- a/fs/nfsd/nfs4proc.c
56460 +++ b/fs/nfsd/nfs4proc.c
56461 @@ -1126,7 +1126,7 @@ struct nfsd4_operation {
56462 nfsd4op_rsize op_rsize_bop;
56463 stateid_getter op_get_currentstateid;
56464 stateid_setter op_set_currentstateid;
56465 -};
56466 +} __do_const;
56467
56468 static struct nfsd4_operation nfsd4_ops[];
56469
56470 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
56471 index 582321a..0224663 100644
56472 --- a/fs/nfsd/nfs4xdr.c
56473 +++ b/fs/nfsd/nfs4xdr.c
56474 @@ -1458,7 +1458,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
56475
56476 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
56477
56478 -static nfsd4_dec nfsd4_dec_ops[] = {
56479 +static const nfsd4_dec nfsd4_dec_ops[] = {
56480 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
56481 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
56482 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
56483 @@ -1498,7 +1498,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
56484 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
56485 };
56486
56487 -static nfsd4_dec nfsd41_dec_ops[] = {
56488 +static const nfsd4_dec nfsd41_dec_ops[] = {
56489 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
56490 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
56491 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
56492 @@ -1560,7 +1560,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
56493 };
56494
56495 struct nfsd4_minorversion_ops {
56496 - nfsd4_dec *decoders;
56497 + const nfsd4_dec *decoders;
56498 int nops;
56499 };
56500
56501 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
56502 index e76244e..9fe8f2f1 100644
56503 --- a/fs/nfsd/nfscache.c
56504 +++ b/fs/nfsd/nfscache.c
56505 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
56506 {
56507 struct svc_cacherep *rp = rqstp->rq_cacherep;
56508 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
56509 - int len;
56510 + long len;
56511 size_t bufsize = 0;
56512
56513 if (!rp)
56514 return;
56515
56516 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
56517 - len >>= 2;
56518 + if (statp) {
56519 + len = (char*)statp - (char*)resv->iov_base;
56520 + len = resv->iov_len - len;
56521 + len >>= 2;
56522 + }
56523
56524 /* Don't cache excessive amounts of data and XDR failures */
56525 if (!statp || len > (256 >> 2)) {
56526 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
56527 index baf149a..76b86ad 100644
56528 --- a/fs/nfsd/vfs.c
56529 +++ b/fs/nfsd/vfs.c
56530 @@ -940,7 +940,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
56531 } else {
56532 oldfs = get_fs();
56533 set_fs(KERNEL_DS);
56534 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
56535 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
56536 set_fs(oldfs);
56537 }
56538
56539 @@ -1027,7 +1027,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
56540
56541 /* Write the data. */
56542 oldfs = get_fs(); set_fs(KERNEL_DS);
56543 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
56544 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
56545 set_fs(oldfs);
56546 if (host_err < 0)
56547 goto out_nfserr;
56548 @@ -1573,7 +1573,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
56549 */
56550
56551 oldfs = get_fs(); set_fs(KERNEL_DS);
56552 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
56553 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
56554 set_fs(oldfs);
56555
56556 if (host_err < 0)
56557 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
56558 index fea6bd5..8ee9d81 100644
56559 --- a/fs/nls/nls_base.c
56560 +++ b/fs/nls/nls_base.c
56561 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
56562
56563 int register_nls(struct nls_table * nls)
56564 {
56565 - struct nls_table ** tmp = &tables;
56566 + struct nls_table *tmp = tables;
56567
56568 if (nls->next)
56569 return -EBUSY;
56570
56571 spin_lock(&nls_lock);
56572 - while (*tmp) {
56573 - if (nls == *tmp) {
56574 + while (tmp) {
56575 + if (nls == tmp) {
56576 spin_unlock(&nls_lock);
56577 return -EBUSY;
56578 }
56579 - tmp = &(*tmp)->next;
56580 + tmp = tmp->next;
56581 }
56582 - nls->next = tables;
56583 + pax_open_kernel();
56584 + *(struct nls_table **)&nls->next = tables;
56585 + pax_close_kernel();
56586 tables = nls;
56587 spin_unlock(&nls_lock);
56588 return 0;
56589 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
56590
56591 int unregister_nls(struct nls_table * nls)
56592 {
56593 - struct nls_table ** tmp = &tables;
56594 + struct nls_table * const * tmp = &tables;
56595
56596 spin_lock(&nls_lock);
56597 while (*tmp) {
56598 if (nls == *tmp) {
56599 - *tmp = nls->next;
56600 + pax_open_kernel();
56601 + *(struct nls_table **)tmp = nls->next;
56602 + pax_close_kernel();
56603 spin_unlock(&nls_lock);
56604 return 0;
56605 }
56606 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
56607 index 7424929..35f6be5 100644
56608 --- a/fs/nls/nls_euc-jp.c
56609 +++ b/fs/nls/nls_euc-jp.c
56610 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
56611 p_nls = load_nls("cp932");
56612
56613 if (p_nls) {
56614 - table.charset2upper = p_nls->charset2upper;
56615 - table.charset2lower = p_nls->charset2lower;
56616 + pax_open_kernel();
56617 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
56618 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
56619 + pax_close_kernel();
56620 return register_nls(&table);
56621 }
56622
56623 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
56624 index e7bc1d7..06bd4bb 100644
56625 --- a/fs/nls/nls_koi8-ru.c
56626 +++ b/fs/nls/nls_koi8-ru.c
56627 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
56628 p_nls = load_nls("koi8-u");
56629
56630 if (p_nls) {
56631 - table.charset2upper = p_nls->charset2upper;
56632 - table.charset2lower = p_nls->charset2lower;
56633 + pax_open_kernel();
56634 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
56635 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
56636 + pax_close_kernel();
56637 return register_nls(&table);
56638 }
56639
56640 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
56641 index 77cc85d..a1e6299 100644
56642 --- a/fs/notify/fanotify/fanotify_user.c
56643 +++ b/fs/notify/fanotify/fanotify_user.c
56644 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
56645
56646 fd = fanotify_event_metadata.fd;
56647 ret = -EFAULT;
56648 - if (copy_to_user(buf, &fanotify_event_metadata,
56649 - fanotify_event_metadata.event_len))
56650 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
56651 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
56652 goto out_close_fd;
56653
56654 ret = prepare_for_access_response(group, event, fd);
56655 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
56656 index 7b51b05..5ea5ef6 100644
56657 --- a/fs/notify/notification.c
56658 +++ b/fs/notify/notification.c
56659 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
56660 * get set to 0 so it will never get 'freed'
56661 */
56662 static struct fsnotify_event *q_overflow_event;
56663 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
56664 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
56665
56666 /**
56667 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
56668 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
56669 */
56670 u32 fsnotify_get_cookie(void)
56671 {
56672 - return atomic_inc_return(&fsnotify_sync_cookie);
56673 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
56674 }
56675 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
56676
56677 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
56678 index aa411c3..c260a84 100644
56679 --- a/fs/ntfs/dir.c
56680 +++ b/fs/ntfs/dir.c
56681 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
56682 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
56683 ~(s64)(ndir->itype.index.block_size - 1)));
56684 /* Bounds checks. */
56685 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
56686 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
56687 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
56688 "inode 0x%lx or driver bug.", vdir->i_ino);
56689 goto err_out;
56690 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
56691 index c5670b8..01a3656 100644
56692 --- a/fs/ntfs/file.c
56693 +++ b/fs/ntfs/file.c
56694 @@ -2241,6 +2241,6 @@ const struct inode_operations ntfs_file_inode_ops = {
56695 #endif /* NTFS_RW */
56696 };
56697
56698 -const struct file_operations ntfs_empty_file_ops = {};
56699 +const struct file_operations ntfs_empty_file_ops __read_only;
56700
56701 -const struct inode_operations ntfs_empty_inode_ops = {};
56702 +const struct inode_operations ntfs_empty_inode_ops __read_only;
56703 diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
56704 index 20dfec7..e238cb7 100644
56705 --- a/fs/ocfs2/aops.c
56706 +++ b/fs/ocfs2/aops.c
56707 @@ -1756,7 +1756,7 @@ try_again:
56708 goto out;
56709 } else if (ret == 1) {
56710 clusters_need = wc->w_clen;
56711 - ret = ocfs2_refcount_cow(inode, filp, di_bh,
56712 + ret = ocfs2_refcount_cow(inode, di_bh,
56713 wc->w_cpos, wc->w_clen, UINT_MAX);
56714 if (ret) {
56715 mlog_errno(ret);
56716 diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
56717 index ff54014..ff125fd 100644
56718 --- a/fs/ocfs2/file.c
56719 +++ b/fs/ocfs2/file.c
56720 @@ -370,7 +370,7 @@ static int ocfs2_cow_file_pos(struct inode *inode,
56721 if (!(ext_flags & OCFS2_EXT_REFCOUNTED))
56722 goto out;
56723
56724 - return ocfs2_refcount_cow(inode, NULL, fe_bh, cpos, 1, cpos+1);
56725 + return ocfs2_refcount_cow(inode, fe_bh, cpos, 1, cpos+1);
56726
56727 out:
56728 return status;
56729 @@ -899,7 +899,7 @@ static int ocfs2_zero_extend_get_range(struct inode *inode,
56730 zero_clusters = last_cpos - zero_cpos;
56731
56732 if (needs_cow) {
56733 - rc = ocfs2_refcount_cow(inode, NULL, di_bh, zero_cpos,
56734 + rc = ocfs2_refcount_cow(inode, di_bh, zero_cpos,
56735 zero_clusters, UINT_MAX);
56736 if (rc) {
56737 mlog_errno(rc);
56738 @@ -2078,7 +2078,7 @@ static int ocfs2_prepare_inode_for_refcount(struct inode *inode,
56739
56740 *meta_level = 1;
56741
56742 - ret = ocfs2_refcount_cow(inode, file, di_bh, cpos, clusters, UINT_MAX);
56743 + ret = ocfs2_refcount_cow(inode, di_bh, cpos, clusters, UINT_MAX);
56744 if (ret)
56745 mlog_errno(ret);
56746 out:
56747 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
56748 index aebeacd..0dcdd26 100644
56749 --- a/fs/ocfs2/localalloc.c
56750 +++ b/fs/ocfs2/localalloc.c
56751 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
56752 goto bail;
56753 }
56754
56755 - atomic_inc(&osb->alloc_stats.moves);
56756 + atomic_inc_unchecked(&osb->alloc_stats.moves);
56757
56758 bail:
56759 if (handle)
56760 diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
56761 index f1fc172..452068b 100644
56762 --- a/fs/ocfs2/move_extents.c
56763 +++ b/fs/ocfs2/move_extents.c
56764 @@ -69,7 +69,7 @@ static int __ocfs2_move_extent(handle_t *handle,
56765 u64 ino = ocfs2_metadata_cache_owner(context->et.et_ci);
56766 u64 old_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cpos);
56767
56768 - ret = ocfs2_duplicate_clusters_by_page(handle, context->file, cpos,
56769 + ret = ocfs2_duplicate_clusters_by_page(handle, inode, cpos,
56770 p_cpos, new_p_cpos, len);
56771 if (ret) {
56772 mlog_errno(ret);
56773 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
56774 index d355e6e..578d905 100644
56775 --- a/fs/ocfs2/ocfs2.h
56776 +++ b/fs/ocfs2/ocfs2.h
56777 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
56778
56779 struct ocfs2_alloc_stats
56780 {
56781 - atomic_t moves;
56782 - atomic_t local_data;
56783 - atomic_t bitmap_data;
56784 - atomic_t bg_allocs;
56785 - atomic_t bg_extends;
56786 + atomic_unchecked_t moves;
56787 + atomic_unchecked_t local_data;
56788 + atomic_unchecked_t bitmap_data;
56789 + atomic_unchecked_t bg_allocs;
56790 + atomic_unchecked_t bg_extends;
56791 };
56792
56793 enum ocfs2_local_alloc_state
56794 diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
56795 index 998b17e..aefe414 100644
56796 --- a/fs/ocfs2/refcounttree.c
56797 +++ b/fs/ocfs2/refcounttree.c
56798 @@ -49,7 +49,6 @@
56799
56800 struct ocfs2_cow_context {
56801 struct inode *inode;
56802 - struct file *file;
56803 u32 cow_start;
56804 u32 cow_len;
56805 struct ocfs2_extent_tree data_et;
56806 @@ -66,7 +65,7 @@ struct ocfs2_cow_context {
56807 u32 *num_clusters,
56808 unsigned int *extent_flags);
56809 int (*cow_duplicate_clusters)(handle_t *handle,
56810 - struct file *file,
56811 + struct inode *inode,
56812 u32 cpos, u32 old_cluster,
56813 u32 new_cluster, u32 new_len);
56814 };
56815 @@ -2922,14 +2921,12 @@ static int ocfs2_clear_cow_buffer(handle_t *handle, struct buffer_head *bh)
56816 }
56817
56818 int ocfs2_duplicate_clusters_by_page(handle_t *handle,
56819 - struct file *file,
56820 + struct inode *inode,
56821 u32 cpos, u32 old_cluster,
56822 u32 new_cluster, u32 new_len)
56823 {
56824 int ret = 0, partial;
56825 - struct inode *inode = file_inode(file);
56826 - struct ocfs2_caching_info *ci = INODE_CACHE(inode);
56827 - struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
56828 + struct super_block *sb = inode->i_sb;
56829 u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster);
56830 struct page *page;
56831 pgoff_t page_index;
56832 @@ -2973,13 +2970,6 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
56833 if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize)
56834 BUG_ON(PageDirty(page));
56835
56836 - if (PageReadahead(page)) {
56837 - page_cache_async_readahead(mapping,
56838 - &file->f_ra, file,
56839 - page, page_index,
56840 - readahead_pages);
56841 - }
56842 -
56843 if (!PageUptodate(page)) {
56844 ret = block_read_full_page(page, ocfs2_get_block);
56845 if (ret) {
56846 @@ -2999,7 +2989,8 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
56847 }
56848 }
56849
56850 - ocfs2_map_and_dirty_page(inode, handle, from, to,
56851 + ocfs2_map_and_dirty_page(inode,
56852 + handle, from, to,
56853 page, 0, &new_block);
56854 mark_page_accessed(page);
56855 unlock:
56856 @@ -3015,12 +3006,11 @@ unlock:
56857 }
56858
56859 int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
56860 - struct file *file,
56861 + struct inode *inode,
56862 u32 cpos, u32 old_cluster,
56863 u32 new_cluster, u32 new_len)
56864 {
56865 int ret = 0;
56866 - struct inode *inode = file_inode(file);
56867 struct super_block *sb = inode->i_sb;
56868 struct ocfs2_caching_info *ci = INODE_CACHE(inode);
56869 int i, blocks = ocfs2_clusters_to_blocks(sb, new_len);
56870 @@ -3145,7 +3135,7 @@ static int ocfs2_replace_clusters(handle_t *handle,
56871
56872 /*If the old clusters is unwritten, no need to duplicate. */
56873 if (!(ext_flags & OCFS2_EXT_UNWRITTEN)) {
56874 - ret = context->cow_duplicate_clusters(handle, context->file,
56875 + ret = context->cow_duplicate_clusters(handle, context->inode,
56876 cpos, old, new, len);
56877 if (ret) {
56878 mlog_errno(ret);
56879 @@ -3423,35 +3413,12 @@ static int ocfs2_replace_cow(struct ocfs2_cow_context *context)
56880 return ret;
56881 }
56882
56883 -static void ocfs2_readahead_for_cow(struct inode *inode,
56884 - struct file *file,
56885 - u32 start, u32 len)
56886 -{
56887 - struct address_space *mapping;
56888 - pgoff_t index;
56889 - unsigned long num_pages;
56890 - int cs_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits;
56891 -
56892 - if (!file)
56893 - return;
56894 -
56895 - mapping = file->f_mapping;
56896 - num_pages = (len << cs_bits) >> PAGE_CACHE_SHIFT;
56897 - if (!num_pages)
56898 - num_pages = 1;
56899 -
56900 - index = ((loff_t)start << cs_bits) >> PAGE_CACHE_SHIFT;
56901 - page_cache_sync_readahead(mapping, &file->f_ra, file,
56902 - index, num_pages);
56903 -}
56904 -
56905 /*
56906 * Starting at cpos, try to CoW write_len clusters. Don't CoW
56907 * past max_cpos. This will stop when it runs into a hole or an
56908 * unrefcounted extent.
56909 */
56910 static int ocfs2_refcount_cow_hunk(struct inode *inode,
56911 - struct file *file,
56912 struct buffer_head *di_bh,
56913 u32 cpos, u32 write_len, u32 max_cpos)
56914 {
56915 @@ -3480,8 +3447,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
56916
56917 BUG_ON(cow_len == 0);
56918
56919 - ocfs2_readahead_for_cow(inode, file, cow_start, cow_len);
56920 -
56921 context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS);
56922 if (!context) {
56923 ret = -ENOMEM;
56924 @@ -3503,7 +3468,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
56925 context->ref_root_bh = ref_root_bh;
56926 context->cow_duplicate_clusters = ocfs2_duplicate_clusters_by_page;
56927 context->get_clusters = ocfs2_di_get_clusters;
56928 - context->file = file;
56929
56930 ocfs2_init_dinode_extent_tree(&context->data_et,
56931 INODE_CACHE(inode), di_bh);
56932 @@ -3532,7 +3496,6 @@ out:
56933 * clusters between cpos and cpos+write_len are safe to modify.
56934 */
56935 int ocfs2_refcount_cow(struct inode *inode,
56936 - struct file *file,
56937 struct buffer_head *di_bh,
56938 u32 cpos, u32 write_len, u32 max_cpos)
56939 {
56940 @@ -3552,7 +3515,7 @@ int ocfs2_refcount_cow(struct inode *inode,
56941 num_clusters = write_len;
56942
56943 if (ext_flags & OCFS2_EXT_REFCOUNTED) {
56944 - ret = ocfs2_refcount_cow_hunk(inode, file, di_bh, cpos,
56945 + ret = ocfs2_refcount_cow_hunk(inode, di_bh, cpos,
56946 num_clusters, max_cpos);
56947 if (ret) {
56948 mlog_errno(ret);
56949 diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h
56950 index 7754608..6422bbcdb 100644
56951 --- a/fs/ocfs2/refcounttree.h
56952 +++ b/fs/ocfs2/refcounttree.h
56953 @@ -53,7 +53,7 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
56954 int *credits,
56955 int *ref_blocks);
56956 int ocfs2_refcount_cow(struct inode *inode,
56957 - struct file *filep, struct buffer_head *di_bh,
56958 + struct buffer_head *di_bh,
56959 u32 cpos, u32 write_len, u32 max_cpos);
56960
56961 typedef int (ocfs2_post_refcount_func)(struct inode *inode,
56962 @@ -85,11 +85,11 @@ int ocfs2_refcount_cow_xattr(struct inode *inode,
56963 u32 cpos, u32 write_len,
56964 struct ocfs2_post_refcount *post);
56965 int ocfs2_duplicate_clusters_by_page(handle_t *handle,
56966 - struct file *file,
56967 + struct inode *inode,
56968 u32 cpos, u32 old_cluster,
56969 u32 new_cluster, u32 new_len);
56970 int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
56971 - struct file *file,
56972 + struct inode *inode,
56973 u32 cpos, u32 old_cluster,
56974 u32 new_cluster, u32 new_len);
56975 int ocfs2_cow_sync_writeback(struct super_block *sb,
56976 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
56977 index b7e74b5..19c6536 100644
56978 --- a/fs/ocfs2/suballoc.c
56979 +++ b/fs/ocfs2/suballoc.c
56980 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
56981 mlog_errno(status);
56982 goto bail;
56983 }
56984 - atomic_inc(&osb->alloc_stats.bg_extends);
56985 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
56986
56987 /* You should never ask for this much metadata */
56988 BUG_ON(bits_wanted >
56989 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
56990 mlog_errno(status);
56991 goto bail;
56992 }
56993 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
56994 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
56995
56996 *suballoc_loc = res.sr_bg_blkno;
56997 *suballoc_bit_start = res.sr_bit_offset;
56998 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
56999 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
57000 res->sr_bits);
57001
57002 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
57003 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
57004
57005 BUG_ON(res->sr_bits != 1);
57006
57007 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
57008 mlog_errno(status);
57009 goto bail;
57010 }
57011 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
57012 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
57013
57014 BUG_ON(res.sr_bits != 1);
57015
57016 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
57017 cluster_start,
57018 num_clusters);
57019 if (!status)
57020 - atomic_inc(&osb->alloc_stats.local_data);
57021 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
57022 } else {
57023 if (min_clusters > (osb->bitmap_cpg - 1)) {
57024 /* The only paths asking for contiguousness
57025 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
57026 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
57027 res.sr_bg_blkno,
57028 res.sr_bit_offset);
57029 - atomic_inc(&osb->alloc_stats.bitmap_data);
57030 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
57031 *num_clusters = res.sr_bits;
57032 }
57033 }
57034 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
57035 index 01b8516..579c4df 100644
57036 --- a/fs/ocfs2/super.c
57037 +++ b/fs/ocfs2/super.c
57038 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
57039 "%10s => GlobalAllocs: %d LocalAllocs: %d "
57040 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
57041 "Stats",
57042 - atomic_read(&osb->alloc_stats.bitmap_data),
57043 - atomic_read(&osb->alloc_stats.local_data),
57044 - atomic_read(&osb->alloc_stats.bg_allocs),
57045 - atomic_read(&osb->alloc_stats.moves),
57046 - atomic_read(&osb->alloc_stats.bg_extends));
57047 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
57048 + atomic_read_unchecked(&osb->alloc_stats.local_data),
57049 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
57050 + atomic_read_unchecked(&osb->alloc_stats.moves),
57051 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
57052
57053 out += snprintf(buf + out, len - out,
57054 "%10s => State: %u Descriptor: %llu Size: %u bits "
57055 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
57056 spin_lock_init(&osb->osb_xattr_lock);
57057 ocfs2_init_steal_slots(osb);
57058
57059 - atomic_set(&osb->alloc_stats.moves, 0);
57060 - atomic_set(&osb->alloc_stats.local_data, 0);
57061 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
57062 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
57063 - atomic_set(&osb->alloc_stats.bg_extends, 0);
57064 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
57065 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
57066 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
57067 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
57068 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
57069
57070 /* Copy the blockcheck stats from the superblock probe */
57071 osb->osb_ecc_stats = *stats;
57072 diff --git a/fs/open.c b/fs/open.c
57073 index 8c74100..4239c48 100644
57074 --- a/fs/open.c
57075 +++ b/fs/open.c
57076 @@ -32,6 +32,8 @@
57077 #include <linux/dnotify.h>
57078 #include <linux/compat.h>
57079
57080 +#define CREATE_TRACE_POINTS
57081 +#include <trace/events/fs.h>
57082 #include "internal.h"
57083
57084 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
57085 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
57086 error = locks_verify_truncate(inode, NULL, length);
57087 if (!error)
57088 error = security_path_truncate(path);
57089 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
57090 + error = -EACCES;
57091 if (!error)
57092 error = do_truncate(path->dentry, length, 0, NULL);
57093
57094 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
57095 error = locks_verify_truncate(inode, f.file, length);
57096 if (!error)
57097 error = security_path_truncate(&f.file->f_path);
57098 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
57099 + error = -EACCES;
57100 if (!error)
57101 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
57102 sb_end_write(inode->i_sb);
57103 @@ -360,6 +366,9 @@ retry:
57104 if (__mnt_is_readonly(path.mnt))
57105 res = -EROFS;
57106
57107 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
57108 + res = -EACCES;
57109 +
57110 out_path_release:
57111 path_put(&path);
57112 if (retry_estale(res, lookup_flags)) {
57113 @@ -391,6 +400,8 @@ retry:
57114 if (error)
57115 goto dput_and_out;
57116
57117 + gr_log_chdir(path.dentry, path.mnt);
57118 +
57119 set_fs_pwd(current->fs, &path);
57120
57121 dput_and_out:
57122 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
57123 goto out_putf;
57124
57125 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
57126 +
57127 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
57128 + error = -EPERM;
57129 +
57130 + if (!error)
57131 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
57132 +
57133 if (!error)
57134 set_fs_pwd(current->fs, &f.file->f_path);
57135 out_putf:
57136 @@ -449,7 +467,13 @@ retry:
57137 if (error)
57138 goto dput_and_out;
57139
57140 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
57141 + goto dput_and_out;
57142 +
57143 set_fs_root(current->fs, &path);
57144 +
57145 + gr_handle_chroot_chdir(&path);
57146 +
57147 error = 0;
57148 dput_and_out:
57149 path_put(&path);
57150 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
57151 if (error)
57152 return error;
57153 mutex_lock(&inode->i_mutex);
57154 +
57155 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
57156 + error = -EACCES;
57157 + goto out_unlock;
57158 + }
57159 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
57160 + error = -EACCES;
57161 + goto out_unlock;
57162 + }
57163 +
57164 error = security_path_chmod(path, mode);
57165 if (error)
57166 goto out_unlock;
57167 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
57168 uid = make_kuid(current_user_ns(), user);
57169 gid = make_kgid(current_user_ns(), group);
57170
57171 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
57172 + return -EACCES;
57173 +
57174 newattrs.ia_valid = ATTR_CTIME;
57175 if (user != (uid_t) -1) {
57176 if (!uid_valid(uid))
57177 @@ -946,6 +983,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
57178 } else {
57179 fsnotify_open(f);
57180 fd_install(fd, f);
57181 + trace_do_sys_open(tmp->name, flags, mode);
57182 }
57183 }
57184 putname(tmp);
57185 diff --git a/fs/pipe.c b/fs/pipe.c
57186 index d2c45e1..009fe1c 100644
57187 --- a/fs/pipe.c
57188 +++ b/fs/pipe.c
57189 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
57190
57191 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
57192 {
57193 - if (pipe->files)
57194 + if (atomic_read(&pipe->files))
57195 mutex_lock_nested(&pipe->mutex, subclass);
57196 }
57197
57198 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
57199
57200 void pipe_unlock(struct pipe_inode_info *pipe)
57201 {
57202 - if (pipe->files)
57203 + if (atomic_read(&pipe->files))
57204 mutex_unlock(&pipe->mutex);
57205 }
57206 EXPORT_SYMBOL(pipe_unlock);
57207 @@ -449,9 +449,9 @@ redo:
57208 }
57209 if (bufs) /* More to do? */
57210 continue;
57211 - if (!pipe->writers)
57212 + if (!atomic_read(&pipe->writers))
57213 break;
57214 - if (!pipe->waiting_writers) {
57215 + if (!atomic_read(&pipe->waiting_writers)) {
57216 /* syscall merging: Usually we must not sleep
57217 * if O_NONBLOCK is set, or if we got some data.
57218 * But if a writer sleeps in kernel space, then
57219 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
57220 ret = 0;
57221 __pipe_lock(pipe);
57222
57223 - if (!pipe->readers) {
57224 + if (!atomic_read(&pipe->readers)) {
57225 send_sig(SIGPIPE, current, 0);
57226 ret = -EPIPE;
57227 goto out;
57228 @@ -562,7 +562,7 @@ redo1:
57229 for (;;) {
57230 int bufs;
57231
57232 - if (!pipe->readers) {
57233 + if (!atomic_read(&pipe->readers)) {
57234 send_sig(SIGPIPE, current, 0);
57235 if (!ret)
57236 ret = -EPIPE;
57237 @@ -653,9 +653,9 @@ redo2:
57238 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
57239 do_wakeup = 0;
57240 }
57241 - pipe->waiting_writers++;
57242 + atomic_inc(&pipe->waiting_writers);
57243 pipe_wait(pipe);
57244 - pipe->waiting_writers--;
57245 + atomic_dec(&pipe->waiting_writers);
57246 }
57247 out:
57248 __pipe_unlock(pipe);
57249 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
57250 mask = 0;
57251 if (filp->f_mode & FMODE_READ) {
57252 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
57253 - if (!pipe->writers && filp->f_version != pipe->w_counter)
57254 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
57255 mask |= POLLHUP;
57256 }
57257
57258 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
57259 * Most Unices do not set POLLERR for FIFOs but on Linux they
57260 * behave exactly like pipes for poll().
57261 */
57262 - if (!pipe->readers)
57263 + if (!atomic_read(&pipe->readers))
57264 mask |= POLLERR;
57265 }
57266
57267 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
57268
57269 __pipe_lock(pipe);
57270 if (file->f_mode & FMODE_READ)
57271 - pipe->readers--;
57272 + atomic_dec(&pipe->readers);
57273 if (file->f_mode & FMODE_WRITE)
57274 - pipe->writers--;
57275 + atomic_dec(&pipe->writers);
57276
57277 - if (pipe->readers || pipe->writers) {
57278 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
57279 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
57280 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
57281 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
57282 }
57283 spin_lock(&inode->i_lock);
57284 - if (!--pipe->files) {
57285 + if (atomic_dec_and_test(&pipe->files)) {
57286 inode->i_pipe = NULL;
57287 kill = 1;
57288 }
57289 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
57290 kfree(pipe);
57291 }
57292
57293 -static struct vfsmount *pipe_mnt __read_mostly;
57294 +struct vfsmount *pipe_mnt __read_mostly;
57295
57296 /*
57297 * pipefs_dname() is called from d_path().
57298 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
57299 goto fail_iput;
57300
57301 inode->i_pipe = pipe;
57302 - pipe->files = 2;
57303 - pipe->readers = pipe->writers = 1;
57304 + atomic_set(&pipe->files, 2);
57305 + atomic_set(&pipe->readers, 1);
57306 + atomic_set(&pipe->writers, 1);
57307 inode->i_fop = &pipefifo_fops;
57308
57309 /*
57310 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
57311 spin_lock(&inode->i_lock);
57312 if (inode->i_pipe) {
57313 pipe = inode->i_pipe;
57314 - pipe->files++;
57315 + atomic_inc(&pipe->files);
57316 spin_unlock(&inode->i_lock);
57317 } else {
57318 spin_unlock(&inode->i_lock);
57319 pipe = alloc_pipe_info();
57320 if (!pipe)
57321 return -ENOMEM;
57322 - pipe->files = 1;
57323 + atomic_set(&pipe->files, 1);
57324 spin_lock(&inode->i_lock);
57325 if (unlikely(inode->i_pipe)) {
57326 - inode->i_pipe->files++;
57327 + atomic_inc(&inode->i_pipe->files);
57328 spin_unlock(&inode->i_lock);
57329 free_pipe_info(pipe);
57330 pipe = inode->i_pipe;
57331 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
57332 * opened, even when there is no process writing the FIFO.
57333 */
57334 pipe->r_counter++;
57335 - if (pipe->readers++ == 0)
57336 + if (atomic_inc_return(&pipe->readers) == 1)
57337 wake_up_partner(pipe);
57338
57339 - if (!is_pipe && !pipe->writers) {
57340 + if (!is_pipe && !atomic_read(&pipe->writers)) {
57341 if ((filp->f_flags & O_NONBLOCK)) {
57342 /* suppress POLLHUP until we have
57343 * seen a writer */
57344 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
57345 * errno=ENXIO when there is no process reading the FIFO.
57346 */
57347 ret = -ENXIO;
57348 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
57349 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
57350 goto err;
57351
57352 pipe->w_counter++;
57353 - if (!pipe->writers++)
57354 + if (atomic_inc_return(&pipe->writers) == 1)
57355 wake_up_partner(pipe);
57356
57357 - if (!is_pipe && !pipe->readers) {
57358 + if (!is_pipe && !atomic_read(&pipe->readers)) {
57359 if (wait_for_partner(pipe, &pipe->r_counter))
57360 goto err_wr;
57361 }
57362 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
57363 * the process can at least talk to itself.
57364 */
57365
57366 - pipe->readers++;
57367 - pipe->writers++;
57368 + atomic_inc(&pipe->readers);
57369 + atomic_inc(&pipe->writers);
57370 pipe->r_counter++;
57371 pipe->w_counter++;
57372 - if (pipe->readers == 1 || pipe->writers == 1)
57373 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
57374 wake_up_partner(pipe);
57375 break;
57376
57377 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
57378 return 0;
57379
57380 err_rd:
57381 - if (!--pipe->readers)
57382 + if (atomic_dec_and_test(&pipe->readers))
57383 wake_up_interruptible(&pipe->wait);
57384 ret = -ERESTARTSYS;
57385 goto err;
57386
57387 err_wr:
57388 - if (!--pipe->writers)
57389 + if (atomic_dec_and_test(&pipe->writers))
57390 wake_up_interruptible(&pipe->wait);
57391 ret = -ERESTARTSYS;
57392 goto err;
57393
57394 err:
57395 spin_lock(&inode->i_lock);
57396 - if (!--pipe->files) {
57397 + if (atomic_dec_and_test(&pipe->files)) {
57398 inode->i_pipe = NULL;
57399 kill = 1;
57400 }
57401 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
57402 index 15af622..0e9f4467 100644
57403 --- a/fs/proc/Kconfig
57404 +++ b/fs/proc/Kconfig
57405 @@ -30,12 +30,12 @@ config PROC_FS
57406
57407 config PROC_KCORE
57408 bool "/proc/kcore support" if !ARM
57409 - depends on PROC_FS && MMU
57410 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
57411
57412 config PROC_VMCORE
57413 bool "/proc/vmcore support"
57414 - depends on PROC_FS && CRASH_DUMP
57415 - default y
57416 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
57417 + default n
57418 help
57419 Exports the dump image of crashed kernel in ELF format.
57420
57421 @@ -59,8 +59,8 @@ config PROC_SYSCTL
57422 limited in memory.
57423
57424 config PROC_PAGE_MONITOR
57425 - default y
57426 - depends on PROC_FS && MMU
57427 + default n
57428 + depends on PROC_FS && MMU && !GRKERNSEC
57429 bool "Enable /proc page monitoring" if EXPERT
57430 help
57431 Various /proc files exist to monitor process memory utilization:
57432 diff --git a/fs/proc/array.c b/fs/proc/array.c
57433 index cbd0f1b..adec3f0 100644
57434 --- a/fs/proc/array.c
57435 +++ b/fs/proc/array.c
57436 @@ -60,6 +60,7 @@
57437 #include <linux/tty.h>
57438 #include <linux/string.h>
57439 #include <linux/mman.h>
57440 +#include <linux/grsecurity.h>
57441 #include <linux/proc_fs.h>
57442 #include <linux/ioport.h>
57443 #include <linux/uaccess.h>
57444 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
57445 seq_putc(m, '\n');
57446 }
57447
57448 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
57449 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
57450 +{
57451 + if (p->mm)
57452 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
57453 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
57454 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
57455 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
57456 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
57457 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
57458 + else
57459 + seq_printf(m, "PaX:\t-----\n");
57460 +}
57461 +#endif
57462 +
57463 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
57464 struct pid *pid, struct task_struct *task)
57465 {
57466 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
57467 task_cpus_allowed(m, task);
57468 cpuset_task_status_allowed(m, task);
57469 task_context_switch_counts(m, task);
57470 +
57471 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
57472 + task_pax(m, task);
57473 +#endif
57474 +
57475 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
57476 + task_grsec_rbac(m, task);
57477 +#endif
57478 +
57479 return 0;
57480 }
57481
57482 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57483 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
57484 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
57485 + _mm->pax_flags & MF_PAX_SEGMEXEC))
57486 +#endif
57487 +
57488 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
57489 struct pid *pid, struct task_struct *task, int whole)
57490 {
57491 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
57492 char tcomm[sizeof(task->comm)];
57493 unsigned long flags;
57494
57495 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57496 + if (current->exec_id != m->exec_id) {
57497 + gr_log_badprocpid("stat");
57498 + return 0;
57499 + }
57500 +#endif
57501 +
57502 state = *get_task_state(task);
57503 vsize = eip = esp = 0;
57504 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
57505 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
57506 gtime = task_gtime(task);
57507 }
57508
57509 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57510 + if (PAX_RAND_FLAGS(mm)) {
57511 + eip = 0;
57512 + esp = 0;
57513 + wchan = 0;
57514 + }
57515 +#endif
57516 +#ifdef CONFIG_GRKERNSEC_HIDESYM
57517 + wchan = 0;
57518 + eip =0;
57519 + esp =0;
57520 +#endif
57521 +
57522 /* scale priority and nice values from timeslices to -20..20 */
57523 /* to make it look like a "normal" Unix priority/nice value */
57524 priority = task_prio(task);
57525 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
57526 seq_put_decimal_ull(m, ' ', vsize);
57527 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
57528 seq_put_decimal_ull(m, ' ', rsslim);
57529 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57530 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
57531 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
57532 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
57533 +#else
57534 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
57535 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
57536 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
57537 +#endif
57538 seq_put_decimal_ull(m, ' ', esp);
57539 seq_put_decimal_ull(m, ' ', eip);
57540 /* The signal information here is obsolete.
57541 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
57542 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
57543 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
57544
57545 - if (mm && permitted) {
57546 + if (mm && permitted
57547 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57548 + && !PAX_RAND_FLAGS(mm)
57549 +#endif
57550 + ) {
57551 seq_put_decimal_ull(m, ' ', mm->start_data);
57552 seq_put_decimal_ull(m, ' ', mm->end_data);
57553 seq_put_decimal_ull(m, ' ', mm->start_brk);
57554 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
57555 struct pid *pid, struct task_struct *task)
57556 {
57557 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
57558 - struct mm_struct *mm = get_task_mm(task);
57559 + struct mm_struct *mm;
57560
57561 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57562 + if (current->exec_id != m->exec_id) {
57563 + gr_log_badprocpid("statm");
57564 + return 0;
57565 + }
57566 +#endif
57567 + mm = get_task_mm(task);
57568 if (mm) {
57569 size = task_statm(mm, &shared, &text, &data, &resident);
57570 mmput(mm);
57571 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
57572 return 0;
57573 }
57574
57575 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
57576 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
57577 +{
57578 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
57579 +}
57580 +#endif
57581 +
57582 #ifdef CONFIG_CHECKPOINT_RESTORE
57583 static struct pid *
57584 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
57585 diff --git a/fs/proc/base.c b/fs/proc/base.c
57586 index c3834da..b402b2b 100644
57587 --- a/fs/proc/base.c
57588 +++ b/fs/proc/base.c
57589 @@ -113,6 +113,14 @@ struct pid_entry {
57590 union proc_op op;
57591 };
57592
57593 +struct getdents_callback {
57594 + struct linux_dirent __user * current_dir;
57595 + struct linux_dirent __user * previous;
57596 + struct file * file;
57597 + int count;
57598 + int error;
57599 +};
57600 +
57601 #define NOD(NAME, MODE, IOP, FOP, OP) { \
57602 .name = (NAME), \
57603 .len = sizeof(NAME) - 1, \
57604 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
57605 if (!mm->arg_end)
57606 goto out_mm; /* Shh! No looking before we're done */
57607
57608 + if (gr_acl_handle_procpidmem(task))
57609 + goto out_mm;
57610 +
57611 len = mm->arg_end - mm->arg_start;
57612
57613 if (len > PAGE_SIZE)
57614 @@ -237,12 +248,28 @@ out:
57615 return res;
57616 }
57617
57618 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57619 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
57620 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
57621 + _mm->pax_flags & MF_PAX_SEGMEXEC))
57622 +#endif
57623 +
57624 static int proc_pid_auxv(struct task_struct *task, char *buffer)
57625 {
57626 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
57627 int res = PTR_ERR(mm);
57628 if (mm && !IS_ERR(mm)) {
57629 unsigned int nwords = 0;
57630 +
57631 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57632 + /* allow if we're currently ptracing this task */
57633 + if (PAX_RAND_FLAGS(mm) &&
57634 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
57635 + mmput(mm);
57636 + return 0;
57637 + }
57638 +#endif
57639 +
57640 do {
57641 nwords += 2;
57642 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
57643 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
57644 }
57645
57646
57647 -#ifdef CONFIG_KALLSYMS
57648 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
57649 /*
57650 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
57651 * Returns the resolved symbol. If that fails, simply return the address.
57652 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
57653 mutex_unlock(&task->signal->cred_guard_mutex);
57654 }
57655
57656 -#ifdef CONFIG_STACKTRACE
57657 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
57658
57659 #define MAX_STACK_TRACE_DEPTH 64
57660
57661 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
57662 return count;
57663 }
57664
57665 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
57666 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
57667 static int proc_pid_syscall(struct task_struct *task, char *buffer)
57668 {
57669 long nr;
57670 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
57671 /************************************************************************/
57672
57673 /* permission checks */
57674 -static int proc_fd_access_allowed(struct inode *inode)
57675 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
57676 {
57677 struct task_struct *task;
57678 int allowed = 0;
57679 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
57680 */
57681 task = get_proc_task(inode);
57682 if (task) {
57683 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
57684 + if (log)
57685 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
57686 + else
57687 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
57688 put_task_struct(task);
57689 }
57690 return allowed;
57691 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
57692 struct task_struct *task,
57693 int hide_pid_min)
57694 {
57695 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
57696 + return false;
57697 +
57698 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
57699 + rcu_read_lock();
57700 + {
57701 + const struct cred *tmpcred = current_cred();
57702 + const struct cred *cred = __task_cred(task);
57703 +
57704 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
57705 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
57706 + || in_group_p(grsec_proc_gid)
57707 +#endif
57708 + ) {
57709 + rcu_read_unlock();
57710 + return true;
57711 + }
57712 + }
57713 + rcu_read_unlock();
57714 +
57715 + if (!pid->hide_pid)
57716 + return false;
57717 +#endif
57718 +
57719 if (pid->hide_pid < hide_pid_min)
57720 return true;
57721 if (in_group_p(pid->pid_gid))
57722 return true;
57723 +
57724 return ptrace_may_access(task, PTRACE_MODE_READ);
57725 }
57726
57727 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
57728 put_task_struct(task);
57729
57730 if (!has_perms) {
57731 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
57732 + {
57733 +#else
57734 if (pid->hide_pid == 2) {
57735 +#endif
57736 /*
57737 * Let's make getdents(), stat(), and open()
57738 * consistent with each other. If a process
57739 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
57740 if (!task)
57741 return -ESRCH;
57742
57743 + if (gr_acl_handle_procpidmem(task)) {
57744 + put_task_struct(task);
57745 + return -EPERM;
57746 + }
57747 +
57748 mm = mm_access(task, mode);
57749 put_task_struct(task);
57750
57751 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
57752
57753 file->private_data = mm;
57754
57755 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57756 + file->f_version = current->exec_id;
57757 +#endif
57758 +
57759 return 0;
57760 }
57761
57762 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
57763 ssize_t copied;
57764 char *page;
57765
57766 +#ifdef CONFIG_GRKERNSEC
57767 + if (write)
57768 + return -EPERM;
57769 +#endif
57770 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57771 + if (file->f_version != current->exec_id) {
57772 + gr_log_badprocpid("mem");
57773 + return 0;
57774 + }
57775 +#endif
57776 +
57777 if (!mm)
57778 return 0;
57779
57780 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
57781 goto free;
57782
57783 while (count > 0) {
57784 - int this_len = min_t(int, count, PAGE_SIZE);
57785 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
57786
57787 if (write && copy_from_user(page, buf, this_len)) {
57788 copied = -EFAULT;
57789 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
57790 if (!mm)
57791 return 0;
57792
57793 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57794 + if (file->f_version != current->exec_id) {
57795 + gr_log_badprocpid("environ");
57796 + return 0;
57797 + }
57798 +#endif
57799 +
57800 page = (char *)__get_free_page(GFP_TEMPORARY);
57801 if (!page)
57802 return -ENOMEM;
57803 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
57804 goto free;
57805 while (count > 0) {
57806 size_t this_len, max_len;
57807 - int retval;
57808 + ssize_t retval;
57809
57810 if (src >= (mm->env_end - mm->env_start))
57811 break;
57812 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
57813 int error = -EACCES;
57814
57815 /* Are we allowed to snoop on the tasks file descriptors? */
57816 - if (!proc_fd_access_allowed(inode))
57817 + if (!proc_fd_access_allowed(inode, 0))
57818 goto out;
57819
57820 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
57821 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
57822 struct path path;
57823
57824 /* Are we allowed to snoop on the tasks file descriptors? */
57825 - if (!proc_fd_access_allowed(inode))
57826 - goto out;
57827 + /* logging this is needed for learning on chromium to work properly,
57828 + but we don't want to flood the logs from 'ps' which does a readlink
57829 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
57830 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
57831 + */
57832 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
57833 + if (!proc_fd_access_allowed(inode,0))
57834 + goto out;
57835 + } else {
57836 + if (!proc_fd_access_allowed(inode,1))
57837 + goto out;
57838 + }
57839
57840 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
57841 if (error)
57842 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
57843 rcu_read_lock();
57844 cred = __task_cred(task);
57845 inode->i_uid = cred->euid;
57846 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
57847 + inode->i_gid = grsec_proc_gid;
57848 +#else
57849 inode->i_gid = cred->egid;
57850 +#endif
57851 rcu_read_unlock();
57852 }
57853 security_task_to_inode(task, inode);
57854 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
57855 return -ENOENT;
57856 }
57857 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
57858 +#ifdef CONFIG_GRKERNSEC_PROC_USER
57859 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
57860 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
57861 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
57862 +#endif
57863 task_dumpable(task)) {
57864 cred = __task_cred(task);
57865 stat->uid = cred->euid;
57866 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
57867 + stat->gid = grsec_proc_gid;
57868 +#else
57869 stat->gid = cred->egid;
57870 +#endif
57871 }
57872 }
57873 rcu_read_unlock();
57874 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
57875
57876 if (task) {
57877 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
57878 +#ifdef CONFIG_GRKERNSEC_PROC_USER
57879 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
57880 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
57881 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
57882 +#endif
57883 task_dumpable(task)) {
57884 rcu_read_lock();
57885 cred = __task_cred(task);
57886 inode->i_uid = cred->euid;
57887 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
57888 + inode->i_gid = grsec_proc_gid;
57889 +#else
57890 inode->i_gid = cred->egid;
57891 +#endif
57892 rcu_read_unlock();
57893 } else {
57894 inode->i_uid = GLOBAL_ROOT_UID;
57895 @@ -2196,6 +2314,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
57896 if (!task)
57897 goto out_no_task;
57898
57899 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
57900 + goto out;
57901 +
57902 /*
57903 * Yes, it does not scale. And it should not. Don't add
57904 * new entries into /proc/<tgid>/ without very good reasons.
57905 @@ -2240,6 +2361,9 @@ static int proc_pident_readdir(struct file *filp,
57906 if (!task)
57907 goto out_no_task;
57908
57909 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
57910 + goto out;
57911 +
57912 ret = 0;
57913 i = filp->f_pos;
57914 switch (i) {
57915 @@ -2653,7 +2777,7 @@ static const struct pid_entry tgid_base_stuff[] = {
57916 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
57917 #endif
57918 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
57919 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
57920 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
57921 INF("syscall", S_IRUGO, proc_pid_syscall),
57922 #endif
57923 INF("cmdline", S_IRUGO, proc_pid_cmdline),
57924 @@ -2678,10 +2802,10 @@ static const struct pid_entry tgid_base_stuff[] = {
57925 #ifdef CONFIG_SECURITY
57926 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
57927 #endif
57928 -#ifdef CONFIG_KALLSYMS
57929 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
57930 INF("wchan", S_IRUGO, proc_pid_wchan),
57931 #endif
57932 -#ifdef CONFIG_STACKTRACE
57933 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
57934 ONE("stack", S_IRUGO, proc_pid_stack),
57935 #endif
57936 #ifdef CONFIG_SCHEDSTATS
57937 @@ -2715,6 +2839,9 @@ static const struct pid_entry tgid_base_stuff[] = {
57938 #ifdef CONFIG_HARDWALL
57939 INF("hardwall", S_IRUGO, proc_pid_hardwall),
57940 #endif
57941 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
57942 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
57943 +#endif
57944 #ifdef CONFIG_USER_NS
57945 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
57946 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
57947 @@ -2847,7 +2974,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
57948 if (!inode)
57949 goto out;
57950
57951 +#ifdef CONFIG_GRKERNSEC_PROC_USER
57952 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
57953 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
57954 + inode->i_gid = grsec_proc_gid;
57955 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
57956 +#else
57957 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
57958 +#endif
57959 inode->i_op = &proc_tgid_base_inode_operations;
57960 inode->i_fop = &proc_tgid_base_operations;
57961 inode->i_flags|=S_IMMUTABLE;
57962 @@ -2885,7 +3019,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
57963 if (!task)
57964 goto out;
57965
57966 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
57967 + goto out_put_task;
57968 +
57969 result = proc_pid_instantiate(dir, dentry, task, NULL);
57970 +out_put_task:
57971 put_task_struct(task);
57972 out:
57973 return result;
57974 @@ -2948,6 +3086,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
57975 static int fake_filldir(void *buf, const char *name, int namelen,
57976 loff_t offset, u64 ino, unsigned d_type)
57977 {
57978 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
57979 + __buf->error = -EINVAL;
57980 return 0;
57981 }
57982
57983 @@ -3007,7 +3147,7 @@ static const struct pid_entry tid_base_stuff[] = {
57984 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
57985 #endif
57986 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
57987 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
57988 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
57989 INF("syscall", S_IRUGO, proc_pid_syscall),
57990 #endif
57991 INF("cmdline", S_IRUGO, proc_pid_cmdline),
57992 @@ -3034,10 +3174,10 @@ static const struct pid_entry tid_base_stuff[] = {
57993 #ifdef CONFIG_SECURITY
57994 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
57995 #endif
57996 -#ifdef CONFIG_KALLSYMS
57997 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
57998 INF("wchan", S_IRUGO, proc_pid_wchan),
57999 #endif
58000 -#ifdef CONFIG_STACKTRACE
58001 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
58002 ONE("stack", S_IRUGO, proc_pid_stack),
58003 #endif
58004 #ifdef CONFIG_SCHEDSTATS
58005 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
58006 index 82676e3..5f8518a 100644
58007 --- a/fs/proc/cmdline.c
58008 +++ b/fs/proc/cmdline.c
58009 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
58010
58011 static int __init proc_cmdline_init(void)
58012 {
58013 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
58014 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
58015 +#else
58016 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
58017 +#endif
58018 return 0;
58019 }
58020 module_init(proc_cmdline_init);
58021 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
58022 index b143471..bb105e5 100644
58023 --- a/fs/proc/devices.c
58024 +++ b/fs/proc/devices.c
58025 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
58026
58027 static int __init proc_devices_init(void)
58028 {
58029 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
58030 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
58031 +#else
58032 proc_create("devices", 0, NULL, &proc_devinfo_operations);
58033 +#endif
58034 return 0;
58035 }
58036 module_init(proc_devices_init);
58037 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
58038 index d7a4a28..0201742 100644
58039 --- a/fs/proc/fd.c
58040 +++ b/fs/proc/fd.c
58041 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
58042 if (!task)
58043 return -ENOENT;
58044
58045 - files = get_files_struct(task);
58046 + if (!gr_acl_handle_procpidmem(task))
58047 + files = get_files_struct(task);
58048 put_task_struct(task);
58049
58050 if (files) {
58051 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
58052 */
58053 int proc_fd_permission(struct inode *inode, int mask)
58054 {
58055 + struct task_struct *task;
58056 int rv = generic_permission(inode, mask);
58057 - if (rv == 0)
58058 - return 0;
58059 +
58060 if (task_pid(current) == proc_pid(inode))
58061 rv = 0;
58062 +
58063 + task = get_proc_task(inode);
58064 + if (task == NULL)
58065 + return rv;
58066 +
58067 + if (gr_acl_handle_procpidmem(task))
58068 + rv = -EACCES;
58069 +
58070 + put_task_struct(task);
58071 +
58072 return rv;
58073 }
58074
58075 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
58076 index 073aea6..0630370 100644
58077 --- a/fs/proc/inode.c
58078 +++ b/fs/proc/inode.c
58079 @@ -23,11 +23,17 @@
58080 #include <linux/slab.h>
58081 #include <linux/mount.h>
58082 #include <linux/magic.h>
58083 +#include <linux/grsecurity.h>
58084
58085 #include <asm/uaccess.h>
58086
58087 #include "internal.h"
58088
58089 +#ifdef CONFIG_PROC_SYSCTL
58090 +extern const struct inode_operations proc_sys_inode_operations;
58091 +extern const struct inode_operations proc_sys_dir_operations;
58092 +#endif
58093 +
58094 static void proc_evict_inode(struct inode *inode)
58095 {
58096 struct proc_dir_entry *de;
58097 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
58098 ns = PROC_I(inode)->ns.ns;
58099 if (ns_ops && ns)
58100 ns_ops->put(ns);
58101 +
58102 +#ifdef CONFIG_PROC_SYSCTL
58103 + if (inode->i_op == &proc_sys_inode_operations ||
58104 + inode->i_op == &proc_sys_dir_operations)
58105 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
58106 +#endif
58107 +
58108 }
58109
58110 static struct kmem_cache * proc_inode_cachep;
58111 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
58112 if (de->mode) {
58113 inode->i_mode = de->mode;
58114 inode->i_uid = de->uid;
58115 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
58116 + inode->i_gid = grsec_proc_gid;
58117 +#else
58118 inode->i_gid = de->gid;
58119 +#endif
58120 }
58121 if (de->size)
58122 inode->i_size = de->size;
58123 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
58124 index d600fb0..3b495fe 100644
58125 --- a/fs/proc/internal.h
58126 +++ b/fs/proc/internal.h
58127 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
58128 struct pid *, struct task_struct *);
58129 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
58130 struct pid *, struct task_struct *);
58131 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
58132 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
58133 +#endif
58134
58135 /*
58136 * base.c
58137 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
58138 index 0a22194..a9fc8c1 100644
58139 --- a/fs/proc/kcore.c
58140 +++ b/fs/proc/kcore.c
58141 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
58142 * the addresses in the elf_phdr on our list.
58143 */
58144 start = kc_offset_to_vaddr(*fpos - elf_buflen);
58145 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
58146 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
58147 + if (tsz > buflen)
58148 tsz = buflen;
58149 -
58150 +
58151 while (buflen) {
58152 struct kcore_list *m;
58153
58154 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
58155 kfree(elf_buf);
58156 } else {
58157 if (kern_addr_valid(start)) {
58158 - unsigned long n;
58159 + char *elf_buf;
58160 + mm_segment_t oldfs;
58161
58162 - n = copy_to_user(buffer, (char *)start, tsz);
58163 - /*
58164 - * We cannot distinguish between fault on source
58165 - * and fault on destination. When this happens
58166 - * we clear too and hope it will trigger the
58167 - * EFAULT again.
58168 - */
58169 - if (n) {
58170 - if (clear_user(buffer + tsz - n,
58171 - n))
58172 + elf_buf = kmalloc(tsz, GFP_KERNEL);
58173 + if (!elf_buf)
58174 + return -ENOMEM;
58175 + oldfs = get_fs();
58176 + set_fs(KERNEL_DS);
58177 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
58178 + set_fs(oldfs);
58179 + if (copy_to_user(buffer, elf_buf, tsz)) {
58180 + kfree(elf_buf);
58181 return -EFAULT;
58182 + }
58183 }
58184 + set_fs(oldfs);
58185 + kfree(elf_buf);
58186 } else {
58187 if (clear_user(buffer, tsz))
58188 return -EFAULT;
58189 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
58190
58191 static int open_kcore(struct inode *inode, struct file *filp)
58192 {
58193 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
58194 + return -EPERM;
58195 +#endif
58196 if (!capable(CAP_SYS_RAWIO))
58197 return -EPERM;
58198 if (kcore_need_update)
58199 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
58200 index 5aa847a..f77c8d4 100644
58201 --- a/fs/proc/meminfo.c
58202 +++ b/fs/proc/meminfo.c
58203 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
58204 vmi.used >> 10,
58205 vmi.largest_chunk >> 10
58206 #ifdef CONFIG_MEMORY_FAILURE
58207 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
58208 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
58209 #endif
58210 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
58211 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
58212 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
58213 index ccfd99b..1b7e255 100644
58214 --- a/fs/proc/nommu.c
58215 +++ b/fs/proc/nommu.c
58216 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
58217 if (len < 1)
58218 len = 1;
58219 seq_printf(m, "%*c", len, ' ');
58220 - seq_path(m, &file->f_path, "");
58221 + seq_path(m, &file->f_path, "\n\\");
58222 }
58223
58224 seq_putc(m, '\n');
58225 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
58226 index 986e832..6e8e859 100644
58227 --- a/fs/proc/proc_net.c
58228 +++ b/fs/proc/proc_net.c
58229 @@ -23,6 +23,7 @@
58230 #include <linux/nsproxy.h>
58231 #include <net/net_namespace.h>
58232 #include <linux/seq_file.h>
58233 +#include <linux/grsecurity.h>
58234
58235 #include "internal.h"
58236
58237 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
58238 struct task_struct *task;
58239 struct nsproxy *ns;
58240 struct net *net = NULL;
58241 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
58242 + const struct cred *cred = current_cred();
58243 +#endif
58244 +
58245 +#ifdef CONFIG_GRKERNSEC_PROC_USER
58246 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
58247 + return net;
58248 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
58249 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
58250 + return net;
58251 +#endif
58252
58253 rcu_read_lock();
58254 task = pid_task(proc_pid(dir), PIDTYPE_PID);
58255 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
58256 index ac05f33..1e6dc7e 100644
58257 --- a/fs/proc/proc_sysctl.c
58258 +++ b/fs/proc/proc_sysctl.c
58259 @@ -13,11 +13,15 @@
58260 #include <linux/module.h>
58261 #include "internal.h"
58262
58263 +extern int gr_handle_chroot_sysctl(const int op);
58264 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
58265 + const int op);
58266 +
58267 static const struct dentry_operations proc_sys_dentry_operations;
58268 static const struct file_operations proc_sys_file_operations;
58269 -static const struct inode_operations proc_sys_inode_operations;
58270 +const struct inode_operations proc_sys_inode_operations;
58271 static const struct file_operations proc_sys_dir_file_operations;
58272 -static const struct inode_operations proc_sys_dir_operations;
58273 +const struct inode_operations proc_sys_dir_operations;
58274
58275 void proc_sys_poll_notify(struct ctl_table_poll *poll)
58276 {
58277 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
58278
58279 err = NULL;
58280 d_set_d_op(dentry, &proc_sys_dentry_operations);
58281 +
58282 + gr_handle_proc_create(dentry, inode);
58283 +
58284 d_add(dentry, inode);
58285
58286 out:
58287 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
58288 struct inode *inode = file_inode(filp);
58289 struct ctl_table_header *head = grab_header(inode);
58290 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
58291 + int op = write ? MAY_WRITE : MAY_READ;
58292 ssize_t error;
58293 size_t res;
58294
58295 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
58296 * and won't be until we finish.
58297 */
58298 error = -EPERM;
58299 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
58300 + if (sysctl_perm(head, table, op))
58301 goto out;
58302
58303 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
58304 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
58305 if (!table->proc_handler)
58306 goto out;
58307
58308 +#ifdef CONFIG_GRKERNSEC
58309 + error = -EPERM;
58310 + if (gr_handle_chroot_sysctl(op))
58311 + goto out;
58312 + dget(filp->f_path.dentry);
58313 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
58314 + dput(filp->f_path.dentry);
58315 + goto out;
58316 + }
58317 + dput(filp->f_path.dentry);
58318 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
58319 + goto out;
58320 + if (write && !capable(CAP_SYS_ADMIN))
58321 + goto out;
58322 +#endif
58323 +
58324 /* careful: calling conventions are nasty here */
58325 res = count;
58326 error = table->proc_handler(table, write, buf, &res, ppos);
58327 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
58328 return -ENOMEM;
58329 } else {
58330 d_set_d_op(child, &proc_sys_dentry_operations);
58331 +
58332 + gr_handle_proc_create(child, inode);
58333 +
58334 d_add(child, inode);
58335 }
58336 } else {
58337 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
58338 if ((*pos)++ < file->f_pos)
58339 return 0;
58340
58341 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
58342 + return 0;
58343 +
58344 if (unlikely(S_ISLNK(table->mode)))
58345 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
58346 else
58347 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
58348 if (IS_ERR(head))
58349 return PTR_ERR(head);
58350
58351 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
58352 + return -ENOENT;
58353 +
58354 generic_fillattr(inode, stat);
58355 if (table)
58356 stat->mode = (stat->mode & S_IFMT) | table->mode;
58357 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
58358 .llseek = generic_file_llseek,
58359 };
58360
58361 -static const struct inode_operations proc_sys_inode_operations = {
58362 +const struct inode_operations proc_sys_inode_operations = {
58363 .permission = proc_sys_permission,
58364 .setattr = proc_sys_setattr,
58365 .getattr = proc_sys_getattr,
58366 };
58367
58368 -static const struct inode_operations proc_sys_dir_operations = {
58369 +const struct inode_operations proc_sys_dir_operations = {
58370 .lookup = proc_sys_lookup,
58371 .permission = proc_sys_permission,
58372 .setattr = proc_sys_setattr,
58373 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
58374 static struct ctl_dir *new_dir(struct ctl_table_set *set,
58375 const char *name, int namelen)
58376 {
58377 - struct ctl_table *table;
58378 + ctl_table_no_const *table;
58379 struct ctl_dir *new;
58380 struct ctl_node *node;
58381 char *new_name;
58382 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
58383 return NULL;
58384
58385 node = (struct ctl_node *)(new + 1);
58386 - table = (struct ctl_table *)(node + 1);
58387 + table = (ctl_table_no_const *)(node + 1);
58388 new_name = (char *)(table + 2);
58389 memcpy(new_name, name, namelen);
58390 new_name[namelen] = '\0';
58391 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
58392 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
58393 struct ctl_table_root *link_root)
58394 {
58395 - struct ctl_table *link_table, *entry, *link;
58396 + ctl_table_no_const *link_table, *link;
58397 + struct ctl_table *entry;
58398 struct ctl_table_header *links;
58399 struct ctl_node *node;
58400 char *link_name;
58401 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
58402 return NULL;
58403
58404 node = (struct ctl_node *)(links + 1);
58405 - link_table = (struct ctl_table *)(node + nr_entries);
58406 + link_table = (ctl_table_no_const *)(node + nr_entries);
58407 link_name = (char *)&link_table[nr_entries + 1];
58408
58409 for (link = link_table, entry = table; entry->procname; link++, entry++) {
58410 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
58411 struct ctl_table_header ***subheader, struct ctl_table_set *set,
58412 struct ctl_table *table)
58413 {
58414 - struct ctl_table *ctl_table_arg = NULL;
58415 - struct ctl_table *entry, *files;
58416 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
58417 + struct ctl_table *entry;
58418 int nr_files = 0;
58419 int nr_dirs = 0;
58420 int err = -ENOMEM;
58421 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
58422 nr_files++;
58423 }
58424
58425 - files = table;
58426 /* If there are mixed files and directories we need a new table */
58427 if (nr_dirs && nr_files) {
58428 - struct ctl_table *new;
58429 + ctl_table_no_const *new;
58430 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
58431 GFP_KERNEL);
58432 if (!files)
58433 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
58434 /* Register everything except a directory full of subdirectories */
58435 if (nr_files || !nr_dirs) {
58436 struct ctl_table_header *header;
58437 - header = __register_sysctl_table(set, path, files);
58438 + header = __register_sysctl_table(set, path, files ? files : table);
58439 if (!header) {
58440 kfree(ctl_table_arg);
58441 goto out;
58442 diff --git a/fs/proc/root.c b/fs/proc/root.c
58443 index 41a6ea9..23eaa92 100644
58444 --- a/fs/proc/root.c
58445 +++ b/fs/proc/root.c
58446 @@ -182,7 +182,15 @@ void __init proc_root_init(void)
58447 #ifdef CONFIG_PROC_DEVICETREE
58448 proc_device_tree_init();
58449 #endif
58450 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
58451 +#ifdef CONFIG_GRKERNSEC_PROC_USER
58452 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
58453 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
58454 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
58455 +#endif
58456 +#else
58457 proc_mkdir("bus", NULL);
58458 +#endif
58459 proc_sys_init();
58460 }
58461
58462 diff --git a/fs/proc/self.c b/fs/proc/self.c
58463 index 6b6a993..807cccc 100644
58464 --- a/fs/proc/self.c
58465 +++ b/fs/proc/self.c
58466 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
58467 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
58468 void *cookie)
58469 {
58470 - char *s = nd_get_link(nd);
58471 + const char *s = nd_get_link(nd);
58472 if (!IS_ERR(s))
58473 kfree(s);
58474 }
58475 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
58476 index 3e636d8..350cc48 100644
58477 --- a/fs/proc/task_mmu.c
58478 +++ b/fs/proc/task_mmu.c
58479 @@ -11,12 +11,19 @@
58480 #include <linux/rmap.h>
58481 #include <linux/swap.h>
58482 #include <linux/swapops.h>
58483 +#include <linux/grsecurity.h>
58484
58485 #include <asm/elf.h>
58486 #include <asm/uaccess.h>
58487 #include <asm/tlbflush.h>
58488 #include "internal.h"
58489
58490 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58491 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58492 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58493 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58494 +#endif
58495 +
58496 void task_mem(struct seq_file *m, struct mm_struct *mm)
58497 {
58498 unsigned long data, text, lib, swap;
58499 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
58500 "VmExe:\t%8lu kB\n"
58501 "VmLib:\t%8lu kB\n"
58502 "VmPTE:\t%8lu kB\n"
58503 - "VmSwap:\t%8lu kB\n",
58504 - hiwater_vm << (PAGE_SHIFT-10),
58505 + "VmSwap:\t%8lu kB\n"
58506 +
58507 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
58508 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
58509 +#endif
58510 +
58511 + ,hiwater_vm << (PAGE_SHIFT-10),
58512 total_vm << (PAGE_SHIFT-10),
58513 mm->locked_vm << (PAGE_SHIFT-10),
58514 mm->pinned_vm << (PAGE_SHIFT-10),
58515 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
58516 data << (PAGE_SHIFT-10),
58517 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
58518 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
58519 - swap << (PAGE_SHIFT-10));
58520 + swap << (PAGE_SHIFT-10)
58521 +
58522 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
58523 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58524 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
58525 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
58526 +#else
58527 + , mm->context.user_cs_base
58528 + , mm->context.user_cs_limit
58529 +#endif
58530 +#endif
58531 +
58532 + );
58533 }
58534
58535 unsigned long task_vsize(struct mm_struct *mm)
58536 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
58537 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
58538 }
58539
58540 - /* We don't show the stack guard page in /proc/maps */
58541 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58542 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
58543 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
58544 +#else
58545 start = vma->vm_start;
58546 - if (stack_guard_page_start(vma, start))
58547 - start += PAGE_SIZE;
58548 end = vma->vm_end;
58549 - if (stack_guard_page_end(vma, end))
58550 - end -= PAGE_SIZE;
58551 +#endif
58552
58553 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
58554 start,
58555 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
58556 flags & VM_WRITE ? 'w' : '-',
58557 flags & VM_EXEC ? 'x' : '-',
58558 flags & VM_MAYSHARE ? 's' : 'p',
58559 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58560 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
58561 +#else
58562 pgoff,
58563 +#endif
58564 MAJOR(dev), MINOR(dev), ino, &len);
58565
58566 /*
58567 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
58568 */
58569 if (file) {
58570 pad_len_spaces(m, len);
58571 - seq_path(m, &file->f_path, "\n");
58572 + seq_path(m, &file->f_path, "\n\\");
58573 goto done;
58574 }
58575
58576 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
58577 * Thread stack in /proc/PID/task/TID/maps or
58578 * the main process stack.
58579 */
58580 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
58581 - vma->vm_end >= mm->start_stack)) {
58582 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
58583 + (vma->vm_start <= mm->start_stack &&
58584 + vma->vm_end >= mm->start_stack)) {
58585 name = "[stack]";
58586 } else {
58587 /* Thread stack in /proc/PID/maps */
58588 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
58589 struct proc_maps_private *priv = m->private;
58590 struct task_struct *task = priv->task;
58591
58592 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58593 + if (current->exec_id != m->exec_id) {
58594 + gr_log_badprocpid("maps");
58595 + return 0;
58596 + }
58597 +#endif
58598 +
58599 show_map_vma(m, vma, is_pid);
58600
58601 if (m->count < m->size) /* vma is copied successfully */
58602 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
58603 .private = &mss,
58604 };
58605
58606 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58607 + if (current->exec_id != m->exec_id) {
58608 + gr_log_badprocpid("smaps");
58609 + return 0;
58610 + }
58611 +#endif
58612 memset(&mss, 0, sizeof mss);
58613 - mss.vma = vma;
58614 - /* mmap_sem is held in m_start */
58615 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
58616 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
58617 -
58618 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58619 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
58620 +#endif
58621 + mss.vma = vma;
58622 + /* mmap_sem is held in m_start */
58623 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
58624 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
58625 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58626 + }
58627 +#endif
58628 show_map_vma(m, vma, is_pid);
58629
58630 seq_printf(m,
58631 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
58632 "KernelPageSize: %8lu kB\n"
58633 "MMUPageSize: %8lu kB\n"
58634 "Locked: %8lu kB\n",
58635 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58636 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
58637 +#else
58638 (vma->vm_end - vma->vm_start) >> 10,
58639 +#endif
58640 mss.resident >> 10,
58641 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
58642 mss.shared_clean >> 10,
58643 @@ -792,14 +843,14 @@ typedef struct {
58644 } pagemap_entry_t;
58645
58646 struct pagemapread {
58647 - int pos, len;
58648 + int pos, len; /* units: PM_ENTRY_BYTES, not bytes */
58649 pagemap_entry_t *buffer;
58650 };
58651
58652 #define PAGEMAP_WALK_SIZE (PMD_SIZE)
58653 #define PAGEMAP_WALK_MASK (PMD_MASK)
58654
58655 -#define PM_ENTRY_BYTES sizeof(u64)
58656 +#define PM_ENTRY_BYTES sizeof(pagemap_entry_t)
58657 #define PM_STATUS_BITS 3
58658 #define PM_STATUS_OFFSET (64 - PM_STATUS_BITS)
58659 #define PM_STATUS_MASK (((1LL << PM_STATUS_BITS) - 1) << PM_STATUS_OFFSET)
58660 @@ -1038,8 +1089,8 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
58661 if (!count)
58662 goto out_task;
58663
58664 - pm.len = PM_ENTRY_BYTES * (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
58665 - pm.buffer = kmalloc(pm.len, GFP_TEMPORARY);
58666 + pm.len = (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
58667 + pm.buffer = kmalloc(pm.len * PM_ENTRY_BYTES, GFP_TEMPORARY);
58668 ret = -ENOMEM;
58669 if (!pm.buffer)
58670 goto out_task;
58671 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
58672 int n;
58673 char buffer[50];
58674
58675 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58676 + if (current->exec_id != m->exec_id) {
58677 + gr_log_badprocpid("numa_maps");
58678 + return 0;
58679 + }
58680 +#endif
58681 +
58682 if (!mm)
58683 return 0;
58684
58685 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
58686 mpol_to_str(buffer, sizeof(buffer), pol);
58687 mpol_cond_put(pol);
58688
58689 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58690 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
58691 +#else
58692 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
58693 +#endif
58694
58695 if (file) {
58696 seq_printf(m, " file=");
58697 - seq_path(m, &file->f_path, "\n\t= ");
58698 + seq_path(m, &file->f_path, "\n\t\\= ");
58699 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
58700 seq_printf(m, " heap");
58701 } else {
58702 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
58703 index 56123a6..5a2f6ec 100644
58704 --- a/fs/proc/task_nommu.c
58705 +++ b/fs/proc/task_nommu.c
58706 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
58707 else
58708 bytes += kobjsize(mm);
58709
58710 - if (current->fs && current->fs->users > 1)
58711 + if (current->fs && atomic_read(&current->fs->users) > 1)
58712 sbytes += kobjsize(current->fs);
58713 else
58714 bytes += kobjsize(current->fs);
58715 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
58716
58717 if (file) {
58718 pad_len_spaces(m, len);
58719 - seq_path(m, &file->f_path, "");
58720 + seq_path(m, &file->f_path, "\n\\");
58721 } else if (mm) {
58722 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
58723
58724 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
58725 index 17f7e08..e4b1529 100644
58726 --- a/fs/proc/vmcore.c
58727 +++ b/fs/proc/vmcore.c
58728 @@ -99,9 +99,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
58729 nr_bytes = count;
58730
58731 /* If pfn is not ram, return zeros for sparse dump files */
58732 - if (pfn_is_ram(pfn) == 0)
58733 - memset(buf, 0, nr_bytes);
58734 - else {
58735 + if (pfn_is_ram(pfn) == 0) {
58736 + if (userbuf) {
58737 + if (clear_user((char __force_user *)buf, nr_bytes))
58738 + return -EFAULT;
58739 + } else
58740 + memset(buf, 0, nr_bytes);
58741 + } else {
58742 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
58743 offset, userbuf);
58744 if (tmp < 0)
58745 @@ -186,7 +190,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
58746 if (tsz > nr_bytes)
58747 tsz = nr_bytes;
58748
58749 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
58750 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
58751 if (tmp < 0)
58752 return tmp;
58753 buflen -= tsz;
58754 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
58755 index b00fcc9..e0c6381 100644
58756 --- a/fs/qnx6/qnx6.h
58757 +++ b/fs/qnx6/qnx6.h
58758 @@ -74,7 +74,7 @@ enum {
58759 BYTESEX_BE,
58760 };
58761
58762 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
58763 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
58764 {
58765 if (sbi->s_bytesex == BYTESEX_LE)
58766 return le64_to_cpu((__force __le64)n);
58767 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
58768 return (__force __fs64)cpu_to_be64(n);
58769 }
58770
58771 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
58772 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
58773 {
58774 if (sbi->s_bytesex == BYTESEX_LE)
58775 return le32_to_cpu((__force __le32)n);
58776 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
58777 index 16e8abb..2dcf914 100644
58778 --- a/fs/quota/netlink.c
58779 +++ b/fs/quota/netlink.c
58780 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
58781 void quota_send_warning(struct kqid qid, dev_t dev,
58782 const char warntype)
58783 {
58784 - static atomic_t seq;
58785 + static atomic_unchecked_t seq;
58786 struct sk_buff *skb;
58787 void *msg_head;
58788 int ret;
58789 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
58790 "VFS: Not enough memory to send quota warning.\n");
58791 return;
58792 }
58793 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
58794 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
58795 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
58796 if (!msg_head) {
58797 printk(KERN_ERR
58798 diff --git a/fs/read_write.c b/fs/read_write.c
58799 index 2cefa41..c7e2fe0 100644
58800 --- a/fs/read_write.c
58801 +++ b/fs/read_write.c
58802 @@ -411,7 +411,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
58803
58804 old_fs = get_fs();
58805 set_fs(get_ds());
58806 - p = (__force const char __user *)buf;
58807 + p = (const char __force_user *)buf;
58808 if (count > MAX_RW_COUNT)
58809 count = MAX_RW_COUNT;
58810 if (file->f_op->write)
58811 diff --git a/fs/readdir.c b/fs/readdir.c
58812 index fee38e0..12fdf47 100644
58813 --- a/fs/readdir.c
58814 +++ b/fs/readdir.c
58815 @@ -17,6 +17,7 @@
58816 #include <linux/security.h>
58817 #include <linux/syscalls.h>
58818 #include <linux/unistd.h>
58819 +#include <linux/namei.h>
58820
58821 #include <asm/uaccess.h>
58822
58823 @@ -67,6 +68,7 @@ struct old_linux_dirent {
58824
58825 struct readdir_callback {
58826 struct old_linux_dirent __user * dirent;
58827 + struct file * file;
58828 int result;
58829 };
58830
58831 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
58832 buf->result = -EOVERFLOW;
58833 return -EOVERFLOW;
58834 }
58835 +
58836 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
58837 + return 0;
58838 +
58839 buf->result++;
58840 dirent = buf->dirent;
58841 if (!access_ok(VERIFY_WRITE, dirent,
58842 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
58843
58844 buf.result = 0;
58845 buf.dirent = dirent;
58846 + buf.file = f.file;
58847
58848 error = vfs_readdir(f.file, fillonedir, &buf);
58849 if (buf.result)
58850 @@ -139,6 +146,7 @@ struct linux_dirent {
58851 struct getdents_callback {
58852 struct linux_dirent __user * current_dir;
58853 struct linux_dirent __user * previous;
58854 + struct file * file;
58855 int count;
58856 int error;
58857 };
58858 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
58859 buf->error = -EOVERFLOW;
58860 return -EOVERFLOW;
58861 }
58862 +
58863 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
58864 + return 0;
58865 +
58866 dirent = buf->previous;
58867 if (dirent) {
58868 if (__put_user(offset, &dirent->d_off))
58869 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
58870 buf.previous = NULL;
58871 buf.count = count;
58872 buf.error = 0;
58873 + buf.file = f.file;
58874
58875 error = vfs_readdir(f.file, filldir, &buf);
58876 if (error >= 0)
58877 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
58878 struct getdents_callback64 {
58879 struct linux_dirent64 __user * current_dir;
58880 struct linux_dirent64 __user * previous;
58881 + struct file *file;
58882 int count;
58883 int error;
58884 };
58885 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
58886 buf->error = -EINVAL; /* only used if we fail.. */
58887 if (reclen > buf->count)
58888 return -EINVAL;
58889 +
58890 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
58891 + return 0;
58892 +
58893 dirent = buf->previous;
58894 if (dirent) {
58895 if (__put_user(offset, &dirent->d_off))
58896 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
58897
58898 buf.current_dir = dirent;
58899 buf.previous = NULL;
58900 + buf.file = f.file;
58901 buf.count = count;
58902 buf.error = 0;
58903
58904 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
58905 error = buf.error;
58906 lastdirent = buf.previous;
58907 if (lastdirent) {
58908 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
58909 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
58910 if (__put_user(d_off, &lastdirent->d_off))
58911 error = -EFAULT;
58912 else
58913 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
58914 index 2b7882b..1c5ef48 100644
58915 --- a/fs/reiserfs/do_balan.c
58916 +++ b/fs/reiserfs/do_balan.c
58917 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
58918 return;
58919 }
58920
58921 - atomic_inc(&(fs_generation(tb->tb_sb)));
58922 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
58923 do_balance_starts(tb);
58924
58925 /* balance leaf returns 0 except if combining L R and S into
58926 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
58927 index 1d48974..2f8f4e0 100644
58928 --- a/fs/reiserfs/procfs.c
58929 +++ b/fs/reiserfs/procfs.c
58930 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
58931 "SMALL_TAILS " : "NO_TAILS ",
58932 replay_only(sb) ? "REPLAY_ONLY " : "",
58933 convert_reiserfs(sb) ? "CONV " : "",
58934 - atomic_read(&r->s_generation_counter),
58935 + atomic_read_unchecked(&r->s_generation_counter),
58936 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
58937 SF(s_do_balance), SF(s_unneeded_left_neighbor),
58938 SF(s_good_search_by_key_reada), SF(s_bmaps),
58939 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
58940 index 157e474..65a6114 100644
58941 --- a/fs/reiserfs/reiserfs.h
58942 +++ b/fs/reiserfs/reiserfs.h
58943 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
58944 /* Comment? -Hans */
58945 wait_queue_head_t s_wait;
58946 /* To be obsoleted soon by per buffer seals.. -Hans */
58947 - atomic_t s_generation_counter; // increased by one every time the
58948 + atomic_unchecked_t s_generation_counter; // increased by one every time the
58949 // tree gets re-balanced
58950 unsigned long s_properties; /* File system properties. Currently holds
58951 on-disk FS format */
58952 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
58953 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
58954
58955 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
58956 -#define get_generation(s) atomic_read (&fs_generation(s))
58957 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
58958 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
58959 #define __fs_changed(gen,s) (gen != get_generation (s))
58960 #define fs_changed(gen,s) \
58961 diff --git a/fs/select.c b/fs/select.c
58962 index 8c1c96c..a0f9b6d 100644
58963 --- a/fs/select.c
58964 +++ b/fs/select.c
58965 @@ -20,6 +20,7 @@
58966 #include <linux/export.h>
58967 #include <linux/slab.h>
58968 #include <linux/poll.h>
58969 +#include <linux/security.h>
58970 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
58971 #include <linux/file.h>
58972 #include <linux/fdtable.h>
58973 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
58974 struct poll_list *walk = head;
58975 unsigned long todo = nfds;
58976
58977 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
58978 if (nfds > rlimit(RLIMIT_NOFILE))
58979 return -EINVAL;
58980
58981 diff --git a/fs/seq_file.c b/fs/seq_file.c
58982 index 774c1eb..b67582a 100644
58983 --- a/fs/seq_file.c
58984 +++ b/fs/seq_file.c
58985 @@ -10,6 +10,7 @@
58986 #include <linux/seq_file.h>
58987 #include <linux/slab.h>
58988 #include <linux/cred.h>
58989 +#include <linux/sched.h>
58990
58991 #include <asm/uaccess.h>
58992 #include <asm/page.h>
58993 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
58994 #ifdef CONFIG_USER_NS
58995 p->user_ns = file->f_cred->user_ns;
58996 #endif
58997 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58998 + p->exec_id = current->exec_id;
58999 +#endif
59000
59001 /*
59002 * Wrappers around seq_open(e.g. swaps_open) need to be
59003 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
59004 return 0;
59005 }
59006 if (!m->buf) {
59007 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
59008 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
59009 if (!m->buf)
59010 return -ENOMEM;
59011 }
59012 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
59013 Eoverflow:
59014 m->op->stop(m, p);
59015 kfree(m->buf);
59016 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
59017 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
59018 return !m->buf ? -ENOMEM : -EAGAIN;
59019 }
59020
59021 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
59022
59023 /* grab buffer if we didn't have one */
59024 if (!m->buf) {
59025 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
59026 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
59027 if (!m->buf)
59028 goto Enomem;
59029 }
59030 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
59031 goto Fill;
59032 m->op->stop(m, p);
59033 kfree(m->buf);
59034 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
59035 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
59036 if (!m->buf)
59037 goto Enomem;
59038 m->count = 0;
59039 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
59040 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
59041 void *data)
59042 {
59043 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
59044 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
59045 int res = -ENOMEM;
59046
59047 if (op) {
59048 diff --git a/fs/splice.c b/fs/splice.c
59049 index d37431d..81c3044 100644
59050 --- a/fs/splice.c
59051 +++ b/fs/splice.c
59052 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
59053 pipe_lock(pipe);
59054
59055 for (;;) {
59056 - if (!pipe->readers) {
59057 + if (!atomic_read(&pipe->readers)) {
59058 send_sig(SIGPIPE, current, 0);
59059 if (!ret)
59060 ret = -EPIPE;
59061 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
59062 page_nr++;
59063 ret += buf->len;
59064
59065 - if (pipe->files)
59066 + if (atomic_read(&pipe->files))
59067 do_wakeup = 1;
59068
59069 if (!--spd->nr_pages)
59070 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
59071 do_wakeup = 0;
59072 }
59073
59074 - pipe->waiting_writers++;
59075 + atomic_inc(&pipe->waiting_writers);
59076 pipe_wait(pipe);
59077 - pipe->waiting_writers--;
59078 + atomic_dec(&pipe->waiting_writers);
59079 }
59080
59081 pipe_unlock(pipe);
59082 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
59083 old_fs = get_fs();
59084 set_fs(get_ds());
59085 /* The cast to a user pointer is valid due to the set_fs() */
59086 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
59087 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
59088 set_fs(old_fs);
59089
59090 return res;
59091 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
59092 old_fs = get_fs();
59093 set_fs(get_ds());
59094 /* The cast to a user pointer is valid due to the set_fs() */
59095 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
59096 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
59097 set_fs(old_fs);
59098
59099 return res;
59100 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
59101 goto err;
59102
59103 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
59104 - vec[i].iov_base = (void __user *) page_address(page);
59105 + vec[i].iov_base = (void __force_user *) page_address(page);
59106 vec[i].iov_len = this_len;
59107 spd.pages[i] = page;
59108 spd.nr_pages++;
59109 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
59110 ops->release(pipe, buf);
59111 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
59112 pipe->nrbufs--;
59113 - if (pipe->files)
59114 + if (atomic_read(&pipe->files))
59115 sd->need_wakeup = true;
59116 }
59117
59118 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
59119 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
59120 {
59121 while (!pipe->nrbufs) {
59122 - if (!pipe->writers)
59123 + if (!atomic_read(&pipe->writers))
59124 return 0;
59125
59126 - if (!pipe->waiting_writers && sd->num_spliced)
59127 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
59128 return 0;
59129
59130 if (sd->flags & SPLICE_F_NONBLOCK)
59131 @@ -1193,7 +1193,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
59132 * out of the pipe right after the splice_to_pipe(). So set
59133 * PIPE_READERS appropriately.
59134 */
59135 - pipe->readers = 1;
59136 + atomic_set(&pipe->readers, 1);
59137
59138 current->splice_pipe = pipe;
59139 }
59140 @@ -1769,9 +1769,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
59141 ret = -ERESTARTSYS;
59142 break;
59143 }
59144 - if (!pipe->writers)
59145 + if (!atomic_read(&pipe->writers))
59146 break;
59147 - if (!pipe->waiting_writers) {
59148 + if (!atomic_read(&pipe->waiting_writers)) {
59149 if (flags & SPLICE_F_NONBLOCK) {
59150 ret = -EAGAIN;
59151 break;
59152 @@ -1803,7 +1803,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
59153 pipe_lock(pipe);
59154
59155 while (pipe->nrbufs >= pipe->buffers) {
59156 - if (!pipe->readers) {
59157 + if (!atomic_read(&pipe->readers)) {
59158 send_sig(SIGPIPE, current, 0);
59159 ret = -EPIPE;
59160 break;
59161 @@ -1816,9 +1816,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
59162 ret = -ERESTARTSYS;
59163 break;
59164 }
59165 - pipe->waiting_writers++;
59166 + atomic_inc(&pipe->waiting_writers);
59167 pipe_wait(pipe);
59168 - pipe->waiting_writers--;
59169 + atomic_dec(&pipe->waiting_writers);
59170 }
59171
59172 pipe_unlock(pipe);
59173 @@ -1854,14 +1854,14 @@ retry:
59174 pipe_double_lock(ipipe, opipe);
59175
59176 do {
59177 - if (!opipe->readers) {
59178 + if (!atomic_read(&opipe->readers)) {
59179 send_sig(SIGPIPE, current, 0);
59180 if (!ret)
59181 ret = -EPIPE;
59182 break;
59183 }
59184
59185 - if (!ipipe->nrbufs && !ipipe->writers)
59186 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
59187 break;
59188
59189 /*
59190 @@ -1958,7 +1958,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
59191 pipe_double_lock(ipipe, opipe);
59192
59193 do {
59194 - if (!opipe->readers) {
59195 + if (!atomic_read(&opipe->readers)) {
59196 send_sig(SIGPIPE, current, 0);
59197 if (!ret)
59198 ret = -EPIPE;
59199 @@ -2003,7 +2003,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
59200 * return EAGAIN if we have the potential of some data in the
59201 * future, otherwise just return 0
59202 */
59203 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
59204 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
59205 ret = -EAGAIN;
59206
59207 pipe_unlock(ipipe);
59208 diff --git a/fs/stat.c b/fs/stat.c
59209 index 04ce1ac..a13dd1e 100644
59210 --- a/fs/stat.c
59211 +++ b/fs/stat.c
59212 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
59213 stat->gid = inode->i_gid;
59214 stat->rdev = inode->i_rdev;
59215 stat->size = i_size_read(inode);
59216 - stat->atime = inode->i_atime;
59217 - stat->mtime = inode->i_mtime;
59218 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
59219 + stat->atime = inode->i_ctime;
59220 + stat->mtime = inode->i_ctime;
59221 + } else {
59222 + stat->atime = inode->i_atime;
59223 + stat->mtime = inode->i_mtime;
59224 + }
59225 stat->ctime = inode->i_ctime;
59226 stat->blksize = (1 << inode->i_blkbits);
59227 stat->blocks = inode->i_blocks;
59228 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
59229 if (retval)
59230 return retval;
59231
59232 - if (inode->i_op->getattr)
59233 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
59234 + if (inode->i_op->getattr) {
59235 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
59236 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
59237 + stat->atime = stat->ctime;
59238 + stat->mtime = stat->ctime;
59239 + }
59240 + return retval;
59241 + }
59242
59243 generic_fillattr(inode, stat);
59244 return 0;
59245 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
59246 index 15c68f9..36a8b3e 100644
59247 --- a/fs/sysfs/bin.c
59248 +++ b/fs/sysfs/bin.c
59249 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
59250 return ret;
59251 }
59252
59253 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
59254 - void *buf, int len, int write)
59255 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
59256 + void *buf, size_t len, int write)
59257 {
59258 struct file *file = vma->vm_file;
59259 struct bin_buffer *bb = file->private_data;
59260 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
59261 - int ret;
59262 + ssize_t ret;
59263
59264 if (!bb->vm_ops)
59265 return -EINVAL;
59266 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
59267 index e8e0e71..79c28ac5 100644
59268 --- a/fs/sysfs/dir.c
59269 +++ b/fs/sysfs/dir.c
59270 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
59271 *
59272 * Returns 31 bit hash of ns + name (so it fits in an off_t )
59273 */
59274 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
59275 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
59276 {
59277 unsigned long hash = init_name_hash();
59278 unsigned int len = strlen(name);
59279 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
59280 struct sysfs_dirent *sd;
59281 int rc;
59282
59283 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
59284 + const char *parent_name = parent_sd->s_name;
59285 +
59286 + mode = S_IFDIR | S_IRWXU;
59287 +
59288 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
59289 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
59290 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
59291 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
59292 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
59293 +#endif
59294 +
59295 /* allocate */
59296 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
59297 if (!sd)
59298 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
59299 index 602f56d..6853db8 100644
59300 --- a/fs/sysfs/file.c
59301 +++ b/fs/sysfs/file.c
59302 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
59303
59304 struct sysfs_open_dirent {
59305 atomic_t refcnt;
59306 - atomic_t event;
59307 + atomic_unchecked_t event;
59308 wait_queue_head_t poll;
59309 struct list_head buffers; /* goes through sysfs_buffer.list */
59310 };
59311 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
59312 if (!sysfs_get_active(attr_sd))
59313 return -ENODEV;
59314
59315 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
59316 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
59317 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
59318
59319 sysfs_put_active(attr_sd);
59320 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
59321 return -ENOMEM;
59322
59323 atomic_set(&new_od->refcnt, 0);
59324 - atomic_set(&new_od->event, 1);
59325 + atomic_set_unchecked(&new_od->event, 1);
59326 init_waitqueue_head(&new_od->poll);
59327 INIT_LIST_HEAD(&new_od->buffers);
59328 goto retry;
59329 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
59330
59331 sysfs_put_active(attr_sd);
59332
59333 - if (buffer->event != atomic_read(&od->event))
59334 + if (buffer->event != atomic_read_unchecked(&od->event))
59335 goto trigger;
59336
59337 return DEFAULT_POLLMASK;
59338 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
59339
59340 od = sd->s_attr.open;
59341 if (od) {
59342 - atomic_inc(&od->event);
59343 + atomic_inc_unchecked(&od->event);
59344 wake_up_interruptible(&od->poll);
59345 }
59346
59347 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
59348 index 8c940df..25b733e 100644
59349 --- a/fs/sysfs/symlink.c
59350 +++ b/fs/sysfs/symlink.c
59351 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
59352
59353 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
59354 {
59355 - char *page = nd_get_link(nd);
59356 + const char *page = nd_get_link(nd);
59357 if (!IS_ERR(page))
59358 free_page((unsigned long)page);
59359 }
59360 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
59361 index 69d4889..a810bd4 100644
59362 --- a/fs/sysv/sysv.h
59363 +++ b/fs/sysv/sysv.h
59364 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
59365 #endif
59366 }
59367
59368 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
59369 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
59370 {
59371 if (sbi->s_bytesex == BYTESEX_PDP)
59372 return PDP_swab((__force __u32)n);
59373 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
59374 index e18b988..f1d4ad0f 100644
59375 --- a/fs/ubifs/io.c
59376 +++ b/fs/ubifs/io.c
59377 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
59378 return err;
59379 }
59380
59381 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
59382 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
59383 {
59384 int err;
59385
59386 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
59387 index c175b4d..8f36a16 100644
59388 --- a/fs/udf/misc.c
59389 +++ b/fs/udf/misc.c
59390 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
59391
59392 u8 udf_tag_checksum(const struct tag *t)
59393 {
59394 - u8 *data = (u8 *)t;
59395 + const u8 *data = (const u8 *)t;
59396 u8 checksum = 0;
59397 int i;
59398 for (i = 0; i < sizeof(struct tag); ++i)
59399 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
59400 index 8d974c4..b82f6ec 100644
59401 --- a/fs/ufs/swab.h
59402 +++ b/fs/ufs/swab.h
59403 @@ -22,7 +22,7 @@ enum {
59404 BYTESEX_BE
59405 };
59406
59407 -static inline u64
59408 +static inline u64 __intentional_overflow(-1)
59409 fs64_to_cpu(struct super_block *sbp, __fs64 n)
59410 {
59411 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
59412 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
59413 return (__force __fs64)cpu_to_be64(n);
59414 }
59415
59416 -static inline u32
59417 +static inline u32 __intentional_overflow(-1)
59418 fs32_to_cpu(struct super_block *sbp, __fs32 n)
59419 {
59420 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
59421 diff --git a/fs/utimes.c b/fs/utimes.c
59422 index f4fb7ec..3fe03c0 100644
59423 --- a/fs/utimes.c
59424 +++ b/fs/utimes.c
59425 @@ -1,6 +1,7 @@
59426 #include <linux/compiler.h>
59427 #include <linux/file.h>
59428 #include <linux/fs.h>
59429 +#include <linux/security.h>
59430 #include <linux/linkage.h>
59431 #include <linux/mount.h>
59432 #include <linux/namei.h>
59433 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
59434 goto mnt_drop_write_and_out;
59435 }
59436 }
59437 +
59438 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
59439 + error = -EACCES;
59440 + goto mnt_drop_write_and_out;
59441 + }
59442 +
59443 mutex_lock(&inode->i_mutex);
59444 error = notify_change(path->dentry, &newattrs);
59445 mutex_unlock(&inode->i_mutex);
59446 diff --git a/fs/xattr.c b/fs/xattr.c
59447 index 3377dff..4d074d9 100644
59448 --- a/fs/xattr.c
59449 +++ b/fs/xattr.c
59450 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
59451 return rc;
59452 }
59453
59454 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
59455 +ssize_t
59456 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
59457 +{
59458 + struct inode *inode = dentry->d_inode;
59459 + ssize_t error;
59460 +
59461 + error = inode_permission(inode, MAY_EXEC);
59462 + if (error)
59463 + return error;
59464 +
59465 + if (inode->i_op->getxattr)
59466 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
59467 + else
59468 + error = -EOPNOTSUPP;
59469 +
59470 + return error;
59471 +}
59472 +EXPORT_SYMBOL(pax_getxattr);
59473 +#endif
59474 +
59475 ssize_t
59476 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
59477 {
59478 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
59479 * Extended attribute SET operations
59480 */
59481 static long
59482 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
59483 +setxattr(struct path *path, const char __user *name, const void __user *value,
59484 size_t size, int flags)
59485 {
59486 int error;
59487 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
59488 posix_acl_fix_xattr_from_user(kvalue, size);
59489 }
59490
59491 - error = vfs_setxattr(d, kname, kvalue, size, flags);
59492 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
59493 + error = -EACCES;
59494 + goto out;
59495 + }
59496 +
59497 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
59498 out:
59499 if (vvalue)
59500 vfree(vvalue);
59501 @@ -377,7 +403,7 @@ retry:
59502 return error;
59503 error = mnt_want_write(path.mnt);
59504 if (!error) {
59505 - error = setxattr(path.dentry, name, value, size, flags);
59506 + error = setxattr(&path, name, value, size, flags);
59507 mnt_drop_write(path.mnt);
59508 }
59509 path_put(&path);
59510 @@ -401,7 +427,7 @@ retry:
59511 return error;
59512 error = mnt_want_write(path.mnt);
59513 if (!error) {
59514 - error = setxattr(path.dentry, name, value, size, flags);
59515 + error = setxattr(&path, name, value, size, flags);
59516 mnt_drop_write(path.mnt);
59517 }
59518 path_put(&path);
59519 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
59520 const void __user *,value, size_t, size, int, flags)
59521 {
59522 struct fd f = fdget(fd);
59523 - struct dentry *dentry;
59524 int error = -EBADF;
59525
59526 if (!f.file)
59527 return error;
59528 - dentry = f.file->f_path.dentry;
59529 - audit_inode(NULL, dentry, 0);
59530 + audit_inode(NULL, f.file->f_path.dentry, 0);
59531 error = mnt_want_write_file(f.file);
59532 if (!error) {
59533 - error = setxattr(dentry, name, value, size, flags);
59534 + error = setxattr(&f.file->f_path, name, value, size, flags);
59535 mnt_drop_write_file(f.file);
59536 }
59537 fdput(f);
59538 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
59539 index 9fbea87..6b19972 100644
59540 --- a/fs/xattr_acl.c
59541 +++ b/fs/xattr_acl.c
59542 @@ -76,8 +76,8 @@ struct posix_acl *
59543 posix_acl_from_xattr(struct user_namespace *user_ns,
59544 const void *value, size_t size)
59545 {
59546 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
59547 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
59548 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
59549 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
59550 int count;
59551 struct posix_acl *acl;
59552 struct posix_acl_entry *acl_e;
59553 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
59554 index 8904284..ee0e14b 100644
59555 --- a/fs/xfs/xfs_bmap.c
59556 +++ b/fs/xfs/xfs_bmap.c
59557 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
59558
59559 #else
59560 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
59561 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
59562 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
59563 #endif /* DEBUG */
59564
59565 /*
59566 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
59567 index 6157424..ac98f6d 100644
59568 --- a/fs/xfs/xfs_dir2_sf.c
59569 +++ b/fs/xfs/xfs_dir2_sf.c
59570 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
59571 }
59572
59573 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
59574 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
59575 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
59576 + char name[sfep->namelen];
59577 + memcpy(name, sfep->name, sfep->namelen);
59578 + if (filldir(dirent, name, sfep->namelen,
59579 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
59580 + *offset = off & 0x7fffffff;
59581 + return 0;
59582 + }
59583 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
59584 off & 0x7fffffff, ino, DT_UNKNOWN)) {
59585 *offset = off & 0x7fffffff;
59586 return 0;
59587 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
59588 index 5e99968..45bd327 100644
59589 --- a/fs/xfs/xfs_ioctl.c
59590 +++ b/fs/xfs/xfs_ioctl.c
59591 @@ -127,7 +127,7 @@ xfs_find_handle(
59592 }
59593
59594 error = -EFAULT;
59595 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
59596 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
59597 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
59598 goto out_put;
59599
59600 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
59601 index ca9ecaa..60100c7 100644
59602 --- a/fs/xfs/xfs_iops.c
59603 +++ b/fs/xfs/xfs_iops.c
59604 @@ -395,7 +395,7 @@ xfs_vn_put_link(
59605 struct nameidata *nd,
59606 void *p)
59607 {
59608 - char *s = nd_get_link(nd);
59609 + const char *s = nd_get_link(nd);
59610
59611 if (!IS_ERR(s))
59612 kfree(s);
59613 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
59614 new file mode 100644
59615 index 0000000..712a85d
59616 --- /dev/null
59617 +++ b/grsecurity/Kconfig
59618 @@ -0,0 +1,1043 @@
59619 +#
59620 +# grecurity configuration
59621 +#
59622 +menu "Memory Protections"
59623 +depends on GRKERNSEC
59624 +
59625 +config GRKERNSEC_KMEM
59626 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
59627 + default y if GRKERNSEC_CONFIG_AUTO
59628 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
59629 + help
59630 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
59631 + be written to or read from to modify or leak the contents of the running
59632 + kernel. /dev/port will also not be allowed to be opened and support
59633 + for /dev/cpu/*/msr will be removed. If you have module
59634 + support disabled, enabling this will close up five ways that are
59635 + currently used to insert malicious code into the running kernel.
59636 +
59637 + Even with all these features enabled, we still highly recommend that
59638 + you use the RBAC system, as it is still possible for an attacker to
59639 + modify the running kernel through privileged I/O granted by ioperm/iopl.
59640 +
59641 + If you are not using XFree86, you may be able to stop this additional
59642 + case by enabling the 'Disable privileged I/O' option. Though nothing
59643 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
59644 + but only to video memory, which is the only writing we allow in this
59645 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
59646 + not be allowed to mprotect it with PROT_WRITE later.
59647 + Enabling this feature will prevent the "cpupower" and "powertop" tools
59648 + from working.
59649 +
59650 + It is highly recommended that you say Y here if you meet all the
59651 + conditions above.
59652 +
59653 +config GRKERNSEC_VM86
59654 + bool "Restrict VM86 mode"
59655 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
59656 + depends on X86_32
59657 +
59658 + help
59659 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
59660 + make use of a special execution mode on 32bit x86 processors called
59661 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
59662 + video cards and will still work with this option enabled. The purpose
59663 + of the option is to prevent exploitation of emulation errors in
59664 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
59665 + Nearly all users should be able to enable this option.
59666 +
59667 +config GRKERNSEC_IO
59668 + bool "Disable privileged I/O"
59669 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
59670 + depends on X86
59671 + select RTC_CLASS
59672 + select RTC_INTF_DEV
59673 + select RTC_DRV_CMOS
59674 +
59675 + help
59676 + If you say Y here, all ioperm and iopl calls will return an error.
59677 + Ioperm and iopl can be used to modify the running kernel.
59678 + Unfortunately, some programs need this access to operate properly,
59679 + the most notable of which are XFree86 and hwclock. hwclock can be
59680 + remedied by having RTC support in the kernel, so real-time
59681 + clock support is enabled if this option is enabled, to ensure
59682 + that hwclock operates correctly. XFree86 still will not
59683 + operate correctly with this option enabled, so DO NOT CHOOSE Y
59684 + IF YOU USE XFree86. If you use XFree86 and you still want to
59685 + protect your kernel against modification, use the RBAC system.
59686 +
59687 +config GRKERNSEC_JIT_HARDEN
59688 + bool "Harden BPF JIT against spray attacks"
59689 + default y if GRKERNSEC_CONFIG_AUTO
59690 + depends on BPF_JIT
59691 + help
59692 + If you say Y here, the native code generated by the kernel's Berkeley
59693 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
59694 + attacks that attempt to fit attacker-beneficial instructions in
59695 + 32bit immediate fields of JIT-generated native instructions. The
59696 + attacker will generally aim to cause an unintended instruction sequence
59697 + of JIT-generated native code to execute by jumping into the middle of
59698 + a generated instruction. This feature effectively randomizes the 32bit
59699 + immediate constants present in the generated code to thwart such attacks.
59700 +
59701 + If you're using KERNEXEC, it's recommended that you enable this option
59702 + to supplement the hardening of the kernel.
59703 +
59704 +config GRKERNSEC_PERF_HARDEN
59705 + bool "Disable unprivileged PERF_EVENTS usage by default"
59706 + default y if GRKERNSEC_CONFIG_AUTO
59707 + depends on PERF_EVENTS
59708 + help
59709 + If you say Y here, the range of acceptable values for the
59710 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
59711 + default to a new value: 3. When the sysctl is set to this value, no
59712 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
59713 +
59714 + Though PERF_EVENTS can be used legitimately for performance monitoring
59715 + and low-level application profiling, it is forced on regardless of
59716 + configuration, has been at fault for several vulnerabilities, and
59717 + creates new opportunities for side channels and other information leaks.
59718 +
59719 + This feature puts PERF_EVENTS into a secure default state and permits
59720 + the administrator to change out of it temporarily if unprivileged
59721 + application profiling is needed.
59722 +
59723 +config GRKERNSEC_RAND_THREADSTACK
59724 + bool "Insert random gaps between thread stacks"
59725 + default y if GRKERNSEC_CONFIG_AUTO
59726 + depends on PAX_RANDMMAP && !PPC
59727 + help
59728 + If you say Y here, a random-sized gap will be enforced between allocated
59729 + thread stacks. Glibc's NPTL and other threading libraries that
59730 + pass MAP_STACK to the kernel for thread stack allocation are supported.
59731 + The implementation currently provides 8 bits of entropy for the gap.
59732 +
59733 + Many distributions do not compile threaded remote services with the
59734 + -fstack-check argument to GCC, causing the variable-sized stack-based
59735 + allocator, alloca(), to not probe the stack on allocation. This
59736 + permits an unbounded alloca() to skip over any guard page and potentially
59737 + modify another thread's stack reliably. An enforced random gap
59738 + reduces the reliability of such an attack and increases the chance
59739 + that such a read/write to another thread's stack instead lands in
59740 + an unmapped area, causing a crash and triggering grsecurity's
59741 + anti-bruteforcing logic.
59742 +
59743 +config GRKERNSEC_PROC_MEMMAP
59744 + bool "Harden ASLR against information leaks and entropy reduction"
59745 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
59746 + depends on PAX_NOEXEC || PAX_ASLR
59747 + help
59748 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
59749 + give no information about the addresses of its mappings if
59750 + PaX features that rely on random addresses are enabled on the task.
59751 + In addition to sanitizing this information and disabling other
59752 + dangerous sources of information, this option causes reads of sensitive
59753 + /proc/<pid> entries where the file descriptor was opened in a different
59754 + task than the one performing the read. Such attempts are logged.
59755 + This option also limits argv/env strings for suid/sgid binaries
59756 + to 512KB to prevent a complete exhaustion of the stack entropy provided
59757 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
59758 + binaries to prevent alternative mmap layouts from being abused.
59759 +
59760 + If you use PaX it is essential that you say Y here as it closes up
59761 + several holes that make full ASLR useless locally.
59762 +
59763 +config GRKERNSEC_BRUTE
59764 + bool "Deter exploit bruteforcing"
59765 + default y if GRKERNSEC_CONFIG_AUTO
59766 + help
59767 + If you say Y here, attempts to bruteforce exploits against forking
59768 + daemons such as apache or sshd, as well as against suid/sgid binaries
59769 + will be deterred. When a child of a forking daemon is killed by PaX
59770 + or crashes due to an illegal instruction or other suspicious signal,
59771 + the parent process will be delayed 30 seconds upon every subsequent
59772 + fork until the administrator is able to assess the situation and
59773 + restart the daemon.
59774 + In the suid/sgid case, the attempt is logged, the user has all their
59775 + existing instances of the suid/sgid binary terminated and will
59776 + be unable to execute any suid/sgid binaries for 15 minutes.
59777 +
59778 + It is recommended that you also enable signal logging in the auditing
59779 + section so that logs are generated when a process triggers a suspicious
59780 + signal.
59781 + If the sysctl option is enabled, a sysctl option with name
59782 + "deter_bruteforce" is created.
59783 +
59784 +
59785 +config GRKERNSEC_MODHARDEN
59786 + bool "Harden module auto-loading"
59787 + default y if GRKERNSEC_CONFIG_AUTO
59788 + depends on MODULES
59789 + help
59790 + If you say Y here, module auto-loading in response to use of some
59791 + feature implemented by an unloaded module will be restricted to
59792 + root users. Enabling this option helps defend against attacks
59793 + by unprivileged users who abuse the auto-loading behavior to
59794 + cause a vulnerable module to load that is then exploited.
59795 +
59796 + If this option prevents a legitimate use of auto-loading for a
59797 + non-root user, the administrator can execute modprobe manually
59798 + with the exact name of the module mentioned in the alert log.
59799 + Alternatively, the administrator can add the module to the list
59800 + of modules loaded at boot by modifying init scripts.
59801 +
59802 + Modification of init scripts will most likely be needed on
59803 + Ubuntu servers with encrypted home directory support enabled,
59804 + as the first non-root user logging in will cause the ecb(aes),
59805 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
59806 +
59807 +config GRKERNSEC_HIDESYM
59808 + bool "Hide kernel symbols"
59809 + default y if GRKERNSEC_CONFIG_AUTO
59810 + select PAX_USERCOPY_SLABS
59811 + help
59812 + If you say Y here, getting information on loaded modules, and
59813 + displaying all kernel symbols through a syscall will be restricted
59814 + to users with CAP_SYS_MODULE. For software compatibility reasons,
59815 + /proc/kallsyms will be restricted to the root user. The RBAC
59816 + system can hide that entry even from root.
59817 +
59818 + This option also prevents leaking of kernel addresses through
59819 + several /proc entries.
59820 +
59821 + Note that this option is only effective provided the following
59822 + conditions are met:
59823 + 1) The kernel using grsecurity is not precompiled by some distribution
59824 + 2) You have also enabled GRKERNSEC_DMESG
59825 + 3) You are using the RBAC system and hiding other files such as your
59826 + kernel image and System.map. Alternatively, enabling this option
59827 + causes the permissions on /boot, /lib/modules, and the kernel
59828 + source directory to change at compile time to prevent
59829 + reading by non-root users.
59830 + If the above conditions are met, this option will aid in providing a
59831 + useful protection against local kernel exploitation of overflows
59832 + and arbitrary read/write vulnerabilities.
59833 +
59834 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
59835 + in addition to this feature.
59836 +
59837 +config GRKERNSEC_KERN_LOCKOUT
59838 + bool "Active kernel exploit response"
59839 + default y if GRKERNSEC_CONFIG_AUTO
59840 + depends on X86 || ARM || PPC || SPARC
59841 + help
59842 + If you say Y here, when a PaX alert is triggered due to suspicious
59843 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
59844 + or an OOPS occurs due to bad memory accesses, instead of just
59845 + terminating the offending process (and potentially allowing
59846 + a subsequent exploit from the same user), we will take one of two
59847 + actions:
59848 + If the user was root, we will panic the system
59849 + If the user was non-root, we will log the attempt, terminate
59850 + all processes owned by the user, then prevent them from creating
59851 + any new processes until the system is restarted
59852 + This deters repeated kernel exploitation/bruteforcing attempts
59853 + and is useful for later forensics.
59854 +
59855 +endmenu
59856 +menu "Role Based Access Control Options"
59857 +depends on GRKERNSEC
59858 +
59859 +config GRKERNSEC_RBAC_DEBUG
59860 + bool
59861 +
59862 +config GRKERNSEC_NO_RBAC
59863 + bool "Disable RBAC system"
59864 + help
59865 + If you say Y here, the /dev/grsec device will be removed from the kernel,
59866 + preventing the RBAC system from being enabled. You should only say Y
59867 + here if you have no intention of using the RBAC system, so as to prevent
59868 + an attacker with root access from misusing the RBAC system to hide files
59869 + and processes when loadable module support and /dev/[k]mem have been
59870 + locked down.
59871 +
59872 +config GRKERNSEC_ACL_HIDEKERN
59873 + bool "Hide kernel processes"
59874 + help
59875 + If you say Y here, all kernel threads will be hidden to all
59876 + processes but those whose subject has the "view hidden processes"
59877 + flag.
59878 +
59879 +config GRKERNSEC_ACL_MAXTRIES
59880 + int "Maximum tries before password lockout"
59881 + default 3
59882 + help
59883 + This option enforces the maximum number of times a user can attempt
59884 + to authorize themselves with the grsecurity RBAC system before being
59885 + denied the ability to attempt authorization again for a specified time.
59886 + The lower the number, the harder it will be to brute-force a password.
59887 +
59888 +config GRKERNSEC_ACL_TIMEOUT
59889 + int "Time to wait after max password tries, in seconds"
59890 + default 30
59891 + help
59892 + This option specifies the time the user must wait after attempting to
59893 + authorize to the RBAC system with the maximum number of invalid
59894 + passwords. The higher the number, the harder it will be to brute-force
59895 + a password.
59896 +
59897 +endmenu
59898 +menu "Filesystem Protections"
59899 +depends on GRKERNSEC
59900 +
59901 +config GRKERNSEC_PROC
59902 + bool "Proc restrictions"
59903 + default y if GRKERNSEC_CONFIG_AUTO
59904 + help
59905 + If you say Y here, the permissions of the /proc filesystem
59906 + will be altered to enhance system security and privacy. You MUST
59907 + choose either a user only restriction or a user and group restriction.
59908 + Depending upon the option you choose, you can either restrict users to
59909 + see only the processes they themselves run, or choose a group that can
59910 + view all processes and files normally restricted to root if you choose
59911 + the "restrict to user only" option. NOTE: If you're running identd or
59912 + ntpd as a non-root user, you will have to run it as the group you
59913 + specify here.
59914 +
59915 +config GRKERNSEC_PROC_USER
59916 + bool "Restrict /proc to user only"
59917 + depends on GRKERNSEC_PROC
59918 + help
59919 + If you say Y here, non-root users will only be able to view their own
59920 + processes, and restricts them from viewing network-related information,
59921 + and viewing kernel symbol and module information.
59922 +
59923 +config GRKERNSEC_PROC_USERGROUP
59924 + bool "Allow special group"
59925 + default y if GRKERNSEC_CONFIG_AUTO
59926 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
59927 + help
59928 + If you say Y here, you will be able to select a group that will be
59929 + able to view all processes and network-related information. If you've
59930 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
59931 + remain hidden. This option is useful if you want to run identd as
59932 + a non-root user. The group you select may also be chosen at boot time
59933 + via "grsec_proc_gid=" on the kernel commandline.
59934 +
59935 +config GRKERNSEC_PROC_GID
59936 + int "GID for special group"
59937 + depends on GRKERNSEC_PROC_USERGROUP
59938 + default 1001
59939 +
59940 +config GRKERNSEC_PROC_ADD
59941 + bool "Additional restrictions"
59942 + default y if GRKERNSEC_CONFIG_AUTO
59943 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
59944 + help
59945 + If you say Y here, additional restrictions will be placed on
59946 + /proc that keep normal users from viewing device information and
59947 + slabinfo information that could be useful for exploits.
59948 +
59949 +config GRKERNSEC_LINK
59950 + bool "Linking restrictions"
59951 + default y if GRKERNSEC_CONFIG_AUTO
59952 + help
59953 + If you say Y here, /tmp race exploits will be prevented, since users
59954 + will no longer be able to follow symlinks owned by other users in
59955 + world-writable +t directories (e.g. /tmp), unless the owner of the
59956 + symlink is the owner of the directory. users will also not be
59957 + able to hardlink to files they do not own. If the sysctl option is
59958 + enabled, a sysctl option with name "linking_restrictions" is created.
59959 +
59960 +config GRKERNSEC_SYMLINKOWN
59961 + bool "Kernel-enforced SymlinksIfOwnerMatch"
59962 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
59963 + help
59964 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
59965 + that prevents it from being used as a security feature. As Apache
59966 + verifies the symlink by performing a stat() against the target of
59967 + the symlink before it is followed, an attacker can setup a symlink
59968 + to point to a same-owned file, then replace the symlink with one
59969 + that targets another user's file just after Apache "validates" the
59970 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
59971 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
59972 + will be in place for the group you specify. If the sysctl option
59973 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
59974 + created.
59975 +
59976 +config GRKERNSEC_SYMLINKOWN_GID
59977 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
59978 + depends on GRKERNSEC_SYMLINKOWN
59979 + default 1006
59980 + help
59981 + Setting this GID determines what group kernel-enforced
59982 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
59983 + is enabled, a sysctl option with name "symlinkown_gid" is created.
59984 +
59985 +config GRKERNSEC_FIFO
59986 + bool "FIFO restrictions"
59987 + default y if GRKERNSEC_CONFIG_AUTO
59988 + help
59989 + If you say Y here, users will not be able to write to FIFOs they don't
59990 + own in world-writable +t directories (e.g. /tmp), unless the owner of
59991 + the FIFO is the same owner of the directory it's held in. If the sysctl
59992 + option is enabled, a sysctl option with name "fifo_restrictions" is
59993 + created.
59994 +
59995 +config GRKERNSEC_SYSFS_RESTRICT
59996 + bool "Sysfs/debugfs restriction"
59997 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
59998 + depends on SYSFS
59999 + help
60000 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
60001 + any filesystem normally mounted under it (e.g. debugfs) will be
60002 + mostly accessible only by root. These filesystems generally provide access
60003 + to hardware and debug information that isn't appropriate for unprivileged
60004 + users of the system. Sysfs and debugfs have also become a large source
60005 + of new vulnerabilities, ranging from infoleaks to local compromise.
60006 + There has been very little oversight with an eye toward security involved
60007 + in adding new exporters of information to these filesystems, so their
60008 + use is discouraged.
60009 + For reasons of compatibility, a few directories have been whitelisted
60010 + for access by non-root users:
60011 + /sys/fs/selinux
60012 + /sys/fs/fuse
60013 + /sys/devices/system/cpu
60014 +
60015 +config GRKERNSEC_ROFS
60016 + bool "Runtime read-only mount protection"
60017 + help
60018 + If you say Y here, a sysctl option with name "romount_protect" will
60019 + be created. By setting this option to 1 at runtime, filesystems
60020 + will be protected in the following ways:
60021 + * No new writable mounts will be allowed
60022 + * Existing read-only mounts won't be able to be remounted read/write
60023 + * Write operations will be denied on all block devices
60024 + This option acts independently of grsec_lock: once it is set to 1,
60025 + it cannot be turned off. Therefore, please be mindful of the resulting
60026 + behavior if this option is enabled in an init script on a read-only
60027 + filesystem. This feature is mainly intended for secure embedded systems.
60028 +
60029 +config GRKERNSEC_DEVICE_SIDECHANNEL
60030 + bool "Eliminate stat/notify-based device sidechannels"
60031 + default y if GRKERNSEC_CONFIG_AUTO
60032 + help
60033 + If you say Y here, timing analyses on block or character
60034 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
60035 + will be thwarted for unprivileged users. If a process without
60036 + CAP_MKNOD stats such a device, the last access and last modify times
60037 + will match the device's create time. No access or modify events
60038 + will be triggered through inotify/dnotify/fanotify for such devices.
60039 + This feature will prevent attacks that may at a minimum
60040 + allow an attacker to determine the administrator's password length.
60041 +
60042 +config GRKERNSEC_CHROOT
60043 + bool "Chroot jail restrictions"
60044 + default y if GRKERNSEC_CONFIG_AUTO
60045 + help
60046 + If you say Y here, you will be able to choose several options that will
60047 + make breaking out of a chrooted jail much more difficult. If you
60048 + encounter no software incompatibilities with the following options, it
60049 + is recommended that you enable each one.
60050 +
60051 +config GRKERNSEC_CHROOT_MOUNT
60052 + bool "Deny mounts"
60053 + default y if GRKERNSEC_CONFIG_AUTO
60054 + depends on GRKERNSEC_CHROOT
60055 + help
60056 + If you say Y here, processes inside a chroot will not be able to
60057 + mount or remount filesystems. If the sysctl option is enabled, a
60058 + sysctl option with name "chroot_deny_mount" is created.
60059 +
60060 +config GRKERNSEC_CHROOT_DOUBLE
60061 + bool "Deny double-chroots"
60062 + default y if GRKERNSEC_CONFIG_AUTO
60063 + depends on GRKERNSEC_CHROOT
60064 + help
60065 + If you say Y here, processes inside a chroot will not be able to chroot
60066 + again outside the chroot. This is a widely used method of breaking
60067 + out of a chroot jail and should not be allowed. If the sysctl
60068 + option is enabled, a sysctl option with name
60069 + "chroot_deny_chroot" is created.
60070 +
60071 +config GRKERNSEC_CHROOT_PIVOT
60072 + bool "Deny pivot_root in chroot"
60073 + default y if GRKERNSEC_CONFIG_AUTO
60074 + depends on GRKERNSEC_CHROOT
60075 + help
60076 + If you say Y here, processes inside a chroot will not be able to use
60077 + a function called pivot_root() that was introduced in Linux 2.3.41. It
60078 + works similar to chroot in that it changes the root filesystem. This
60079 + function could be misused in a chrooted process to attempt to break out
60080 + of the chroot, and therefore should not be allowed. If the sysctl
60081 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
60082 + created.
60083 +
60084 +config GRKERNSEC_CHROOT_CHDIR
60085 + bool "Enforce chdir(\"/\") on all chroots"
60086 + default y if GRKERNSEC_CONFIG_AUTO
60087 + depends on GRKERNSEC_CHROOT
60088 + help
60089 + If you say Y here, the current working directory of all newly-chrooted
60090 + applications will be set to the the root directory of the chroot.
60091 + The man page on chroot(2) states:
60092 + Note that this call does not change the current working
60093 + directory, so that `.' can be outside the tree rooted at
60094 + `/'. In particular, the super-user can escape from a
60095 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
60096 +
60097 + It is recommended that you say Y here, since it's not known to break
60098 + any software. If the sysctl option is enabled, a sysctl option with
60099 + name "chroot_enforce_chdir" is created.
60100 +
60101 +config GRKERNSEC_CHROOT_CHMOD
60102 + bool "Deny (f)chmod +s"
60103 + default y if GRKERNSEC_CONFIG_AUTO
60104 + depends on GRKERNSEC_CHROOT
60105 + help
60106 + If you say Y here, processes inside a chroot will not be able to chmod
60107 + or fchmod files to make them have suid or sgid bits. This protects
60108 + against another published method of breaking a chroot. If the sysctl
60109 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
60110 + created.
60111 +
60112 +config GRKERNSEC_CHROOT_FCHDIR
60113 + bool "Deny fchdir out of chroot"
60114 + default y if GRKERNSEC_CONFIG_AUTO
60115 + depends on GRKERNSEC_CHROOT
60116 + help
60117 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
60118 + to a file descriptor of the chrooting process that points to a directory
60119 + outside the filesystem will be stopped. If the sysctl option
60120 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
60121 +
60122 +config GRKERNSEC_CHROOT_MKNOD
60123 + bool "Deny mknod"
60124 + default y if GRKERNSEC_CONFIG_AUTO
60125 + depends on GRKERNSEC_CHROOT
60126 + help
60127 + If you say Y here, processes inside a chroot will not be allowed to
60128 + mknod. The problem with using mknod inside a chroot is that it
60129 + would allow an attacker to create a device entry that is the same
60130 + as one on the physical root of your system, which could range from
60131 + anything from the console device to a device for your harddrive (which
60132 + they could then use to wipe the drive or steal data). It is recommended
60133 + that you say Y here, unless you run into software incompatibilities.
60134 + If the sysctl option is enabled, a sysctl option with name
60135 + "chroot_deny_mknod" is created.
60136 +
60137 +config GRKERNSEC_CHROOT_SHMAT
60138 + bool "Deny shmat() out of chroot"
60139 + default y if GRKERNSEC_CONFIG_AUTO
60140 + depends on GRKERNSEC_CHROOT
60141 + help
60142 + If you say Y here, processes inside a chroot will not be able to attach
60143 + to shared memory segments that were created outside of the chroot jail.
60144 + It is recommended that you say Y here. If the sysctl option is enabled,
60145 + a sysctl option with name "chroot_deny_shmat" is created.
60146 +
60147 +config GRKERNSEC_CHROOT_UNIX
60148 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
60149 + default y if GRKERNSEC_CONFIG_AUTO
60150 + depends on GRKERNSEC_CHROOT
60151 + help
60152 + If you say Y here, processes inside a chroot will not be able to
60153 + connect to abstract (meaning not belonging to a filesystem) Unix
60154 + domain sockets that were bound outside of a chroot. It is recommended
60155 + that you say Y here. If the sysctl option is enabled, a sysctl option
60156 + with name "chroot_deny_unix" is created.
60157 +
60158 +config GRKERNSEC_CHROOT_FINDTASK
60159 + bool "Protect outside processes"
60160 + default y if GRKERNSEC_CONFIG_AUTO
60161 + depends on GRKERNSEC_CHROOT
60162 + help
60163 + If you say Y here, processes inside a chroot will not be able to
60164 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
60165 + getsid, or view any process outside of the chroot. If the sysctl
60166 + option is enabled, a sysctl option with name "chroot_findtask" is
60167 + created.
60168 +
60169 +config GRKERNSEC_CHROOT_NICE
60170 + bool "Restrict priority changes"
60171 + default y if GRKERNSEC_CONFIG_AUTO
60172 + depends on GRKERNSEC_CHROOT
60173 + help
60174 + If you say Y here, processes inside a chroot will not be able to raise
60175 + the priority of processes in the chroot, or alter the priority of
60176 + processes outside the chroot. This provides more security than simply
60177 + removing CAP_SYS_NICE from the process' capability set. If the
60178 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
60179 + is created.
60180 +
60181 +config GRKERNSEC_CHROOT_SYSCTL
60182 + bool "Deny sysctl writes"
60183 + default y if GRKERNSEC_CONFIG_AUTO
60184 + depends on GRKERNSEC_CHROOT
60185 + help
60186 + If you say Y here, an attacker in a chroot will not be able to
60187 + write to sysctl entries, either by sysctl(2) or through a /proc
60188 + interface. It is strongly recommended that you say Y here. If the
60189 + sysctl option is enabled, a sysctl option with name
60190 + "chroot_deny_sysctl" is created.
60191 +
60192 +config GRKERNSEC_CHROOT_CAPS
60193 + bool "Capability restrictions"
60194 + default y if GRKERNSEC_CONFIG_AUTO
60195 + depends on GRKERNSEC_CHROOT
60196 + help
60197 + If you say Y here, the capabilities on all processes within a
60198 + chroot jail will be lowered to stop module insertion, raw i/o,
60199 + system and net admin tasks, rebooting the system, modifying immutable
60200 + files, modifying IPC owned by another, and changing the system time.
60201 + This is left an option because it can break some apps. Disable this
60202 + if your chrooted apps are having problems performing those kinds of
60203 + tasks. If the sysctl option is enabled, a sysctl option with
60204 + name "chroot_caps" is created.
60205 +
60206 +config GRKERNSEC_CHROOT_INITRD
60207 + bool "Exempt initrd tasks from restrictions"
60208 + default y if GRKERNSEC_CONFIG_AUTO
60209 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
60210 + help
60211 + If you say Y here, tasks started prior to init will be exempted from
60212 + grsecurity's chroot restrictions. This option is mainly meant to
60213 + resolve Plymouth's performing privileged operations unnecessarily
60214 + in a chroot.
60215 +
60216 +endmenu
60217 +menu "Kernel Auditing"
60218 +depends on GRKERNSEC
60219 +
60220 +config GRKERNSEC_AUDIT_GROUP
60221 + bool "Single group for auditing"
60222 + help
60223 + If you say Y here, the exec and chdir logging features will only operate
60224 + on a group you specify. This option is recommended if you only want to
60225 + watch certain users instead of having a large amount of logs from the
60226 + entire system. If the sysctl option is enabled, a sysctl option with
60227 + name "audit_group" is created.
60228 +
60229 +config GRKERNSEC_AUDIT_GID
60230 + int "GID for auditing"
60231 + depends on GRKERNSEC_AUDIT_GROUP
60232 + default 1007
60233 +
60234 +config GRKERNSEC_EXECLOG
60235 + bool "Exec logging"
60236 + help
60237 + If you say Y here, all execve() calls will be logged (since the
60238 + other exec*() calls are frontends to execve(), all execution
60239 + will be logged). Useful for shell-servers that like to keep track
60240 + of their users. If the sysctl option is enabled, a sysctl option with
60241 + name "exec_logging" is created.
60242 + WARNING: This option when enabled will produce a LOT of logs, especially
60243 + on an active system.
60244 +
60245 +config GRKERNSEC_RESLOG
60246 + bool "Resource logging"
60247 + default y if GRKERNSEC_CONFIG_AUTO
60248 + help
60249 + If you say Y here, all attempts to overstep resource limits will
60250 + be logged with the resource name, the requested size, and the current
60251 + limit. It is highly recommended that you say Y here. If the sysctl
60252 + option is enabled, a sysctl option with name "resource_logging" is
60253 + created. If the RBAC system is enabled, the sysctl value is ignored.
60254 +
60255 +config GRKERNSEC_CHROOT_EXECLOG
60256 + bool "Log execs within chroot"
60257 + help
60258 + If you say Y here, all executions inside a chroot jail will be logged
60259 + to syslog. This can cause a large amount of logs if certain
60260 + applications (eg. djb's daemontools) are installed on the system, and
60261 + is therefore left as an option. If the sysctl option is enabled, a
60262 + sysctl option with name "chroot_execlog" is created.
60263 +
60264 +config GRKERNSEC_AUDIT_PTRACE
60265 + bool "Ptrace logging"
60266 + help
60267 + If you say Y here, all attempts to attach to a process via ptrace
60268 + will be logged. If the sysctl option is enabled, a sysctl option
60269 + with name "audit_ptrace" is created.
60270 +
60271 +config GRKERNSEC_AUDIT_CHDIR
60272 + bool "Chdir logging"
60273 + help
60274 + If you say Y here, all chdir() calls will be logged. If the sysctl
60275 + option is enabled, a sysctl option with name "audit_chdir" is created.
60276 +
60277 +config GRKERNSEC_AUDIT_MOUNT
60278 + bool "(Un)Mount logging"
60279 + help
60280 + If you say Y here, all mounts and unmounts will be logged. If the
60281 + sysctl option is enabled, a sysctl option with name "audit_mount" is
60282 + created.
60283 +
60284 +config GRKERNSEC_SIGNAL
60285 + bool "Signal logging"
60286 + default y if GRKERNSEC_CONFIG_AUTO
60287 + help
60288 + If you say Y here, certain important signals will be logged, such as
60289 + SIGSEGV, which will as a result inform you of when a error in a program
60290 + occurred, which in some cases could mean a possible exploit attempt.
60291 + If the sysctl option is enabled, a sysctl option with name
60292 + "signal_logging" is created.
60293 +
60294 +config GRKERNSEC_FORKFAIL
60295 + bool "Fork failure logging"
60296 + help
60297 + If you say Y here, all failed fork() attempts will be logged.
60298 + This could suggest a fork bomb, or someone attempting to overstep
60299 + their process limit. If the sysctl option is enabled, a sysctl option
60300 + with name "forkfail_logging" is created.
60301 +
60302 +config GRKERNSEC_TIME
60303 + bool "Time change logging"
60304 + default y if GRKERNSEC_CONFIG_AUTO
60305 + help
60306 + If you say Y here, any changes of the system clock will be logged.
60307 + If the sysctl option is enabled, a sysctl option with name
60308 + "timechange_logging" is created.
60309 +
60310 +config GRKERNSEC_PROC_IPADDR
60311 + bool "/proc/<pid>/ipaddr support"
60312 + default y if GRKERNSEC_CONFIG_AUTO
60313 + help
60314 + If you say Y here, a new entry will be added to each /proc/<pid>
60315 + directory that contains the IP address of the person using the task.
60316 + The IP is carried across local TCP and AF_UNIX stream sockets.
60317 + This information can be useful for IDS/IPSes to perform remote response
60318 + to a local attack. The entry is readable by only the owner of the
60319 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
60320 + the RBAC system), and thus does not create privacy concerns.
60321 +
60322 +config GRKERNSEC_RWXMAP_LOG
60323 + bool 'Denied RWX mmap/mprotect logging'
60324 + default y if GRKERNSEC_CONFIG_AUTO
60325 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
60326 + help
60327 + If you say Y here, calls to mmap() and mprotect() with explicit
60328 + usage of PROT_WRITE and PROT_EXEC together will be logged when
60329 + denied by the PAX_MPROTECT feature. This feature will also
60330 + log other problematic scenarios that can occur when PAX_MPROTECT
60331 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
60332 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
60333 + is created.
60334 +
60335 +endmenu
60336 +
60337 +menu "Executable Protections"
60338 +depends on GRKERNSEC
60339 +
60340 +config GRKERNSEC_DMESG
60341 + bool "Dmesg(8) restriction"
60342 + default y if GRKERNSEC_CONFIG_AUTO
60343 + help
60344 + If you say Y here, non-root users will not be able to use dmesg(8)
60345 + to view the contents of the kernel's circular log buffer.
60346 + The kernel's log buffer often contains kernel addresses and other
60347 + identifying information useful to an attacker in fingerprinting a
60348 + system for a targeted exploit.
60349 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
60350 + created.
60351 +
60352 +config GRKERNSEC_HARDEN_PTRACE
60353 + bool "Deter ptrace-based process snooping"
60354 + default y if GRKERNSEC_CONFIG_AUTO
60355 + help
60356 + If you say Y here, TTY sniffers and other malicious monitoring
60357 + programs implemented through ptrace will be defeated. If you
60358 + have been using the RBAC system, this option has already been
60359 + enabled for several years for all users, with the ability to make
60360 + fine-grained exceptions.
60361 +
60362 + This option only affects the ability of non-root users to ptrace
60363 + processes that are not a descendent of the ptracing process.
60364 + This means that strace ./binary and gdb ./binary will still work,
60365 + but attaching to arbitrary processes will not. If the sysctl
60366 + option is enabled, a sysctl option with name "harden_ptrace" is
60367 + created.
60368 +
60369 +config GRKERNSEC_PTRACE_READEXEC
60370 + bool "Require read access to ptrace sensitive binaries"
60371 + default y if GRKERNSEC_CONFIG_AUTO
60372 + help
60373 + If you say Y here, unprivileged users will not be able to ptrace unreadable
60374 + binaries. This option is useful in environments that
60375 + remove the read bits (e.g. file mode 4711) from suid binaries to
60376 + prevent infoleaking of their contents. This option adds
60377 + consistency to the use of that file mode, as the binary could normally
60378 + be read out when run without privileges while ptracing.
60379 +
60380 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
60381 + is created.
60382 +
60383 +config GRKERNSEC_SETXID
60384 + bool "Enforce consistent multithreaded privileges"
60385 + default y if GRKERNSEC_CONFIG_AUTO
60386 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
60387 + help
60388 + If you say Y here, a change from a root uid to a non-root uid
60389 + in a multithreaded application will cause the resulting uids,
60390 + gids, supplementary groups, and capabilities in that thread
60391 + to be propagated to the other threads of the process. In most
60392 + cases this is unnecessary, as glibc will emulate this behavior
60393 + on behalf of the application. Other libcs do not act in the
60394 + same way, allowing the other threads of the process to continue
60395 + running with root privileges. If the sysctl option is enabled,
60396 + a sysctl option with name "consistent_setxid" is created.
60397 +
60398 +config GRKERNSEC_TPE
60399 + bool "Trusted Path Execution (TPE)"
60400 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
60401 + help
60402 + If you say Y here, you will be able to choose a gid to add to the
60403 + supplementary groups of users you want to mark as "untrusted."
60404 + These users will not be able to execute any files that are not in
60405 + root-owned directories writable only by root. If the sysctl option
60406 + is enabled, a sysctl option with name "tpe" is created.
60407 +
60408 +config GRKERNSEC_TPE_ALL
60409 + bool "Partially restrict all non-root users"
60410 + depends on GRKERNSEC_TPE
60411 + help
60412 + If you say Y here, all non-root users will be covered under
60413 + a weaker TPE restriction. This is separate from, and in addition to,
60414 + the main TPE options that you have selected elsewhere. Thus, if a
60415 + "trusted" GID is chosen, this restriction applies to even that GID.
60416 + Under this restriction, all non-root users will only be allowed to
60417 + execute files in directories they own that are not group or
60418 + world-writable, or in directories owned by root and writable only by
60419 + root. If the sysctl option is enabled, a sysctl option with name
60420 + "tpe_restrict_all" is created.
60421 +
60422 +config GRKERNSEC_TPE_INVERT
60423 + bool "Invert GID option"
60424 + depends on GRKERNSEC_TPE
60425 + help
60426 + If you say Y here, the group you specify in the TPE configuration will
60427 + decide what group TPE restrictions will be *disabled* for. This
60428 + option is useful if you want TPE restrictions to be applied to most
60429 + users on the system. If the sysctl option is enabled, a sysctl option
60430 + with name "tpe_invert" is created. Unlike other sysctl options, this
60431 + entry will default to on for backward-compatibility.
60432 +
60433 +config GRKERNSEC_TPE_GID
60434 + int
60435 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
60436 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
60437 +
60438 +config GRKERNSEC_TPE_UNTRUSTED_GID
60439 + int "GID for TPE-untrusted users"
60440 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
60441 + default 1005
60442 + help
60443 + Setting this GID determines what group TPE restrictions will be
60444 + *enabled* for. If the sysctl option is enabled, a sysctl option
60445 + with name "tpe_gid" is created.
60446 +
60447 +config GRKERNSEC_TPE_TRUSTED_GID
60448 + int "GID for TPE-trusted users"
60449 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
60450 + default 1005
60451 + help
60452 + Setting this GID determines what group TPE restrictions will be
60453 + *disabled* for. If the sysctl option is enabled, a sysctl option
60454 + with name "tpe_gid" is created.
60455 +
60456 +endmenu
60457 +menu "Network Protections"
60458 +depends on GRKERNSEC
60459 +
60460 +config GRKERNSEC_RANDNET
60461 + bool "Larger entropy pools"
60462 + default y if GRKERNSEC_CONFIG_AUTO
60463 + help
60464 + If you say Y here, the entropy pools used for many features of Linux
60465 + and grsecurity will be doubled in size. Since several grsecurity
60466 + features use additional randomness, it is recommended that you say Y
60467 + here. Saying Y here has a similar effect as modifying
60468 + /proc/sys/kernel/random/poolsize.
60469 +
60470 +config GRKERNSEC_BLACKHOLE
60471 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
60472 + default y if GRKERNSEC_CONFIG_AUTO
60473 + depends on NET
60474 + help
60475 + If you say Y here, neither TCP resets nor ICMP
60476 + destination-unreachable packets will be sent in response to packets
60477 + sent to ports for which no associated listening process exists.
60478 + This feature supports both IPV4 and IPV6 and exempts the
60479 + loopback interface from blackholing. Enabling this feature
60480 + makes a host more resilient to DoS attacks and reduces network
60481 + visibility against scanners.
60482 +
60483 + The blackhole feature as-implemented is equivalent to the FreeBSD
60484 + blackhole feature, as it prevents RST responses to all packets, not
60485 + just SYNs. Under most application behavior this causes no
60486 + problems, but applications (like haproxy) may not close certain
60487 + connections in a way that cleanly terminates them on the remote
60488 + end, leaving the remote host in LAST_ACK state. Because of this
60489 + side-effect and to prevent intentional LAST_ACK DoSes, this
60490 + feature also adds automatic mitigation against such attacks.
60491 + The mitigation drastically reduces the amount of time a socket
60492 + can spend in LAST_ACK state. If you're using haproxy and not
60493 + all servers it connects to have this option enabled, consider
60494 + disabling this feature on the haproxy host.
60495 +
60496 + If the sysctl option is enabled, two sysctl options with names
60497 + "ip_blackhole" and "lastack_retries" will be created.
60498 + While "ip_blackhole" takes the standard zero/non-zero on/off
60499 + toggle, "lastack_retries" uses the same kinds of values as
60500 + "tcp_retries1" and "tcp_retries2". The default value of 4
60501 + prevents a socket from lasting more than 45 seconds in LAST_ACK
60502 + state.
60503 +
60504 +config GRKERNSEC_NO_SIMULT_CONNECT
60505 + bool "Disable TCP Simultaneous Connect"
60506 + default y if GRKERNSEC_CONFIG_AUTO
60507 + depends on NET
60508 + help
60509 + If you say Y here, a feature by Willy Tarreau will be enabled that
60510 + removes a weakness in Linux's strict implementation of TCP that
60511 + allows two clients to connect to each other without either entering
60512 + a listening state. The weakness allows an attacker to easily prevent
60513 + a client from connecting to a known server provided the source port
60514 + for the connection is guessed correctly.
60515 +
60516 + As the weakness could be used to prevent an antivirus or IPS from
60517 + fetching updates, or prevent an SSL gateway from fetching a CRL,
60518 + it should be eliminated by enabling this option. Though Linux is
60519 + one of few operating systems supporting simultaneous connect, it
60520 + has no legitimate use in practice and is rarely supported by firewalls.
60521 +
60522 +config GRKERNSEC_SOCKET
60523 + bool "Socket restrictions"
60524 + depends on NET
60525 + help
60526 + If you say Y here, you will be able to choose from several options.
60527 + If you assign a GID on your system and add it to the supplementary
60528 + groups of users you want to restrict socket access to, this patch
60529 + will perform up to three things, based on the option(s) you choose.
60530 +
60531 +config GRKERNSEC_SOCKET_ALL
60532 + bool "Deny any sockets to group"
60533 + depends on GRKERNSEC_SOCKET
60534 + help
60535 + If you say Y here, you will be able to choose a GID of whose users will
60536 + be unable to connect to other hosts from your machine or run server
60537 + applications from your machine. If the sysctl option is enabled, a
60538 + sysctl option with name "socket_all" is created.
60539 +
60540 +config GRKERNSEC_SOCKET_ALL_GID
60541 + int "GID to deny all sockets for"
60542 + depends on GRKERNSEC_SOCKET_ALL
60543 + default 1004
60544 + help
60545 + Here you can choose the GID to disable socket access for. Remember to
60546 + add the users you want socket access disabled for to the GID
60547 + specified here. If the sysctl option is enabled, a sysctl option
60548 + with name "socket_all_gid" is created.
60549 +
60550 +config GRKERNSEC_SOCKET_CLIENT
60551 + bool "Deny client sockets to group"
60552 + depends on GRKERNSEC_SOCKET
60553 + help
60554 + If you say Y here, you will be able to choose a GID of whose users will
60555 + be unable to connect to other hosts from your machine, but will be
60556 + able to run servers. If this option is enabled, all users in the group
60557 + you specify will have to use passive mode when initiating ftp transfers
60558 + from the shell on your machine. If the sysctl option is enabled, a
60559 + sysctl option with name "socket_client" is created.
60560 +
60561 +config GRKERNSEC_SOCKET_CLIENT_GID
60562 + int "GID to deny client sockets for"
60563 + depends on GRKERNSEC_SOCKET_CLIENT
60564 + default 1003
60565 + help
60566 + Here you can choose the GID to disable client socket access for.
60567 + Remember to add the users you want client socket access disabled for to
60568 + the GID specified here. If the sysctl option is enabled, a sysctl
60569 + option with name "socket_client_gid" is created.
60570 +
60571 +config GRKERNSEC_SOCKET_SERVER
60572 + bool "Deny server sockets to group"
60573 + depends on GRKERNSEC_SOCKET
60574 + help
60575 + If you say Y here, you will be able to choose a GID of whose users will
60576 + be unable to run server applications from your machine. If the sysctl
60577 + option is enabled, a sysctl option with name "socket_server" is created.
60578 +
60579 +config GRKERNSEC_SOCKET_SERVER_GID
60580 + int "GID to deny server sockets for"
60581 + depends on GRKERNSEC_SOCKET_SERVER
60582 + default 1002
60583 + help
60584 + Here you can choose the GID to disable server socket access for.
60585 + Remember to add the users you want server socket access disabled for to
60586 + the GID specified here. If the sysctl option is enabled, a sysctl
60587 + option with name "socket_server_gid" is created.
60588 +
60589 +endmenu
60590 +menu "Sysctl Support"
60591 +depends on GRKERNSEC && SYSCTL
60592 +
60593 +config GRKERNSEC_SYSCTL
60594 + bool "Sysctl support"
60595 + default y if GRKERNSEC_CONFIG_AUTO
60596 + help
60597 + If you say Y here, you will be able to change the options that
60598 + grsecurity runs with at bootup, without having to recompile your
60599 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
60600 + to enable (1) or disable (0) various features. All the sysctl entries
60601 + are mutable until the "grsec_lock" entry is set to a non-zero value.
60602 + All features enabled in the kernel configuration are disabled at boot
60603 + if you do not say Y to the "Turn on features by default" option.
60604 + All options should be set at startup, and the grsec_lock entry should
60605 + be set to a non-zero value after all the options are set.
60606 + *THIS IS EXTREMELY IMPORTANT*
60607 +
60608 +config GRKERNSEC_SYSCTL_DISTRO
60609 + bool "Extra sysctl support for distro makers (READ HELP)"
60610 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
60611 + help
60612 + If you say Y here, additional sysctl options will be created
60613 + for features that affect processes running as root. Therefore,
60614 + it is critical when using this option that the grsec_lock entry be
60615 + enabled after boot. Only distros with prebuilt kernel packages
60616 + with this option enabled that can ensure grsec_lock is enabled
60617 + after boot should use this option.
60618 + *Failure to set grsec_lock after boot makes all grsec features
60619 + this option covers useless*
60620 +
60621 + Currently this option creates the following sysctl entries:
60622 + "Disable Privileged I/O": "disable_priv_io"
60623 +
60624 +config GRKERNSEC_SYSCTL_ON
60625 + bool "Turn on features by default"
60626 + default y if GRKERNSEC_CONFIG_AUTO
60627 + depends on GRKERNSEC_SYSCTL
60628 + help
60629 + If you say Y here, instead of having all features enabled in the
60630 + kernel configuration disabled at boot time, the features will be
60631 + enabled at boot time. It is recommended you say Y here unless
60632 + there is some reason you would want all sysctl-tunable features to
60633 + be disabled by default. As mentioned elsewhere, it is important
60634 + to enable the grsec_lock entry once you have finished modifying
60635 + the sysctl entries.
60636 +
60637 +endmenu
60638 +menu "Logging Options"
60639 +depends on GRKERNSEC
60640 +
60641 +config GRKERNSEC_FLOODTIME
60642 + int "Seconds in between log messages (minimum)"
60643 + default 10
60644 + help
60645 + This option allows you to enforce the number of seconds between
60646 + grsecurity log messages. The default should be suitable for most
60647 + people, however, if you choose to change it, choose a value small enough
60648 + to allow informative logs to be produced, but large enough to
60649 + prevent flooding.
60650 +
60651 +config GRKERNSEC_FLOODBURST
60652 + int "Number of messages in a burst (maximum)"
60653 + default 6
60654 + help
60655 + This option allows you to choose the maximum number of messages allowed
60656 + within the flood time interval you chose in a separate option. The
60657 + default should be suitable for most people, however if you find that
60658 + many of your logs are being interpreted as flooding, you may want to
60659 + raise this value.
60660 +
60661 +endmenu
60662 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
60663 new file mode 100644
60664 index 0000000..36845aa
60665 --- /dev/null
60666 +++ b/grsecurity/Makefile
60667 @@ -0,0 +1,42 @@
60668 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
60669 +# during 2001-2009 it has been completely redesigned by Brad Spengler
60670 +# into an RBAC system
60671 +#
60672 +# All code in this directory and various hooks inserted throughout the kernel
60673 +# are copyright Brad Spengler - Open Source Security, Inc., and released
60674 +# under the GPL v2 or higher
60675 +
60676 +KBUILD_CFLAGS += -Werror
60677 +
60678 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
60679 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
60680 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
60681 +
60682 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
60683 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
60684 + gracl_learn.o grsec_log.o
60685 +ifdef CONFIG_COMPAT
60686 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
60687 +endif
60688 +
60689 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
60690 +
60691 +ifdef CONFIG_NET
60692 +obj-y += grsec_sock.o
60693 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
60694 +endif
60695 +
60696 +ifndef CONFIG_GRKERNSEC
60697 +obj-y += grsec_disabled.o
60698 +endif
60699 +
60700 +ifdef CONFIG_GRKERNSEC_HIDESYM
60701 +extra-y := grsec_hidesym.o
60702 +$(obj)/grsec_hidesym.o:
60703 + @-chmod -f 500 /boot
60704 + @-chmod -f 500 /lib/modules
60705 + @-chmod -f 500 /lib64/modules
60706 + @-chmod -f 500 /lib32/modules
60707 + @-chmod -f 700 .
60708 + @echo ' grsec: protected kernel image paths'
60709 +endif
60710 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
60711 new file mode 100644
60712 index 0000000..c0793fd
60713 --- /dev/null
60714 +++ b/grsecurity/gracl.c
60715 @@ -0,0 +1,4178 @@
60716 +#include <linux/kernel.h>
60717 +#include <linux/module.h>
60718 +#include <linux/sched.h>
60719 +#include <linux/mm.h>
60720 +#include <linux/file.h>
60721 +#include <linux/fs.h>
60722 +#include <linux/namei.h>
60723 +#include <linux/mount.h>
60724 +#include <linux/tty.h>
60725 +#include <linux/proc_fs.h>
60726 +#include <linux/lglock.h>
60727 +#include <linux/slab.h>
60728 +#include <linux/vmalloc.h>
60729 +#include <linux/types.h>
60730 +#include <linux/sysctl.h>
60731 +#include <linux/netdevice.h>
60732 +#include <linux/ptrace.h>
60733 +#include <linux/gracl.h>
60734 +#include <linux/gralloc.h>
60735 +#include <linux/security.h>
60736 +#include <linux/grinternal.h>
60737 +#include <linux/pid_namespace.h>
60738 +#include <linux/stop_machine.h>
60739 +#include <linux/fdtable.h>
60740 +#include <linux/percpu.h>
60741 +#include <linux/lglock.h>
60742 +#include <linux/hugetlb.h>
60743 +#include <linux/posix-timers.h>
60744 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
60745 +#include <linux/magic.h>
60746 +#include <linux/pagemap.h>
60747 +#include "../fs/btrfs/async-thread.h"
60748 +#include "../fs/btrfs/ctree.h"
60749 +#include "../fs/btrfs/btrfs_inode.h"
60750 +#endif
60751 +#include "../fs/mount.h"
60752 +
60753 +#include <asm/uaccess.h>
60754 +#include <asm/errno.h>
60755 +#include <asm/mman.h>
60756 +
60757 +extern struct lglock vfsmount_lock;
60758 +
60759 +static struct acl_role_db acl_role_set;
60760 +static struct name_db name_set;
60761 +static struct inodev_db inodev_set;
60762 +
60763 +/* for keeping track of userspace pointers used for subjects, so we
60764 + can share references in the kernel as well
60765 +*/
60766 +
60767 +static struct path real_root;
60768 +
60769 +static struct acl_subj_map_db subj_map_set;
60770 +
60771 +static struct acl_role_label *default_role;
60772 +
60773 +static struct acl_role_label *role_list;
60774 +
60775 +static u16 acl_sp_role_value;
60776 +
60777 +extern char *gr_shared_page[4];
60778 +static DEFINE_MUTEX(gr_dev_mutex);
60779 +DEFINE_RWLOCK(gr_inode_lock);
60780 +
60781 +struct gr_arg *gr_usermode;
60782 +
60783 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
60784 +
60785 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
60786 +extern void gr_clear_learn_entries(void);
60787 +
60788 +unsigned char *gr_system_salt;
60789 +unsigned char *gr_system_sum;
60790 +
60791 +static struct sprole_pw **acl_special_roles = NULL;
60792 +static __u16 num_sprole_pws = 0;
60793 +
60794 +static struct acl_role_label *kernel_role = NULL;
60795 +
60796 +static unsigned int gr_auth_attempts = 0;
60797 +static unsigned long gr_auth_expires = 0UL;
60798 +
60799 +#ifdef CONFIG_NET
60800 +extern struct vfsmount *sock_mnt;
60801 +#endif
60802 +
60803 +extern struct vfsmount *pipe_mnt;
60804 +extern struct vfsmount *shm_mnt;
60805 +
60806 +#ifdef CONFIG_HUGETLBFS
60807 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
60808 +#endif
60809 +
60810 +static struct acl_object_label *fakefs_obj_rw;
60811 +static struct acl_object_label *fakefs_obj_rwx;
60812 +
60813 +extern int gr_init_uidset(void);
60814 +extern void gr_free_uidset(void);
60815 +extern void gr_remove_uid(uid_t uid);
60816 +extern int gr_find_uid(uid_t uid);
60817 +
60818 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
60819 +{
60820 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
60821 + return -EFAULT;
60822 +
60823 + return 0;
60824 +}
60825 +
60826 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
60827 +{
60828 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
60829 + return -EFAULT;
60830 +
60831 + return 0;
60832 +}
60833 +
60834 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
60835 +{
60836 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
60837 + return -EFAULT;
60838 +
60839 + return 0;
60840 +}
60841 +
60842 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
60843 +{
60844 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
60845 + return -EFAULT;
60846 +
60847 + return 0;
60848 +}
60849 +
60850 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
60851 +{
60852 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
60853 + return -EFAULT;
60854 +
60855 + return 0;
60856 +}
60857 +
60858 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
60859 +{
60860 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
60861 + return -EFAULT;
60862 +
60863 + return 0;
60864 +}
60865 +
60866 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
60867 +{
60868 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
60869 + return -EFAULT;
60870 +
60871 + return 0;
60872 +}
60873 +
60874 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
60875 +{
60876 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
60877 + return -EFAULT;
60878 +
60879 + return 0;
60880 +}
60881 +
60882 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
60883 +{
60884 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
60885 + return -EFAULT;
60886 +
60887 + return 0;
60888 +}
60889 +
60890 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
60891 +{
60892 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
60893 + return -EFAULT;
60894 +
60895 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
60896 + return -EINVAL;
60897 +
60898 + return 0;
60899 +}
60900 +
60901 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
60902 +{
60903 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
60904 + return -EFAULT;
60905 +
60906 + return 0;
60907 +}
60908 +
60909 +static size_t get_gr_arg_wrapper_size_normal(void)
60910 +{
60911 + return sizeof(struct gr_arg_wrapper);
60912 +}
60913 +
60914 +#ifdef CONFIG_COMPAT
60915 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
60916 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
60917 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
60918 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
60919 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
60920 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
60921 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
60922 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
60923 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
60924 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
60925 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
60926 +extern size_t get_gr_arg_wrapper_size_compat(void);
60927 +
60928 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
60929 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
60930 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
60931 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
60932 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
60933 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
60934 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
60935 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
60936 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
60937 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
60938 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
60939 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
60940 +
60941 +#else
60942 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
60943 +#define copy_gr_arg copy_gr_arg_normal
60944 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
60945 +#define copy_acl_object_label copy_acl_object_label_normal
60946 +#define copy_acl_subject_label copy_acl_subject_label_normal
60947 +#define copy_acl_role_label copy_acl_role_label_normal
60948 +#define copy_acl_ip_label copy_acl_ip_label_normal
60949 +#define copy_pointer_from_array copy_pointer_from_array_normal
60950 +#define copy_sprole_pw copy_sprole_pw_normal
60951 +#define copy_role_transition copy_role_transition_normal
60952 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
60953 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
60954 +#endif
60955 +
60956 +__inline__ int
60957 +gr_acl_is_enabled(void)
60958 +{
60959 + return (gr_status & GR_READY);
60960 +}
60961 +
60962 +static inline dev_t __get_dev(const struct dentry *dentry)
60963 +{
60964 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
60965 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
60966 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
60967 + else
60968 +#endif
60969 + return dentry->d_sb->s_dev;
60970 +}
60971 +
60972 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
60973 +{
60974 + return __get_dev(dentry);
60975 +}
60976 +
60977 +static char gr_task_roletype_to_char(struct task_struct *task)
60978 +{
60979 + switch (task->role->roletype &
60980 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
60981 + GR_ROLE_SPECIAL)) {
60982 + case GR_ROLE_DEFAULT:
60983 + return 'D';
60984 + case GR_ROLE_USER:
60985 + return 'U';
60986 + case GR_ROLE_GROUP:
60987 + return 'G';
60988 + case GR_ROLE_SPECIAL:
60989 + return 'S';
60990 + }
60991 +
60992 + return 'X';
60993 +}
60994 +
60995 +char gr_roletype_to_char(void)
60996 +{
60997 + return gr_task_roletype_to_char(current);
60998 +}
60999 +
61000 +__inline__ int
61001 +gr_acl_tpe_check(void)
61002 +{
61003 + if (unlikely(!(gr_status & GR_READY)))
61004 + return 0;
61005 + if (current->role->roletype & GR_ROLE_TPE)
61006 + return 1;
61007 + else
61008 + return 0;
61009 +}
61010 +
61011 +int
61012 +gr_handle_rawio(const struct inode *inode)
61013 +{
61014 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
61015 + if (inode && S_ISBLK(inode->i_mode) &&
61016 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
61017 + !capable(CAP_SYS_RAWIO))
61018 + return 1;
61019 +#endif
61020 + return 0;
61021 +}
61022 +
61023 +static int
61024 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
61025 +{
61026 + if (likely(lena != lenb))
61027 + return 0;
61028 +
61029 + return !memcmp(a, b, lena);
61030 +}
61031 +
61032 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
61033 +{
61034 + *buflen -= namelen;
61035 + if (*buflen < 0)
61036 + return -ENAMETOOLONG;
61037 + *buffer -= namelen;
61038 + memcpy(*buffer, str, namelen);
61039 + return 0;
61040 +}
61041 +
61042 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
61043 +{
61044 + return prepend(buffer, buflen, name->name, name->len);
61045 +}
61046 +
61047 +static int prepend_path(const struct path *path, struct path *root,
61048 + char **buffer, int *buflen)
61049 +{
61050 + struct dentry *dentry = path->dentry;
61051 + struct vfsmount *vfsmnt = path->mnt;
61052 + struct mount *mnt = real_mount(vfsmnt);
61053 + bool slash = false;
61054 + int error = 0;
61055 +
61056 + while (dentry != root->dentry || vfsmnt != root->mnt) {
61057 + struct dentry * parent;
61058 +
61059 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
61060 + /* Global root? */
61061 + if (!mnt_has_parent(mnt)) {
61062 + goto out;
61063 + }
61064 + dentry = mnt->mnt_mountpoint;
61065 + mnt = mnt->mnt_parent;
61066 + vfsmnt = &mnt->mnt;
61067 + continue;
61068 + }
61069 + parent = dentry->d_parent;
61070 + prefetch(parent);
61071 + spin_lock(&dentry->d_lock);
61072 + error = prepend_name(buffer, buflen, &dentry->d_name);
61073 + spin_unlock(&dentry->d_lock);
61074 + if (!error)
61075 + error = prepend(buffer, buflen, "/", 1);
61076 + if (error)
61077 + break;
61078 +
61079 + slash = true;
61080 + dentry = parent;
61081 + }
61082 +
61083 +out:
61084 + if (!error && !slash)
61085 + error = prepend(buffer, buflen, "/", 1);
61086 +
61087 + return error;
61088 +}
61089 +
61090 +/* this must be called with vfsmount_lock and rename_lock held */
61091 +
61092 +static char *__our_d_path(const struct path *path, struct path *root,
61093 + char *buf, int buflen)
61094 +{
61095 + char *res = buf + buflen;
61096 + int error;
61097 +
61098 + prepend(&res, &buflen, "\0", 1);
61099 + error = prepend_path(path, root, &res, &buflen);
61100 + if (error)
61101 + return ERR_PTR(error);
61102 +
61103 + return res;
61104 +}
61105 +
61106 +static char *
61107 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
61108 +{
61109 + char *retval;
61110 +
61111 + retval = __our_d_path(path, root, buf, buflen);
61112 + if (unlikely(IS_ERR(retval)))
61113 + retval = strcpy(buf, "<path too long>");
61114 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
61115 + retval[1] = '\0';
61116 +
61117 + return retval;
61118 +}
61119 +
61120 +static char *
61121 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
61122 + char *buf, int buflen)
61123 +{
61124 + struct path path;
61125 + char *res;
61126 +
61127 + path.dentry = (struct dentry *)dentry;
61128 + path.mnt = (struct vfsmount *)vfsmnt;
61129 +
61130 + /* we can use real_root.dentry, real_root.mnt, because this is only called
61131 + by the RBAC system */
61132 + res = gen_full_path(&path, &real_root, buf, buflen);
61133 +
61134 + return res;
61135 +}
61136 +
61137 +static char *
61138 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
61139 + char *buf, int buflen)
61140 +{
61141 + char *res;
61142 + struct path path;
61143 + struct path root;
61144 + struct task_struct *reaper = init_pid_ns.child_reaper;
61145 +
61146 + path.dentry = (struct dentry *)dentry;
61147 + path.mnt = (struct vfsmount *)vfsmnt;
61148 +
61149 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
61150 + get_fs_root(reaper->fs, &root);
61151 +
61152 + br_read_lock(&vfsmount_lock);
61153 + write_seqlock(&rename_lock);
61154 + res = gen_full_path(&path, &root, buf, buflen);
61155 + write_sequnlock(&rename_lock);
61156 + br_read_unlock(&vfsmount_lock);
61157 +
61158 + path_put(&root);
61159 + return res;
61160 +}
61161 +
61162 +static char *
61163 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
61164 +{
61165 + char *ret;
61166 + br_read_lock(&vfsmount_lock);
61167 + write_seqlock(&rename_lock);
61168 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
61169 + PAGE_SIZE);
61170 + write_sequnlock(&rename_lock);
61171 + br_read_unlock(&vfsmount_lock);
61172 + return ret;
61173 +}
61174 +
61175 +static char *
61176 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
61177 +{
61178 + char *ret;
61179 + char *buf;
61180 + int buflen;
61181 +
61182 + br_read_lock(&vfsmount_lock);
61183 + write_seqlock(&rename_lock);
61184 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
61185 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
61186 + buflen = (int)(ret - buf);
61187 + if (buflen >= 5)
61188 + prepend(&ret, &buflen, "/proc", 5);
61189 + else
61190 + ret = strcpy(buf, "<path too long>");
61191 + write_sequnlock(&rename_lock);
61192 + br_read_unlock(&vfsmount_lock);
61193 + return ret;
61194 +}
61195 +
61196 +char *
61197 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
61198 +{
61199 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
61200 + PAGE_SIZE);
61201 +}
61202 +
61203 +char *
61204 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
61205 +{
61206 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61207 + PAGE_SIZE);
61208 +}
61209 +
61210 +char *
61211 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
61212 +{
61213 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
61214 + PAGE_SIZE);
61215 +}
61216 +
61217 +char *
61218 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
61219 +{
61220 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
61221 + PAGE_SIZE);
61222 +}
61223 +
61224 +char *
61225 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
61226 +{
61227 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
61228 + PAGE_SIZE);
61229 +}
61230 +
61231 +__inline__ __u32
61232 +to_gr_audit(const __u32 reqmode)
61233 +{
61234 + /* masks off auditable permission flags, then shifts them to create
61235 + auditing flags, and adds the special case of append auditing if
61236 + we're requesting write */
61237 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
61238 +}
61239 +
61240 +struct acl_subject_label *
61241 +lookup_subject_map(const struct acl_subject_label *userp)
61242 +{
61243 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
61244 + struct subject_map *match;
61245 +
61246 + match = subj_map_set.s_hash[index];
61247 +
61248 + while (match && match->user != userp)
61249 + match = match->next;
61250 +
61251 + if (match != NULL)
61252 + return match->kernel;
61253 + else
61254 + return NULL;
61255 +}
61256 +
61257 +static void
61258 +insert_subj_map_entry(struct subject_map *subjmap)
61259 +{
61260 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
61261 + struct subject_map **curr;
61262 +
61263 + subjmap->prev = NULL;
61264 +
61265 + curr = &subj_map_set.s_hash[index];
61266 + if (*curr != NULL)
61267 + (*curr)->prev = subjmap;
61268 +
61269 + subjmap->next = *curr;
61270 + *curr = subjmap;
61271 +
61272 + return;
61273 +}
61274 +
61275 +static struct acl_role_label *
61276 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
61277 + const gid_t gid)
61278 +{
61279 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
61280 + struct acl_role_label *match;
61281 + struct role_allowed_ip *ipp;
61282 + unsigned int x;
61283 + u32 curr_ip = task->signal->curr_ip;
61284 +
61285 + task->signal->saved_ip = curr_ip;
61286 +
61287 + match = acl_role_set.r_hash[index];
61288 +
61289 + while (match) {
61290 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
61291 + for (x = 0; x < match->domain_child_num; x++) {
61292 + if (match->domain_children[x] == uid)
61293 + goto found;
61294 + }
61295 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
61296 + break;
61297 + match = match->next;
61298 + }
61299 +found:
61300 + if (match == NULL) {
61301 + try_group:
61302 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
61303 + match = acl_role_set.r_hash[index];
61304 +
61305 + while (match) {
61306 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
61307 + for (x = 0; x < match->domain_child_num; x++) {
61308 + if (match->domain_children[x] == gid)
61309 + goto found2;
61310 + }
61311 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
61312 + break;
61313 + match = match->next;
61314 + }
61315 +found2:
61316 + if (match == NULL)
61317 + match = default_role;
61318 + if (match->allowed_ips == NULL)
61319 + return match;
61320 + else {
61321 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
61322 + if (likely
61323 + ((ntohl(curr_ip) & ipp->netmask) ==
61324 + (ntohl(ipp->addr) & ipp->netmask)))
61325 + return match;
61326 + }
61327 + match = default_role;
61328 + }
61329 + } else if (match->allowed_ips == NULL) {
61330 + return match;
61331 + } else {
61332 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
61333 + if (likely
61334 + ((ntohl(curr_ip) & ipp->netmask) ==
61335 + (ntohl(ipp->addr) & ipp->netmask)))
61336 + return match;
61337 + }
61338 + goto try_group;
61339 + }
61340 +
61341 + return match;
61342 +}
61343 +
61344 +struct acl_subject_label *
61345 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
61346 + const struct acl_role_label *role)
61347 +{
61348 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
61349 + struct acl_subject_label *match;
61350 +
61351 + match = role->subj_hash[index];
61352 +
61353 + while (match && (match->inode != ino || match->device != dev ||
61354 + (match->mode & GR_DELETED))) {
61355 + match = match->next;
61356 + }
61357 +
61358 + if (match && !(match->mode & GR_DELETED))
61359 + return match;
61360 + else
61361 + return NULL;
61362 +}
61363 +
61364 +struct acl_subject_label *
61365 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
61366 + const struct acl_role_label *role)
61367 +{
61368 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
61369 + struct acl_subject_label *match;
61370 +
61371 + match = role->subj_hash[index];
61372 +
61373 + while (match && (match->inode != ino || match->device != dev ||
61374 + !(match->mode & GR_DELETED))) {
61375 + match = match->next;
61376 + }
61377 +
61378 + if (match && (match->mode & GR_DELETED))
61379 + return match;
61380 + else
61381 + return NULL;
61382 +}
61383 +
61384 +static struct acl_object_label *
61385 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
61386 + const struct acl_subject_label *subj)
61387 +{
61388 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
61389 + struct acl_object_label *match;
61390 +
61391 + match = subj->obj_hash[index];
61392 +
61393 + while (match && (match->inode != ino || match->device != dev ||
61394 + (match->mode & GR_DELETED))) {
61395 + match = match->next;
61396 + }
61397 +
61398 + if (match && !(match->mode & GR_DELETED))
61399 + return match;
61400 + else
61401 + return NULL;
61402 +}
61403 +
61404 +static struct acl_object_label *
61405 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
61406 + const struct acl_subject_label *subj)
61407 +{
61408 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
61409 + struct acl_object_label *match;
61410 +
61411 + match = subj->obj_hash[index];
61412 +
61413 + while (match && (match->inode != ino || match->device != dev ||
61414 + !(match->mode & GR_DELETED))) {
61415 + match = match->next;
61416 + }
61417 +
61418 + if (match && (match->mode & GR_DELETED))
61419 + return match;
61420 +
61421 + match = subj->obj_hash[index];
61422 +
61423 + while (match && (match->inode != ino || match->device != dev ||
61424 + (match->mode & GR_DELETED))) {
61425 + match = match->next;
61426 + }
61427 +
61428 + if (match && !(match->mode & GR_DELETED))
61429 + return match;
61430 + else
61431 + return NULL;
61432 +}
61433 +
61434 +static struct name_entry *
61435 +lookup_name_entry(const char *name)
61436 +{
61437 + unsigned int len = strlen(name);
61438 + unsigned int key = full_name_hash(name, len);
61439 + unsigned int index = key % name_set.n_size;
61440 + struct name_entry *match;
61441 +
61442 + match = name_set.n_hash[index];
61443 +
61444 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
61445 + match = match->next;
61446 +
61447 + return match;
61448 +}
61449 +
61450 +static struct name_entry *
61451 +lookup_name_entry_create(const char *name)
61452 +{
61453 + unsigned int len = strlen(name);
61454 + unsigned int key = full_name_hash(name, len);
61455 + unsigned int index = key % name_set.n_size;
61456 + struct name_entry *match;
61457 +
61458 + match = name_set.n_hash[index];
61459 +
61460 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
61461 + !match->deleted))
61462 + match = match->next;
61463 +
61464 + if (match && match->deleted)
61465 + return match;
61466 +
61467 + match = name_set.n_hash[index];
61468 +
61469 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
61470 + match->deleted))
61471 + match = match->next;
61472 +
61473 + if (match && !match->deleted)
61474 + return match;
61475 + else
61476 + return NULL;
61477 +}
61478 +
61479 +static struct inodev_entry *
61480 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
61481 +{
61482 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
61483 + struct inodev_entry *match;
61484 +
61485 + match = inodev_set.i_hash[index];
61486 +
61487 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
61488 + match = match->next;
61489 +
61490 + return match;
61491 +}
61492 +
61493 +static void
61494 +insert_inodev_entry(struct inodev_entry *entry)
61495 +{
61496 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
61497 + inodev_set.i_size);
61498 + struct inodev_entry **curr;
61499 +
61500 + entry->prev = NULL;
61501 +
61502 + curr = &inodev_set.i_hash[index];
61503 + if (*curr != NULL)
61504 + (*curr)->prev = entry;
61505 +
61506 + entry->next = *curr;
61507 + *curr = entry;
61508 +
61509 + return;
61510 +}
61511 +
61512 +static void
61513 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
61514 +{
61515 + unsigned int index =
61516 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
61517 + struct acl_role_label **curr;
61518 + struct acl_role_label *tmp, *tmp2;
61519 +
61520 + curr = &acl_role_set.r_hash[index];
61521 +
61522 + /* simple case, slot is empty, just set it to our role */
61523 + if (*curr == NULL) {
61524 + *curr = role;
61525 + } else {
61526 + /* example:
61527 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
61528 + 2 -> 3
61529 + */
61530 + /* first check to see if we can already be reached via this slot */
61531 + tmp = *curr;
61532 + while (tmp && tmp != role)
61533 + tmp = tmp->next;
61534 + if (tmp == role) {
61535 + /* we don't need to add ourselves to this slot's chain */
61536 + return;
61537 + }
61538 + /* we need to add ourselves to this chain, two cases */
61539 + if (role->next == NULL) {
61540 + /* simple case, append the current chain to our role */
61541 + role->next = *curr;
61542 + *curr = role;
61543 + } else {
61544 + /* 1 -> 2 -> 3 -> 4
61545 + 2 -> 3 -> 4
61546 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
61547 + */
61548 + /* trickier case: walk our role's chain until we find
61549 + the role for the start of the current slot's chain */
61550 + tmp = role;
61551 + tmp2 = *curr;
61552 + while (tmp->next && tmp->next != tmp2)
61553 + tmp = tmp->next;
61554 + if (tmp->next == tmp2) {
61555 + /* from example above, we found 3, so just
61556 + replace this slot's chain with ours */
61557 + *curr = role;
61558 + } else {
61559 + /* we didn't find a subset of our role's chain
61560 + in the current slot's chain, so append their
61561 + chain to ours, and set us as the first role in
61562 + the slot's chain
61563 +
61564 + we could fold this case with the case above,
61565 + but making it explicit for clarity
61566 + */
61567 + tmp->next = tmp2;
61568 + *curr = role;
61569 + }
61570 + }
61571 + }
61572 +
61573 + return;
61574 +}
61575 +
61576 +static void
61577 +insert_acl_role_label(struct acl_role_label *role)
61578 +{
61579 + int i;
61580 +
61581 + if (role_list == NULL) {
61582 + role_list = role;
61583 + role->prev = NULL;
61584 + } else {
61585 + role->prev = role_list;
61586 + role_list = role;
61587 + }
61588 +
61589 + /* used for hash chains */
61590 + role->next = NULL;
61591 +
61592 + if (role->roletype & GR_ROLE_DOMAIN) {
61593 + for (i = 0; i < role->domain_child_num; i++)
61594 + __insert_acl_role_label(role, role->domain_children[i]);
61595 + } else
61596 + __insert_acl_role_label(role, role->uidgid);
61597 +}
61598 +
61599 +static int
61600 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
61601 +{
61602 + struct name_entry **curr, *nentry;
61603 + struct inodev_entry *ientry;
61604 + unsigned int len = strlen(name);
61605 + unsigned int key = full_name_hash(name, len);
61606 + unsigned int index = key % name_set.n_size;
61607 +
61608 + curr = &name_set.n_hash[index];
61609 +
61610 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
61611 + curr = &((*curr)->next);
61612 +
61613 + if (*curr != NULL)
61614 + return 1;
61615 +
61616 + nentry = acl_alloc(sizeof (struct name_entry));
61617 + if (nentry == NULL)
61618 + return 0;
61619 + ientry = acl_alloc(sizeof (struct inodev_entry));
61620 + if (ientry == NULL)
61621 + return 0;
61622 + ientry->nentry = nentry;
61623 +
61624 + nentry->key = key;
61625 + nentry->name = name;
61626 + nentry->inode = inode;
61627 + nentry->device = device;
61628 + nentry->len = len;
61629 + nentry->deleted = deleted;
61630 +
61631 + nentry->prev = NULL;
61632 + curr = &name_set.n_hash[index];
61633 + if (*curr != NULL)
61634 + (*curr)->prev = nentry;
61635 + nentry->next = *curr;
61636 + *curr = nentry;
61637 +
61638 + /* insert us into the table searchable by inode/dev */
61639 + insert_inodev_entry(ientry);
61640 +
61641 + return 1;
61642 +}
61643 +
61644 +static void
61645 +insert_acl_obj_label(struct acl_object_label *obj,
61646 + struct acl_subject_label *subj)
61647 +{
61648 + unsigned int index =
61649 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
61650 + struct acl_object_label **curr;
61651 +
61652 +
61653 + obj->prev = NULL;
61654 +
61655 + curr = &subj->obj_hash[index];
61656 + if (*curr != NULL)
61657 + (*curr)->prev = obj;
61658 +
61659 + obj->next = *curr;
61660 + *curr = obj;
61661 +
61662 + return;
61663 +}
61664 +
61665 +static void
61666 +insert_acl_subj_label(struct acl_subject_label *obj,
61667 + struct acl_role_label *role)
61668 +{
61669 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
61670 + struct acl_subject_label **curr;
61671 +
61672 + obj->prev = NULL;
61673 +
61674 + curr = &role->subj_hash[index];
61675 + if (*curr != NULL)
61676 + (*curr)->prev = obj;
61677 +
61678 + obj->next = *curr;
61679 + *curr = obj;
61680 +
61681 + return;
61682 +}
61683 +
61684 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
61685 +
61686 +static void *
61687 +create_table(__u32 * len, int elementsize)
61688 +{
61689 + unsigned int table_sizes[] = {
61690 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
61691 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
61692 + 4194301, 8388593, 16777213, 33554393, 67108859
61693 + };
61694 + void *newtable = NULL;
61695 + unsigned int pwr = 0;
61696 +
61697 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
61698 + table_sizes[pwr] <= *len)
61699 + pwr++;
61700 +
61701 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
61702 + return newtable;
61703 +
61704 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
61705 + newtable =
61706 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
61707 + else
61708 + newtable = vmalloc(table_sizes[pwr] * elementsize);
61709 +
61710 + *len = table_sizes[pwr];
61711 +
61712 + return newtable;
61713 +}
61714 +
61715 +static int
61716 +init_variables(const struct gr_arg *arg)
61717 +{
61718 + struct task_struct *reaper = init_pid_ns.child_reaper;
61719 + unsigned int stacksize;
61720 +
61721 + subj_map_set.s_size = arg->role_db.num_subjects;
61722 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
61723 + name_set.n_size = arg->role_db.num_objects;
61724 + inodev_set.i_size = arg->role_db.num_objects;
61725 +
61726 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
61727 + !name_set.n_size || !inodev_set.i_size)
61728 + return 1;
61729 +
61730 + if (!gr_init_uidset())
61731 + return 1;
61732 +
61733 + /* set up the stack that holds allocation info */
61734 +
61735 + stacksize = arg->role_db.num_pointers + 5;
61736 +
61737 + if (!acl_alloc_stack_init(stacksize))
61738 + return 1;
61739 +
61740 + /* grab reference for the real root dentry and vfsmount */
61741 + get_fs_root(reaper->fs, &real_root);
61742 +
61743 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61744 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
61745 +#endif
61746 +
61747 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
61748 + if (fakefs_obj_rw == NULL)
61749 + return 1;
61750 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
61751 +
61752 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
61753 + if (fakefs_obj_rwx == NULL)
61754 + return 1;
61755 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
61756 +
61757 + subj_map_set.s_hash =
61758 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
61759 + acl_role_set.r_hash =
61760 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
61761 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
61762 + inodev_set.i_hash =
61763 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
61764 +
61765 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
61766 + !name_set.n_hash || !inodev_set.i_hash)
61767 + return 1;
61768 +
61769 + memset(subj_map_set.s_hash, 0,
61770 + sizeof(struct subject_map *) * subj_map_set.s_size);
61771 + memset(acl_role_set.r_hash, 0,
61772 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
61773 + memset(name_set.n_hash, 0,
61774 + sizeof (struct name_entry *) * name_set.n_size);
61775 + memset(inodev_set.i_hash, 0,
61776 + sizeof (struct inodev_entry *) * inodev_set.i_size);
61777 +
61778 + return 0;
61779 +}
61780 +
61781 +/* free information not needed after startup
61782 + currently contains user->kernel pointer mappings for subjects
61783 +*/
61784 +
61785 +static void
61786 +free_init_variables(void)
61787 +{
61788 + __u32 i;
61789 +
61790 + if (subj_map_set.s_hash) {
61791 + for (i = 0; i < subj_map_set.s_size; i++) {
61792 + if (subj_map_set.s_hash[i]) {
61793 + kfree(subj_map_set.s_hash[i]);
61794 + subj_map_set.s_hash[i] = NULL;
61795 + }
61796 + }
61797 +
61798 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
61799 + PAGE_SIZE)
61800 + kfree(subj_map_set.s_hash);
61801 + else
61802 + vfree(subj_map_set.s_hash);
61803 + }
61804 +
61805 + return;
61806 +}
61807 +
61808 +static void
61809 +free_variables(void)
61810 +{
61811 + struct acl_subject_label *s;
61812 + struct acl_role_label *r;
61813 + struct task_struct *task, *task2;
61814 + unsigned int x;
61815 +
61816 + gr_clear_learn_entries();
61817 +
61818 + read_lock(&tasklist_lock);
61819 + do_each_thread(task2, task) {
61820 + task->acl_sp_role = 0;
61821 + task->acl_role_id = 0;
61822 + task->acl = NULL;
61823 + task->role = NULL;
61824 + } while_each_thread(task2, task);
61825 + read_unlock(&tasklist_lock);
61826 +
61827 + /* release the reference to the real root dentry and vfsmount */
61828 + path_put(&real_root);
61829 + memset(&real_root, 0, sizeof(real_root));
61830 +
61831 + /* free all object hash tables */
61832 +
61833 + FOR_EACH_ROLE_START(r)
61834 + if (r->subj_hash == NULL)
61835 + goto next_role;
61836 + FOR_EACH_SUBJECT_START(r, s, x)
61837 + if (s->obj_hash == NULL)
61838 + break;
61839 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
61840 + kfree(s->obj_hash);
61841 + else
61842 + vfree(s->obj_hash);
61843 + FOR_EACH_SUBJECT_END(s, x)
61844 + FOR_EACH_NESTED_SUBJECT_START(r, s)
61845 + if (s->obj_hash == NULL)
61846 + break;
61847 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
61848 + kfree(s->obj_hash);
61849 + else
61850 + vfree(s->obj_hash);
61851 + FOR_EACH_NESTED_SUBJECT_END(s)
61852 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
61853 + kfree(r->subj_hash);
61854 + else
61855 + vfree(r->subj_hash);
61856 + r->subj_hash = NULL;
61857 +next_role:
61858 + FOR_EACH_ROLE_END(r)
61859 +
61860 + acl_free_all();
61861 +
61862 + if (acl_role_set.r_hash) {
61863 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
61864 + PAGE_SIZE)
61865 + kfree(acl_role_set.r_hash);
61866 + else
61867 + vfree(acl_role_set.r_hash);
61868 + }
61869 + if (name_set.n_hash) {
61870 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
61871 + PAGE_SIZE)
61872 + kfree(name_set.n_hash);
61873 + else
61874 + vfree(name_set.n_hash);
61875 + }
61876 +
61877 + if (inodev_set.i_hash) {
61878 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
61879 + PAGE_SIZE)
61880 + kfree(inodev_set.i_hash);
61881 + else
61882 + vfree(inodev_set.i_hash);
61883 + }
61884 +
61885 + gr_free_uidset();
61886 +
61887 + memset(&name_set, 0, sizeof (struct name_db));
61888 + memset(&inodev_set, 0, sizeof (struct inodev_db));
61889 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
61890 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
61891 +
61892 + default_role = NULL;
61893 + kernel_role = NULL;
61894 + role_list = NULL;
61895 +
61896 + return;
61897 +}
61898 +
61899 +static struct acl_subject_label *
61900 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
61901 +
61902 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
61903 +{
61904 + unsigned int len = strnlen_user(*name, maxlen);
61905 + char *tmp;
61906 +
61907 + if (!len || len >= maxlen)
61908 + return -EINVAL;
61909 +
61910 + if ((tmp = (char *) acl_alloc(len)) == NULL)
61911 + return -ENOMEM;
61912 +
61913 + if (copy_from_user(tmp, *name, len))
61914 + return -EFAULT;
61915 +
61916 + tmp[len-1] = '\0';
61917 + *name = tmp;
61918 +
61919 + return 0;
61920 +}
61921 +
61922 +static int
61923 +copy_user_glob(struct acl_object_label *obj)
61924 +{
61925 + struct acl_object_label *g_tmp, **guser;
61926 + int error;
61927 +
61928 + if (obj->globbed == NULL)
61929 + return 0;
61930 +
61931 + guser = &obj->globbed;
61932 + while (*guser) {
61933 + g_tmp = (struct acl_object_label *)
61934 + acl_alloc(sizeof (struct acl_object_label));
61935 + if (g_tmp == NULL)
61936 + return -ENOMEM;
61937 +
61938 + if (copy_acl_object_label(g_tmp, *guser))
61939 + return -EFAULT;
61940 +
61941 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
61942 + if (error)
61943 + return error;
61944 +
61945 + *guser = g_tmp;
61946 + guser = &(g_tmp->next);
61947 + }
61948 +
61949 + return 0;
61950 +}
61951 +
61952 +static int
61953 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
61954 + struct acl_role_label *role)
61955 +{
61956 + struct acl_object_label *o_tmp;
61957 + int ret;
61958 +
61959 + while (userp) {
61960 + if ((o_tmp = (struct acl_object_label *)
61961 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
61962 + return -ENOMEM;
61963 +
61964 + if (copy_acl_object_label(o_tmp, userp))
61965 + return -EFAULT;
61966 +
61967 + userp = o_tmp->prev;
61968 +
61969 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
61970 + if (ret)
61971 + return ret;
61972 +
61973 + insert_acl_obj_label(o_tmp, subj);
61974 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
61975 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
61976 + return -ENOMEM;
61977 +
61978 + ret = copy_user_glob(o_tmp);
61979 + if (ret)
61980 + return ret;
61981 +
61982 + if (o_tmp->nested) {
61983 + int already_copied;
61984 +
61985 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
61986 + if (IS_ERR(o_tmp->nested))
61987 + return PTR_ERR(o_tmp->nested);
61988 +
61989 + /* insert into nested subject list if we haven't copied this one yet
61990 + to prevent duplicate entries */
61991 + if (!already_copied) {
61992 + o_tmp->nested->next = role->hash->first;
61993 + role->hash->first = o_tmp->nested;
61994 + }
61995 + }
61996 + }
61997 +
61998 + return 0;
61999 +}
62000 +
62001 +static __u32
62002 +count_user_subjs(struct acl_subject_label *userp)
62003 +{
62004 + struct acl_subject_label s_tmp;
62005 + __u32 num = 0;
62006 +
62007 + while (userp) {
62008 + if (copy_acl_subject_label(&s_tmp, userp))
62009 + break;
62010 +
62011 + userp = s_tmp.prev;
62012 + }
62013 +
62014 + return num;
62015 +}
62016 +
62017 +static int
62018 +copy_user_allowedips(struct acl_role_label *rolep)
62019 +{
62020 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
62021 +
62022 + ruserip = rolep->allowed_ips;
62023 +
62024 + while (ruserip) {
62025 + rlast = rtmp;
62026 +
62027 + if ((rtmp = (struct role_allowed_ip *)
62028 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
62029 + return -ENOMEM;
62030 +
62031 + if (copy_role_allowed_ip(rtmp, ruserip))
62032 + return -EFAULT;
62033 +
62034 + ruserip = rtmp->prev;
62035 +
62036 + if (!rlast) {
62037 + rtmp->prev = NULL;
62038 + rolep->allowed_ips = rtmp;
62039 + } else {
62040 + rlast->next = rtmp;
62041 + rtmp->prev = rlast;
62042 + }
62043 +
62044 + if (!ruserip)
62045 + rtmp->next = NULL;
62046 + }
62047 +
62048 + return 0;
62049 +}
62050 +
62051 +static int
62052 +copy_user_transitions(struct acl_role_label *rolep)
62053 +{
62054 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
62055 + int error;
62056 +
62057 + rusertp = rolep->transitions;
62058 +
62059 + while (rusertp) {
62060 + rlast = rtmp;
62061 +
62062 + if ((rtmp = (struct role_transition *)
62063 + acl_alloc(sizeof (struct role_transition))) == NULL)
62064 + return -ENOMEM;
62065 +
62066 + if (copy_role_transition(rtmp, rusertp))
62067 + return -EFAULT;
62068 +
62069 + rusertp = rtmp->prev;
62070 +
62071 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
62072 + if (error)
62073 + return error;
62074 +
62075 + if (!rlast) {
62076 + rtmp->prev = NULL;
62077 + rolep->transitions = rtmp;
62078 + } else {
62079 + rlast->next = rtmp;
62080 + rtmp->prev = rlast;
62081 + }
62082 +
62083 + if (!rusertp)
62084 + rtmp->next = NULL;
62085 + }
62086 +
62087 + return 0;
62088 +}
62089 +
62090 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
62091 +{
62092 + struct acl_object_label o_tmp;
62093 + __u32 num = 0;
62094 +
62095 + while (userp) {
62096 + if (copy_acl_object_label(&o_tmp, userp))
62097 + break;
62098 +
62099 + userp = o_tmp.prev;
62100 + num++;
62101 + }
62102 +
62103 + return num;
62104 +}
62105 +
62106 +static struct acl_subject_label *
62107 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
62108 +{
62109 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
62110 + __u32 num_objs;
62111 + struct acl_ip_label **i_tmp, *i_utmp2;
62112 + struct gr_hash_struct ghash;
62113 + struct subject_map *subjmap;
62114 + unsigned int i_num;
62115 + int err;
62116 +
62117 + if (already_copied != NULL)
62118 + *already_copied = 0;
62119 +
62120 + s_tmp = lookup_subject_map(userp);
62121 +
62122 + /* we've already copied this subject into the kernel, just return
62123 + the reference to it, and don't copy it over again
62124 + */
62125 + if (s_tmp) {
62126 + if (already_copied != NULL)
62127 + *already_copied = 1;
62128 + return(s_tmp);
62129 + }
62130 +
62131 + if ((s_tmp = (struct acl_subject_label *)
62132 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
62133 + return ERR_PTR(-ENOMEM);
62134 +
62135 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
62136 + if (subjmap == NULL)
62137 + return ERR_PTR(-ENOMEM);
62138 +
62139 + subjmap->user = userp;
62140 + subjmap->kernel = s_tmp;
62141 + insert_subj_map_entry(subjmap);
62142 +
62143 + if (copy_acl_subject_label(s_tmp, userp))
62144 + return ERR_PTR(-EFAULT);
62145 +
62146 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
62147 + if (err)
62148 + return ERR_PTR(err);
62149 +
62150 + if (!strcmp(s_tmp->filename, "/"))
62151 + role->root_label = s_tmp;
62152 +
62153 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
62154 + return ERR_PTR(-EFAULT);
62155 +
62156 + /* copy user and group transition tables */
62157 +
62158 + if (s_tmp->user_trans_num) {
62159 + uid_t *uidlist;
62160 +
62161 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
62162 + if (uidlist == NULL)
62163 + return ERR_PTR(-ENOMEM);
62164 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
62165 + return ERR_PTR(-EFAULT);
62166 +
62167 + s_tmp->user_transitions = uidlist;
62168 + }
62169 +
62170 + if (s_tmp->group_trans_num) {
62171 + gid_t *gidlist;
62172 +
62173 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
62174 + if (gidlist == NULL)
62175 + return ERR_PTR(-ENOMEM);
62176 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
62177 + return ERR_PTR(-EFAULT);
62178 +
62179 + s_tmp->group_transitions = gidlist;
62180 + }
62181 +
62182 + /* set up object hash table */
62183 + num_objs = count_user_objs(ghash.first);
62184 +
62185 + s_tmp->obj_hash_size = num_objs;
62186 + s_tmp->obj_hash =
62187 + (struct acl_object_label **)
62188 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
62189 +
62190 + if (!s_tmp->obj_hash)
62191 + return ERR_PTR(-ENOMEM);
62192 +
62193 + memset(s_tmp->obj_hash, 0,
62194 + s_tmp->obj_hash_size *
62195 + sizeof (struct acl_object_label *));
62196 +
62197 + /* add in objects */
62198 + err = copy_user_objs(ghash.first, s_tmp, role);
62199 +
62200 + if (err)
62201 + return ERR_PTR(err);
62202 +
62203 + /* set pointer for parent subject */
62204 + if (s_tmp->parent_subject) {
62205 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
62206 +
62207 + if (IS_ERR(s_tmp2))
62208 + return s_tmp2;
62209 +
62210 + s_tmp->parent_subject = s_tmp2;
62211 + }
62212 +
62213 + /* add in ip acls */
62214 +
62215 + if (!s_tmp->ip_num) {
62216 + s_tmp->ips = NULL;
62217 + goto insert;
62218 + }
62219 +
62220 + i_tmp =
62221 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
62222 + sizeof (struct acl_ip_label *));
62223 +
62224 + if (!i_tmp)
62225 + return ERR_PTR(-ENOMEM);
62226 +
62227 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
62228 + *(i_tmp + i_num) =
62229 + (struct acl_ip_label *)
62230 + acl_alloc(sizeof (struct acl_ip_label));
62231 + if (!*(i_tmp + i_num))
62232 + return ERR_PTR(-ENOMEM);
62233 +
62234 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
62235 + return ERR_PTR(-EFAULT);
62236 +
62237 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
62238 + return ERR_PTR(-EFAULT);
62239 +
62240 + if ((*(i_tmp + i_num))->iface == NULL)
62241 + continue;
62242 +
62243 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
62244 + if (err)
62245 + return ERR_PTR(err);
62246 + }
62247 +
62248 + s_tmp->ips = i_tmp;
62249 +
62250 +insert:
62251 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
62252 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
62253 + return ERR_PTR(-ENOMEM);
62254 +
62255 + return s_tmp;
62256 +}
62257 +
62258 +static int
62259 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
62260 +{
62261 + struct acl_subject_label s_pre;
62262 + struct acl_subject_label * ret;
62263 + int err;
62264 +
62265 + while (userp) {
62266 + if (copy_acl_subject_label(&s_pre, userp))
62267 + return -EFAULT;
62268 +
62269 + ret = do_copy_user_subj(userp, role, NULL);
62270 +
62271 + err = PTR_ERR(ret);
62272 + if (IS_ERR(ret))
62273 + return err;
62274 +
62275 + insert_acl_subj_label(ret, role);
62276 +
62277 + userp = s_pre.prev;
62278 + }
62279 +
62280 + return 0;
62281 +}
62282 +
62283 +static int
62284 +copy_user_acl(struct gr_arg *arg)
62285 +{
62286 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
62287 + struct acl_subject_label *subj_list;
62288 + struct sprole_pw *sptmp;
62289 + struct gr_hash_struct *ghash;
62290 + uid_t *domainlist;
62291 + unsigned int r_num;
62292 + int err = 0;
62293 + __u16 i;
62294 + __u32 num_subjs;
62295 +
62296 + /* we need a default and kernel role */
62297 + if (arg->role_db.num_roles < 2)
62298 + return -EINVAL;
62299 +
62300 + /* copy special role authentication info from userspace */
62301 +
62302 + num_sprole_pws = arg->num_sprole_pws;
62303 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
62304 +
62305 + if (!acl_special_roles && num_sprole_pws)
62306 + return -ENOMEM;
62307 +
62308 + for (i = 0; i < num_sprole_pws; i++) {
62309 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
62310 + if (!sptmp)
62311 + return -ENOMEM;
62312 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
62313 + return -EFAULT;
62314 +
62315 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
62316 + if (err)
62317 + return err;
62318 +
62319 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
62320 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
62321 +#endif
62322 +
62323 + acl_special_roles[i] = sptmp;
62324 + }
62325 +
62326 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
62327 +
62328 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
62329 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
62330 +
62331 + if (!r_tmp)
62332 + return -ENOMEM;
62333 +
62334 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
62335 + return -EFAULT;
62336 +
62337 + if (copy_acl_role_label(r_tmp, r_utmp2))
62338 + return -EFAULT;
62339 +
62340 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
62341 + if (err)
62342 + return err;
62343 +
62344 + if (!strcmp(r_tmp->rolename, "default")
62345 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
62346 + default_role = r_tmp;
62347 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
62348 + kernel_role = r_tmp;
62349 + }
62350 +
62351 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
62352 + return -ENOMEM;
62353 +
62354 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
62355 + return -EFAULT;
62356 +
62357 + r_tmp->hash = ghash;
62358 +
62359 + num_subjs = count_user_subjs(r_tmp->hash->first);
62360 +
62361 + r_tmp->subj_hash_size = num_subjs;
62362 + r_tmp->subj_hash =
62363 + (struct acl_subject_label **)
62364 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
62365 +
62366 + if (!r_tmp->subj_hash)
62367 + return -ENOMEM;
62368 +
62369 + err = copy_user_allowedips(r_tmp);
62370 + if (err)
62371 + return err;
62372 +
62373 + /* copy domain info */
62374 + if (r_tmp->domain_children != NULL) {
62375 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
62376 + if (domainlist == NULL)
62377 + return -ENOMEM;
62378 +
62379 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
62380 + return -EFAULT;
62381 +
62382 + r_tmp->domain_children = domainlist;
62383 + }
62384 +
62385 + err = copy_user_transitions(r_tmp);
62386 + if (err)
62387 + return err;
62388 +
62389 + memset(r_tmp->subj_hash, 0,
62390 + r_tmp->subj_hash_size *
62391 + sizeof (struct acl_subject_label *));
62392 +
62393 + /* acquire the list of subjects, then NULL out
62394 + the list prior to parsing the subjects for this role,
62395 + as during this parsing the list is replaced with a list
62396 + of *nested* subjects for the role
62397 + */
62398 + subj_list = r_tmp->hash->first;
62399 +
62400 + /* set nested subject list to null */
62401 + r_tmp->hash->first = NULL;
62402 +
62403 + err = copy_user_subjs(subj_list, r_tmp);
62404 +
62405 + if (err)
62406 + return err;
62407 +
62408 + insert_acl_role_label(r_tmp);
62409 + }
62410 +
62411 + if (default_role == NULL || kernel_role == NULL)
62412 + return -EINVAL;
62413 +
62414 + return err;
62415 +}
62416 +
62417 +static int
62418 +gracl_init(struct gr_arg *args)
62419 +{
62420 + int error = 0;
62421 +
62422 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
62423 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
62424 +
62425 + if (init_variables(args)) {
62426 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
62427 + error = -ENOMEM;
62428 + free_variables();
62429 + goto out;
62430 + }
62431 +
62432 + error = copy_user_acl(args);
62433 + free_init_variables();
62434 + if (error) {
62435 + free_variables();
62436 + goto out;
62437 + }
62438 +
62439 + if ((error = gr_set_acls(0))) {
62440 + free_variables();
62441 + goto out;
62442 + }
62443 +
62444 + pax_open_kernel();
62445 + gr_status |= GR_READY;
62446 + pax_close_kernel();
62447 +
62448 + out:
62449 + return error;
62450 +}
62451 +
62452 +/* derived from glibc fnmatch() 0: match, 1: no match*/
62453 +
62454 +static int
62455 +glob_match(const char *p, const char *n)
62456 +{
62457 + char c;
62458 +
62459 + while ((c = *p++) != '\0') {
62460 + switch (c) {
62461 + case '?':
62462 + if (*n == '\0')
62463 + return 1;
62464 + else if (*n == '/')
62465 + return 1;
62466 + break;
62467 + case '\\':
62468 + if (*n != c)
62469 + return 1;
62470 + break;
62471 + case '*':
62472 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
62473 + if (*n == '/')
62474 + return 1;
62475 + else if (c == '?') {
62476 + if (*n == '\0')
62477 + return 1;
62478 + else
62479 + ++n;
62480 + }
62481 + }
62482 + if (c == '\0') {
62483 + return 0;
62484 + } else {
62485 + const char *endp;
62486 +
62487 + if ((endp = strchr(n, '/')) == NULL)
62488 + endp = n + strlen(n);
62489 +
62490 + if (c == '[') {
62491 + for (--p; n < endp; ++n)
62492 + if (!glob_match(p, n))
62493 + return 0;
62494 + } else if (c == '/') {
62495 + while (*n != '\0' && *n != '/')
62496 + ++n;
62497 + if (*n == '/' && !glob_match(p, n + 1))
62498 + return 0;
62499 + } else {
62500 + for (--p; n < endp; ++n)
62501 + if (*n == c && !glob_match(p, n))
62502 + return 0;
62503 + }
62504 +
62505 + return 1;
62506 + }
62507 + case '[':
62508 + {
62509 + int not;
62510 + char cold;
62511 +
62512 + if (*n == '\0' || *n == '/')
62513 + return 1;
62514 +
62515 + not = (*p == '!' || *p == '^');
62516 + if (not)
62517 + ++p;
62518 +
62519 + c = *p++;
62520 + for (;;) {
62521 + unsigned char fn = (unsigned char)*n;
62522 +
62523 + if (c == '\0')
62524 + return 1;
62525 + else {
62526 + if (c == fn)
62527 + goto matched;
62528 + cold = c;
62529 + c = *p++;
62530 +
62531 + if (c == '-' && *p != ']') {
62532 + unsigned char cend = *p++;
62533 +
62534 + if (cend == '\0')
62535 + return 1;
62536 +
62537 + if (cold <= fn && fn <= cend)
62538 + goto matched;
62539 +
62540 + c = *p++;
62541 + }
62542 + }
62543 +
62544 + if (c == ']')
62545 + break;
62546 + }
62547 + if (!not)
62548 + return 1;
62549 + break;
62550 + matched:
62551 + while (c != ']') {
62552 + if (c == '\0')
62553 + return 1;
62554 +
62555 + c = *p++;
62556 + }
62557 + if (not)
62558 + return 1;
62559 + }
62560 + break;
62561 + default:
62562 + if (c != *n)
62563 + return 1;
62564 + }
62565 +
62566 + ++n;
62567 + }
62568 +
62569 + if (*n == '\0')
62570 + return 0;
62571 +
62572 + if (*n == '/')
62573 + return 0;
62574 +
62575 + return 1;
62576 +}
62577 +
62578 +static struct acl_object_label *
62579 +chk_glob_label(struct acl_object_label *globbed,
62580 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
62581 +{
62582 + struct acl_object_label *tmp;
62583 +
62584 + if (*path == NULL)
62585 + *path = gr_to_filename_nolock(dentry, mnt);
62586 +
62587 + tmp = globbed;
62588 +
62589 + while (tmp) {
62590 + if (!glob_match(tmp->filename, *path))
62591 + return tmp;
62592 + tmp = tmp->next;
62593 + }
62594 +
62595 + return NULL;
62596 +}
62597 +
62598 +static struct acl_object_label *
62599 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
62600 + const ino_t curr_ino, const dev_t curr_dev,
62601 + const struct acl_subject_label *subj, char **path, const int checkglob)
62602 +{
62603 + struct acl_subject_label *tmpsubj;
62604 + struct acl_object_label *retval;
62605 + struct acl_object_label *retval2;
62606 +
62607 + tmpsubj = (struct acl_subject_label *) subj;
62608 + read_lock(&gr_inode_lock);
62609 + do {
62610 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
62611 + if (retval) {
62612 + if (checkglob && retval->globbed) {
62613 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
62614 + if (retval2)
62615 + retval = retval2;
62616 + }
62617 + break;
62618 + }
62619 + } while ((tmpsubj = tmpsubj->parent_subject));
62620 + read_unlock(&gr_inode_lock);
62621 +
62622 + return retval;
62623 +}
62624 +
62625 +static __inline__ struct acl_object_label *
62626 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
62627 + struct dentry *curr_dentry,
62628 + const struct acl_subject_label *subj, char **path, const int checkglob)
62629 +{
62630 + int newglob = checkglob;
62631 + ino_t inode;
62632 + dev_t device;
62633 +
62634 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
62635 + as we don't want a / * rule to match instead of the / object
62636 + don't do this for create lookups that call this function though, since they're looking up
62637 + on the parent and thus need globbing checks on all paths
62638 + */
62639 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
62640 + newglob = GR_NO_GLOB;
62641 +
62642 + spin_lock(&curr_dentry->d_lock);
62643 + inode = curr_dentry->d_inode->i_ino;
62644 + device = __get_dev(curr_dentry);
62645 + spin_unlock(&curr_dentry->d_lock);
62646 +
62647 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
62648 +}
62649 +
62650 +#ifdef CONFIG_HUGETLBFS
62651 +static inline bool
62652 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
62653 +{
62654 + int i;
62655 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
62656 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
62657 + return true;
62658 + }
62659 +
62660 + return false;
62661 +}
62662 +#endif
62663 +
62664 +static struct acl_object_label *
62665 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
62666 + const struct acl_subject_label *subj, char *path, const int checkglob)
62667 +{
62668 + struct dentry *dentry = (struct dentry *) l_dentry;
62669 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
62670 + struct mount *real_mnt = real_mount(mnt);
62671 + struct acl_object_label *retval;
62672 + struct dentry *parent;
62673 +
62674 + br_read_lock(&vfsmount_lock);
62675 + write_seqlock(&rename_lock);
62676 +
62677 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
62678 +#ifdef CONFIG_NET
62679 + mnt == sock_mnt ||
62680 +#endif
62681 +#ifdef CONFIG_HUGETLBFS
62682 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
62683 +#endif
62684 + /* ignore Eric Biederman */
62685 + IS_PRIVATE(l_dentry->d_inode))) {
62686 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
62687 + goto out;
62688 + }
62689 +
62690 + for (;;) {
62691 + if (dentry == real_root.dentry && mnt == real_root.mnt)
62692 + break;
62693 +
62694 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
62695 + if (!mnt_has_parent(real_mnt))
62696 + break;
62697 +
62698 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
62699 + if (retval != NULL)
62700 + goto out;
62701 +
62702 + dentry = real_mnt->mnt_mountpoint;
62703 + real_mnt = real_mnt->mnt_parent;
62704 + mnt = &real_mnt->mnt;
62705 + continue;
62706 + }
62707 +
62708 + parent = dentry->d_parent;
62709 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
62710 + if (retval != NULL)
62711 + goto out;
62712 +
62713 + dentry = parent;
62714 + }
62715 +
62716 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
62717 +
62718 + /* real_root is pinned so we don't have to hold a reference */
62719 + if (retval == NULL)
62720 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
62721 +out:
62722 + write_sequnlock(&rename_lock);
62723 + br_read_unlock(&vfsmount_lock);
62724 +
62725 + BUG_ON(retval == NULL);
62726 +
62727 + return retval;
62728 +}
62729 +
62730 +static __inline__ struct acl_object_label *
62731 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
62732 + const struct acl_subject_label *subj)
62733 +{
62734 + char *path = NULL;
62735 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
62736 +}
62737 +
62738 +static __inline__ struct acl_object_label *
62739 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
62740 + const struct acl_subject_label *subj)
62741 +{
62742 + char *path = NULL;
62743 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
62744 +}
62745 +
62746 +static __inline__ struct acl_object_label *
62747 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
62748 + const struct acl_subject_label *subj, char *path)
62749 +{
62750 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
62751 +}
62752 +
62753 +static struct acl_subject_label *
62754 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
62755 + const struct acl_role_label *role)
62756 +{
62757 + struct dentry *dentry = (struct dentry *) l_dentry;
62758 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
62759 + struct mount *real_mnt = real_mount(mnt);
62760 + struct acl_subject_label *retval;
62761 + struct dentry *parent;
62762 +
62763 + br_read_lock(&vfsmount_lock);
62764 + write_seqlock(&rename_lock);
62765 +
62766 + for (;;) {
62767 + if (dentry == real_root.dentry && mnt == real_root.mnt)
62768 + break;
62769 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
62770 + if (!mnt_has_parent(real_mnt))
62771 + break;
62772 +
62773 + spin_lock(&dentry->d_lock);
62774 + read_lock(&gr_inode_lock);
62775 + retval =
62776 + lookup_acl_subj_label(dentry->d_inode->i_ino,
62777 + __get_dev(dentry), role);
62778 + read_unlock(&gr_inode_lock);
62779 + spin_unlock(&dentry->d_lock);
62780 + if (retval != NULL)
62781 + goto out;
62782 +
62783 + dentry = real_mnt->mnt_mountpoint;
62784 + real_mnt = real_mnt->mnt_parent;
62785 + mnt = &real_mnt->mnt;
62786 + continue;
62787 + }
62788 +
62789 + spin_lock(&dentry->d_lock);
62790 + read_lock(&gr_inode_lock);
62791 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
62792 + __get_dev(dentry), role);
62793 + read_unlock(&gr_inode_lock);
62794 + parent = dentry->d_parent;
62795 + spin_unlock(&dentry->d_lock);
62796 +
62797 + if (retval != NULL)
62798 + goto out;
62799 +
62800 + dentry = parent;
62801 + }
62802 +
62803 + spin_lock(&dentry->d_lock);
62804 + read_lock(&gr_inode_lock);
62805 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
62806 + __get_dev(dentry), role);
62807 + read_unlock(&gr_inode_lock);
62808 + spin_unlock(&dentry->d_lock);
62809 +
62810 + if (unlikely(retval == NULL)) {
62811 + /* real_root is pinned, we don't need to hold a reference */
62812 + read_lock(&gr_inode_lock);
62813 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
62814 + __get_dev(real_root.dentry), role);
62815 + read_unlock(&gr_inode_lock);
62816 + }
62817 +out:
62818 + write_sequnlock(&rename_lock);
62819 + br_read_unlock(&vfsmount_lock);
62820 +
62821 + BUG_ON(retval == NULL);
62822 +
62823 + return retval;
62824 +}
62825 +
62826 +static void
62827 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
62828 +{
62829 + struct task_struct *task = current;
62830 + const struct cred *cred = current_cred();
62831 +
62832 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
62833 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
62834 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
62835 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
62836 +
62837 + return;
62838 +}
62839 +
62840 +static void
62841 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
62842 +{
62843 + struct task_struct *task = current;
62844 + const struct cred *cred = current_cred();
62845 +
62846 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
62847 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
62848 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
62849 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
62850 +
62851 + return;
62852 +}
62853 +
62854 +static void
62855 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
62856 +{
62857 + struct task_struct *task = current;
62858 + const struct cred *cred = current_cred();
62859 +
62860 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
62861 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
62862 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
62863 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
62864 +
62865 + return;
62866 +}
62867 +
62868 +__u32
62869 +gr_search_file(const struct dentry * dentry, const __u32 mode,
62870 + const struct vfsmount * mnt)
62871 +{
62872 + __u32 retval = mode;
62873 + struct acl_subject_label *curracl;
62874 + struct acl_object_label *currobj;
62875 +
62876 + if (unlikely(!(gr_status & GR_READY)))
62877 + return (mode & ~GR_AUDITS);
62878 +
62879 + curracl = current->acl;
62880 +
62881 + currobj = chk_obj_label(dentry, mnt, curracl);
62882 + retval = currobj->mode & mode;
62883 +
62884 + /* if we're opening a specified transfer file for writing
62885 + (e.g. /dev/initctl), then transfer our role to init
62886 + */
62887 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
62888 + current->role->roletype & GR_ROLE_PERSIST)) {
62889 + struct task_struct *task = init_pid_ns.child_reaper;
62890 +
62891 + if (task->role != current->role) {
62892 + task->acl_sp_role = 0;
62893 + task->acl_role_id = current->acl_role_id;
62894 + task->role = current->role;
62895 + rcu_read_lock();
62896 + read_lock(&grsec_exec_file_lock);
62897 + gr_apply_subject_to_task(task);
62898 + read_unlock(&grsec_exec_file_lock);
62899 + rcu_read_unlock();
62900 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
62901 + }
62902 + }
62903 +
62904 + if (unlikely
62905 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
62906 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
62907 + __u32 new_mode = mode;
62908 +
62909 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
62910 +
62911 + retval = new_mode;
62912 +
62913 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
62914 + new_mode |= GR_INHERIT;
62915 +
62916 + if (!(mode & GR_NOLEARN))
62917 + gr_log_learn(dentry, mnt, new_mode);
62918 + }
62919 +
62920 + return retval;
62921 +}
62922 +
62923 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
62924 + const struct dentry *parent,
62925 + const struct vfsmount *mnt)
62926 +{
62927 + struct name_entry *match;
62928 + struct acl_object_label *matchpo;
62929 + struct acl_subject_label *curracl;
62930 + char *path;
62931 +
62932 + if (unlikely(!(gr_status & GR_READY)))
62933 + return NULL;
62934 +
62935 + preempt_disable();
62936 + path = gr_to_filename_rbac(new_dentry, mnt);
62937 + match = lookup_name_entry_create(path);
62938 +
62939 + curracl = current->acl;
62940 +
62941 + if (match) {
62942 + read_lock(&gr_inode_lock);
62943 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
62944 + read_unlock(&gr_inode_lock);
62945 +
62946 + if (matchpo) {
62947 + preempt_enable();
62948 + return matchpo;
62949 + }
62950 + }
62951 +
62952 + // lookup parent
62953 +
62954 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
62955 +
62956 + preempt_enable();
62957 + return matchpo;
62958 +}
62959 +
62960 +__u32
62961 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
62962 + const struct vfsmount * mnt, const __u32 mode)
62963 +{
62964 + struct acl_object_label *matchpo;
62965 + __u32 retval;
62966 +
62967 + if (unlikely(!(gr_status & GR_READY)))
62968 + return (mode & ~GR_AUDITS);
62969 +
62970 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
62971 +
62972 + retval = matchpo->mode & mode;
62973 +
62974 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
62975 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
62976 + __u32 new_mode = mode;
62977 +
62978 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
62979 +
62980 + gr_log_learn(new_dentry, mnt, new_mode);
62981 + return new_mode;
62982 + }
62983 +
62984 + return retval;
62985 +}
62986 +
62987 +__u32
62988 +gr_check_link(const struct dentry * new_dentry,
62989 + const struct dentry * parent_dentry,
62990 + const struct vfsmount * parent_mnt,
62991 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
62992 +{
62993 + struct acl_object_label *obj;
62994 + __u32 oldmode, newmode;
62995 + __u32 needmode;
62996 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
62997 + GR_DELETE | GR_INHERIT;
62998 +
62999 + if (unlikely(!(gr_status & GR_READY)))
63000 + return (GR_CREATE | GR_LINK);
63001 +
63002 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
63003 + oldmode = obj->mode;
63004 +
63005 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
63006 + newmode = obj->mode;
63007 +
63008 + needmode = newmode & checkmodes;
63009 +
63010 + // old name for hardlink must have at least the permissions of the new name
63011 + if ((oldmode & needmode) != needmode)
63012 + goto bad;
63013 +
63014 + // if old name had restrictions/auditing, make sure the new name does as well
63015 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
63016 +
63017 + // don't allow hardlinking of suid/sgid/fcapped files without permission
63018 + if (is_privileged_binary(old_dentry))
63019 + needmode |= GR_SETID;
63020 +
63021 + if ((newmode & needmode) != needmode)
63022 + goto bad;
63023 +
63024 + // enforce minimum permissions
63025 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
63026 + return newmode;
63027 +bad:
63028 + needmode = oldmode;
63029 + if (is_privileged_binary(old_dentry))
63030 + needmode |= GR_SETID;
63031 +
63032 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
63033 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
63034 + return (GR_CREATE | GR_LINK);
63035 + } else if (newmode & GR_SUPPRESS)
63036 + return GR_SUPPRESS;
63037 + else
63038 + return 0;
63039 +}
63040 +
63041 +int
63042 +gr_check_hidden_task(const struct task_struct *task)
63043 +{
63044 + if (unlikely(!(gr_status & GR_READY)))
63045 + return 0;
63046 +
63047 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
63048 + return 1;
63049 +
63050 + return 0;
63051 +}
63052 +
63053 +int
63054 +gr_check_protected_task(const struct task_struct *task)
63055 +{
63056 + if (unlikely(!(gr_status & GR_READY) || !task))
63057 + return 0;
63058 +
63059 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
63060 + task->acl != current->acl)
63061 + return 1;
63062 +
63063 + return 0;
63064 +}
63065 +
63066 +int
63067 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
63068 +{
63069 + struct task_struct *p;
63070 + int ret = 0;
63071 +
63072 + if (unlikely(!(gr_status & GR_READY) || !pid))
63073 + return ret;
63074 +
63075 + read_lock(&tasklist_lock);
63076 + do_each_pid_task(pid, type, p) {
63077 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
63078 + p->acl != current->acl) {
63079 + ret = 1;
63080 + goto out;
63081 + }
63082 + } while_each_pid_task(pid, type, p);
63083 +out:
63084 + read_unlock(&tasklist_lock);
63085 +
63086 + return ret;
63087 +}
63088 +
63089 +void
63090 +gr_copy_label(struct task_struct *tsk)
63091 +{
63092 + tsk->signal->used_accept = 0;
63093 + tsk->acl_sp_role = 0;
63094 + tsk->acl_role_id = current->acl_role_id;
63095 + tsk->acl = current->acl;
63096 + tsk->role = current->role;
63097 + tsk->signal->curr_ip = current->signal->curr_ip;
63098 + tsk->signal->saved_ip = current->signal->saved_ip;
63099 + if (current->exec_file)
63100 + get_file(current->exec_file);
63101 + tsk->exec_file = current->exec_file;
63102 + tsk->is_writable = current->is_writable;
63103 + if (unlikely(current->signal->used_accept)) {
63104 + current->signal->curr_ip = 0;
63105 + current->signal->saved_ip = 0;
63106 + }
63107 +
63108 + return;
63109 +}
63110 +
63111 +static void
63112 +gr_set_proc_res(struct task_struct *task)
63113 +{
63114 + struct acl_subject_label *proc;
63115 + unsigned short i;
63116 +
63117 + proc = task->acl;
63118 +
63119 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
63120 + return;
63121 +
63122 + for (i = 0; i < RLIM_NLIMITS; i++) {
63123 + if (!(proc->resmask & (1U << i)))
63124 + continue;
63125 +
63126 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
63127 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
63128 +
63129 + if (i == RLIMIT_CPU)
63130 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
63131 + }
63132 +
63133 + return;
63134 +}
63135 +
63136 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
63137 +
63138 +int
63139 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
63140 +{
63141 + unsigned int i;
63142 + __u16 num;
63143 + uid_t *uidlist;
63144 + uid_t curuid;
63145 + int realok = 0;
63146 + int effectiveok = 0;
63147 + int fsok = 0;
63148 + uid_t globalreal, globaleffective, globalfs;
63149 +
63150 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
63151 + struct user_struct *user;
63152 +
63153 + if (!uid_valid(real))
63154 + goto skipit;
63155 +
63156 + /* find user based on global namespace */
63157 +
63158 + globalreal = GR_GLOBAL_UID(real);
63159 +
63160 + user = find_user(make_kuid(&init_user_ns, globalreal));
63161 + if (user == NULL)
63162 + goto skipit;
63163 +
63164 + if (gr_process_kernel_setuid_ban(user)) {
63165 + /* for find_user */
63166 + free_uid(user);
63167 + return 1;
63168 + }
63169 +
63170 + /* for find_user */
63171 + free_uid(user);
63172 +
63173 +skipit:
63174 +#endif
63175 +
63176 + if (unlikely(!(gr_status & GR_READY)))
63177 + return 0;
63178 +
63179 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
63180 + gr_log_learn_uid_change(real, effective, fs);
63181 +
63182 + num = current->acl->user_trans_num;
63183 + uidlist = current->acl->user_transitions;
63184 +
63185 + if (uidlist == NULL)
63186 + return 0;
63187 +
63188 + if (!uid_valid(real)) {
63189 + realok = 1;
63190 + globalreal = (uid_t)-1;
63191 + } else {
63192 + globalreal = GR_GLOBAL_UID(real);
63193 + }
63194 + if (!uid_valid(effective)) {
63195 + effectiveok = 1;
63196 + globaleffective = (uid_t)-1;
63197 + } else {
63198 + globaleffective = GR_GLOBAL_UID(effective);
63199 + }
63200 + if (!uid_valid(fs)) {
63201 + fsok = 1;
63202 + globalfs = (uid_t)-1;
63203 + } else {
63204 + globalfs = GR_GLOBAL_UID(fs);
63205 + }
63206 +
63207 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
63208 + for (i = 0; i < num; i++) {
63209 + curuid = uidlist[i];
63210 + if (globalreal == curuid)
63211 + realok = 1;
63212 + if (globaleffective == curuid)
63213 + effectiveok = 1;
63214 + if (globalfs == curuid)
63215 + fsok = 1;
63216 + }
63217 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
63218 + for (i = 0; i < num; i++) {
63219 + curuid = uidlist[i];
63220 + if (globalreal == curuid)
63221 + break;
63222 + if (globaleffective == curuid)
63223 + break;
63224 + if (globalfs == curuid)
63225 + break;
63226 + }
63227 + /* not in deny list */
63228 + if (i == num) {
63229 + realok = 1;
63230 + effectiveok = 1;
63231 + fsok = 1;
63232 + }
63233 + }
63234 +
63235 + if (realok && effectiveok && fsok)
63236 + return 0;
63237 + else {
63238 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
63239 + return 1;
63240 + }
63241 +}
63242 +
63243 +int
63244 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
63245 +{
63246 + unsigned int i;
63247 + __u16 num;
63248 + gid_t *gidlist;
63249 + gid_t curgid;
63250 + int realok = 0;
63251 + int effectiveok = 0;
63252 + int fsok = 0;
63253 + gid_t globalreal, globaleffective, globalfs;
63254 +
63255 + if (unlikely(!(gr_status & GR_READY)))
63256 + return 0;
63257 +
63258 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
63259 + gr_log_learn_gid_change(real, effective, fs);
63260 +
63261 + num = current->acl->group_trans_num;
63262 + gidlist = current->acl->group_transitions;
63263 +
63264 + if (gidlist == NULL)
63265 + return 0;
63266 +
63267 + if (!gid_valid(real)) {
63268 + realok = 1;
63269 + globalreal = (gid_t)-1;
63270 + } else {
63271 + globalreal = GR_GLOBAL_GID(real);
63272 + }
63273 + if (!gid_valid(effective)) {
63274 + effectiveok = 1;
63275 + globaleffective = (gid_t)-1;
63276 + } else {
63277 + globaleffective = GR_GLOBAL_GID(effective);
63278 + }
63279 + if (!gid_valid(fs)) {
63280 + fsok = 1;
63281 + globalfs = (gid_t)-1;
63282 + } else {
63283 + globalfs = GR_GLOBAL_GID(fs);
63284 + }
63285 +
63286 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
63287 + for (i = 0; i < num; i++) {
63288 + curgid = gidlist[i];
63289 + if (globalreal == curgid)
63290 + realok = 1;
63291 + if (globaleffective == curgid)
63292 + effectiveok = 1;
63293 + if (globalfs == curgid)
63294 + fsok = 1;
63295 + }
63296 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
63297 + for (i = 0; i < num; i++) {
63298 + curgid = gidlist[i];
63299 + if (globalreal == curgid)
63300 + break;
63301 + if (globaleffective == curgid)
63302 + break;
63303 + if (globalfs == curgid)
63304 + break;
63305 + }
63306 + /* not in deny list */
63307 + if (i == num) {
63308 + realok = 1;
63309 + effectiveok = 1;
63310 + fsok = 1;
63311 + }
63312 + }
63313 +
63314 + if (realok && effectiveok && fsok)
63315 + return 0;
63316 + else {
63317 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
63318 + return 1;
63319 + }
63320 +}
63321 +
63322 +extern int gr_acl_is_capable(const int cap);
63323 +
63324 +void
63325 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
63326 +{
63327 + struct acl_role_label *role = task->role;
63328 + struct acl_subject_label *subj = NULL;
63329 + struct acl_object_label *obj;
63330 + struct file *filp;
63331 + uid_t uid;
63332 + gid_t gid;
63333 +
63334 + if (unlikely(!(gr_status & GR_READY)))
63335 + return;
63336 +
63337 + uid = GR_GLOBAL_UID(kuid);
63338 + gid = GR_GLOBAL_GID(kgid);
63339 +
63340 + filp = task->exec_file;
63341 +
63342 + /* kernel process, we'll give them the kernel role */
63343 + if (unlikely(!filp)) {
63344 + task->role = kernel_role;
63345 + task->acl = kernel_role->root_label;
63346 + return;
63347 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
63348 + role = lookup_acl_role_label(task, uid, gid);
63349 +
63350 + /* don't change the role if we're not a privileged process */
63351 + if (role && task->role != role &&
63352 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
63353 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
63354 + return;
63355 +
63356 + /* perform subject lookup in possibly new role
63357 + we can use this result below in the case where role == task->role
63358 + */
63359 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
63360 +
63361 + /* if we changed uid/gid, but result in the same role
63362 + and are using inheritance, don't lose the inherited subject
63363 + if current subject is other than what normal lookup
63364 + would result in, we arrived via inheritance, don't
63365 + lose subject
63366 + */
63367 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
63368 + (subj == task->acl)))
63369 + task->acl = subj;
63370 +
63371 + task->role = role;
63372 +
63373 + task->is_writable = 0;
63374 +
63375 + /* ignore additional mmap checks for processes that are writable
63376 + by the default ACL */
63377 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
63378 + if (unlikely(obj->mode & GR_WRITE))
63379 + task->is_writable = 1;
63380 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
63381 + if (unlikely(obj->mode & GR_WRITE))
63382 + task->is_writable = 1;
63383 +
63384 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63385 + 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);
63386 +#endif
63387 +
63388 + gr_set_proc_res(task);
63389 +
63390 + return;
63391 +}
63392 +
63393 +int
63394 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63395 + const int unsafe_flags)
63396 +{
63397 + struct task_struct *task = current;
63398 + struct acl_subject_label *newacl;
63399 + struct acl_object_label *obj;
63400 + __u32 retmode;
63401 +
63402 + if (unlikely(!(gr_status & GR_READY)))
63403 + return 0;
63404 +
63405 + newacl = chk_subj_label(dentry, mnt, task->role);
63406 +
63407 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
63408 + did an exec
63409 + */
63410 + rcu_read_lock();
63411 + read_lock(&tasklist_lock);
63412 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
63413 + (task->parent->acl->mode & GR_POVERRIDE))) {
63414 + read_unlock(&tasklist_lock);
63415 + rcu_read_unlock();
63416 + goto skip_check;
63417 + }
63418 + read_unlock(&tasklist_lock);
63419 + rcu_read_unlock();
63420 +
63421 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
63422 + !(task->role->roletype & GR_ROLE_GOD) &&
63423 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
63424 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
63425 + if (unsafe_flags & LSM_UNSAFE_SHARE)
63426 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
63427 + else
63428 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
63429 + return -EACCES;
63430 + }
63431 +
63432 +skip_check:
63433 +
63434 + obj = chk_obj_label(dentry, mnt, task->acl);
63435 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
63436 +
63437 + if (!(task->acl->mode & GR_INHERITLEARN) &&
63438 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
63439 + if (obj->nested)
63440 + task->acl = obj->nested;
63441 + else
63442 + task->acl = newacl;
63443 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
63444 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
63445 +
63446 + task->is_writable = 0;
63447 +
63448 + /* ignore additional mmap checks for processes that are writable
63449 + by the default ACL */
63450 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
63451 + if (unlikely(obj->mode & GR_WRITE))
63452 + task->is_writable = 1;
63453 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
63454 + if (unlikely(obj->mode & GR_WRITE))
63455 + task->is_writable = 1;
63456 +
63457 + gr_set_proc_res(task);
63458 +
63459 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63460 + 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);
63461 +#endif
63462 + return 0;
63463 +}
63464 +
63465 +/* always called with valid inodev ptr */
63466 +static void
63467 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
63468 +{
63469 + struct acl_object_label *matchpo;
63470 + struct acl_subject_label *matchps;
63471 + struct acl_subject_label *subj;
63472 + struct acl_role_label *role;
63473 + unsigned int x;
63474 +
63475 + FOR_EACH_ROLE_START(role)
63476 + FOR_EACH_SUBJECT_START(role, subj, x)
63477 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
63478 + matchpo->mode |= GR_DELETED;
63479 + FOR_EACH_SUBJECT_END(subj,x)
63480 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
63481 + /* nested subjects aren't in the role's subj_hash table */
63482 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
63483 + matchpo->mode |= GR_DELETED;
63484 + FOR_EACH_NESTED_SUBJECT_END(subj)
63485 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
63486 + matchps->mode |= GR_DELETED;
63487 + FOR_EACH_ROLE_END(role)
63488 +
63489 + inodev->nentry->deleted = 1;
63490 +
63491 + return;
63492 +}
63493 +
63494 +void
63495 +gr_handle_delete(const ino_t ino, const dev_t dev)
63496 +{
63497 + struct inodev_entry *inodev;
63498 +
63499 + if (unlikely(!(gr_status & GR_READY)))
63500 + return;
63501 +
63502 + write_lock(&gr_inode_lock);
63503 + inodev = lookup_inodev_entry(ino, dev);
63504 + if (inodev != NULL)
63505 + do_handle_delete(inodev, ino, dev);
63506 + write_unlock(&gr_inode_lock);
63507 +
63508 + return;
63509 +}
63510 +
63511 +static void
63512 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
63513 + const ino_t newinode, const dev_t newdevice,
63514 + struct acl_subject_label *subj)
63515 +{
63516 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
63517 + struct acl_object_label *match;
63518 +
63519 + match = subj->obj_hash[index];
63520 +
63521 + while (match && (match->inode != oldinode ||
63522 + match->device != olddevice ||
63523 + !(match->mode & GR_DELETED)))
63524 + match = match->next;
63525 +
63526 + if (match && (match->inode == oldinode)
63527 + && (match->device == olddevice)
63528 + && (match->mode & GR_DELETED)) {
63529 + if (match->prev == NULL) {
63530 + subj->obj_hash[index] = match->next;
63531 + if (match->next != NULL)
63532 + match->next->prev = NULL;
63533 + } else {
63534 + match->prev->next = match->next;
63535 + if (match->next != NULL)
63536 + match->next->prev = match->prev;
63537 + }
63538 + match->prev = NULL;
63539 + match->next = NULL;
63540 + match->inode = newinode;
63541 + match->device = newdevice;
63542 + match->mode &= ~GR_DELETED;
63543 +
63544 + insert_acl_obj_label(match, subj);
63545 + }
63546 +
63547 + return;
63548 +}
63549 +
63550 +static void
63551 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
63552 + const ino_t newinode, const dev_t newdevice,
63553 + struct acl_role_label *role)
63554 +{
63555 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
63556 + struct acl_subject_label *match;
63557 +
63558 + match = role->subj_hash[index];
63559 +
63560 + while (match && (match->inode != oldinode ||
63561 + match->device != olddevice ||
63562 + !(match->mode & GR_DELETED)))
63563 + match = match->next;
63564 +
63565 + if (match && (match->inode == oldinode)
63566 + && (match->device == olddevice)
63567 + && (match->mode & GR_DELETED)) {
63568 + if (match->prev == NULL) {
63569 + role->subj_hash[index] = match->next;
63570 + if (match->next != NULL)
63571 + match->next->prev = NULL;
63572 + } else {
63573 + match->prev->next = match->next;
63574 + if (match->next != NULL)
63575 + match->next->prev = match->prev;
63576 + }
63577 + match->prev = NULL;
63578 + match->next = NULL;
63579 + match->inode = newinode;
63580 + match->device = newdevice;
63581 + match->mode &= ~GR_DELETED;
63582 +
63583 + insert_acl_subj_label(match, role);
63584 + }
63585 +
63586 + return;
63587 +}
63588 +
63589 +static void
63590 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
63591 + const ino_t newinode, const dev_t newdevice)
63592 +{
63593 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
63594 + struct inodev_entry *match;
63595 +
63596 + match = inodev_set.i_hash[index];
63597 +
63598 + while (match && (match->nentry->inode != oldinode ||
63599 + match->nentry->device != olddevice || !match->nentry->deleted))
63600 + match = match->next;
63601 +
63602 + if (match && (match->nentry->inode == oldinode)
63603 + && (match->nentry->device == olddevice) &&
63604 + match->nentry->deleted) {
63605 + if (match->prev == NULL) {
63606 + inodev_set.i_hash[index] = match->next;
63607 + if (match->next != NULL)
63608 + match->next->prev = NULL;
63609 + } else {
63610 + match->prev->next = match->next;
63611 + if (match->next != NULL)
63612 + match->next->prev = match->prev;
63613 + }
63614 + match->prev = NULL;
63615 + match->next = NULL;
63616 + match->nentry->inode = newinode;
63617 + match->nentry->device = newdevice;
63618 + match->nentry->deleted = 0;
63619 +
63620 + insert_inodev_entry(match);
63621 + }
63622 +
63623 + return;
63624 +}
63625 +
63626 +static void
63627 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
63628 +{
63629 + struct acl_subject_label *subj;
63630 + struct acl_role_label *role;
63631 + unsigned int x;
63632 +
63633 + FOR_EACH_ROLE_START(role)
63634 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
63635 +
63636 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
63637 + if ((subj->inode == ino) && (subj->device == dev)) {
63638 + subj->inode = ino;
63639 + subj->device = dev;
63640 + }
63641 + /* nested subjects aren't in the role's subj_hash table */
63642 + update_acl_obj_label(matchn->inode, matchn->device,
63643 + ino, dev, subj);
63644 + FOR_EACH_NESTED_SUBJECT_END(subj)
63645 + FOR_EACH_SUBJECT_START(role, subj, x)
63646 + update_acl_obj_label(matchn->inode, matchn->device,
63647 + ino, dev, subj);
63648 + FOR_EACH_SUBJECT_END(subj,x)
63649 + FOR_EACH_ROLE_END(role)
63650 +
63651 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
63652 +
63653 + return;
63654 +}
63655 +
63656 +static void
63657 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
63658 + const struct vfsmount *mnt)
63659 +{
63660 + ino_t ino = dentry->d_inode->i_ino;
63661 + dev_t dev = __get_dev(dentry);
63662 +
63663 + __do_handle_create(matchn, ino, dev);
63664 +
63665 + return;
63666 +}
63667 +
63668 +void
63669 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
63670 +{
63671 + struct name_entry *matchn;
63672 +
63673 + if (unlikely(!(gr_status & GR_READY)))
63674 + return;
63675 +
63676 + preempt_disable();
63677 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
63678 +
63679 + if (unlikely((unsigned long)matchn)) {
63680 + write_lock(&gr_inode_lock);
63681 + do_handle_create(matchn, dentry, mnt);
63682 + write_unlock(&gr_inode_lock);
63683 + }
63684 + preempt_enable();
63685 +
63686 + return;
63687 +}
63688 +
63689 +void
63690 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
63691 +{
63692 + struct name_entry *matchn;
63693 +
63694 + if (unlikely(!(gr_status & GR_READY)))
63695 + return;
63696 +
63697 + preempt_disable();
63698 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
63699 +
63700 + if (unlikely((unsigned long)matchn)) {
63701 + write_lock(&gr_inode_lock);
63702 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
63703 + write_unlock(&gr_inode_lock);
63704 + }
63705 + preempt_enable();
63706 +
63707 + return;
63708 +}
63709 +
63710 +void
63711 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
63712 + struct dentry *old_dentry,
63713 + struct dentry *new_dentry,
63714 + struct vfsmount *mnt, const __u8 replace)
63715 +{
63716 + struct name_entry *matchn;
63717 + struct inodev_entry *inodev;
63718 + struct inode *inode = new_dentry->d_inode;
63719 + ino_t old_ino = old_dentry->d_inode->i_ino;
63720 + dev_t old_dev = __get_dev(old_dentry);
63721 +
63722 + /* vfs_rename swaps the name and parent link for old_dentry and
63723 + new_dentry
63724 + at this point, old_dentry has the new name, parent link, and inode
63725 + for the renamed file
63726 + if a file is being replaced by a rename, new_dentry has the inode
63727 + and name for the replaced file
63728 + */
63729 +
63730 + if (unlikely(!(gr_status & GR_READY)))
63731 + return;
63732 +
63733 + preempt_disable();
63734 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
63735 +
63736 + /* we wouldn't have to check d_inode if it weren't for
63737 + NFS silly-renaming
63738 + */
63739 +
63740 + write_lock(&gr_inode_lock);
63741 + if (unlikely(replace && inode)) {
63742 + ino_t new_ino = inode->i_ino;
63743 + dev_t new_dev = __get_dev(new_dentry);
63744 +
63745 + inodev = lookup_inodev_entry(new_ino, new_dev);
63746 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
63747 + do_handle_delete(inodev, new_ino, new_dev);
63748 + }
63749 +
63750 + inodev = lookup_inodev_entry(old_ino, old_dev);
63751 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
63752 + do_handle_delete(inodev, old_ino, old_dev);
63753 +
63754 + if (unlikely((unsigned long)matchn))
63755 + do_handle_create(matchn, old_dentry, mnt);
63756 +
63757 + write_unlock(&gr_inode_lock);
63758 + preempt_enable();
63759 +
63760 + return;
63761 +}
63762 +
63763 +static int
63764 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
63765 + unsigned char **sum)
63766 +{
63767 + struct acl_role_label *r;
63768 + struct role_allowed_ip *ipp;
63769 + struct role_transition *trans;
63770 + unsigned int i;
63771 + int found = 0;
63772 + u32 curr_ip = current->signal->curr_ip;
63773 +
63774 + current->signal->saved_ip = curr_ip;
63775 +
63776 + /* check transition table */
63777 +
63778 + for (trans = current->role->transitions; trans; trans = trans->next) {
63779 + if (!strcmp(rolename, trans->rolename)) {
63780 + found = 1;
63781 + break;
63782 + }
63783 + }
63784 +
63785 + if (!found)
63786 + return 0;
63787 +
63788 + /* handle special roles that do not require authentication
63789 + and check ip */
63790 +
63791 + FOR_EACH_ROLE_START(r)
63792 + if (!strcmp(rolename, r->rolename) &&
63793 + (r->roletype & GR_ROLE_SPECIAL)) {
63794 + found = 0;
63795 + if (r->allowed_ips != NULL) {
63796 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
63797 + if ((ntohl(curr_ip) & ipp->netmask) ==
63798 + (ntohl(ipp->addr) & ipp->netmask))
63799 + found = 1;
63800 + }
63801 + } else
63802 + found = 2;
63803 + if (!found)
63804 + return 0;
63805 +
63806 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
63807 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
63808 + *salt = NULL;
63809 + *sum = NULL;
63810 + return 1;
63811 + }
63812 + }
63813 + FOR_EACH_ROLE_END(r)
63814 +
63815 + for (i = 0; i < num_sprole_pws; i++) {
63816 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
63817 + *salt = acl_special_roles[i]->salt;
63818 + *sum = acl_special_roles[i]->sum;
63819 + return 1;
63820 + }
63821 + }
63822 +
63823 + return 0;
63824 +}
63825 +
63826 +static void
63827 +assign_special_role(char *rolename)
63828 +{
63829 + struct acl_object_label *obj;
63830 + struct acl_role_label *r;
63831 + struct acl_role_label *assigned = NULL;
63832 + struct task_struct *tsk;
63833 + struct file *filp;
63834 +
63835 + FOR_EACH_ROLE_START(r)
63836 + if (!strcmp(rolename, r->rolename) &&
63837 + (r->roletype & GR_ROLE_SPECIAL)) {
63838 + assigned = r;
63839 + break;
63840 + }
63841 + FOR_EACH_ROLE_END(r)
63842 +
63843 + if (!assigned)
63844 + return;
63845 +
63846 + read_lock(&tasklist_lock);
63847 + read_lock(&grsec_exec_file_lock);
63848 +
63849 + tsk = current->real_parent;
63850 + if (tsk == NULL)
63851 + goto out_unlock;
63852 +
63853 + filp = tsk->exec_file;
63854 + if (filp == NULL)
63855 + goto out_unlock;
63856 +
63857 + tsk->is_writable = 0;
63858 +
63859 + tsk->acl_sp_role = 1;
63860 + tsk->acl_role_id = ++acl_sp_role_value;
63861 + tsk->role = assigned;
63862 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
63863 +
63864 + /* ignore additional mmap checks for processes that are writable
63865 + by the default ACL */
63866 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
63867 + if (unlikely(obj->mode & GR_WRITE))
63868 + tsk->is_writable = 1;
63869 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
63870 + if (unlikely(obj->mode & GR_WRITE))
63871 + tsk->is_writable = 1;
63872 +
63873 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63874 + 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));
63875 +#endif
63876 +
63877 +out_unlock:
63878 + read_unlock(&grsec_exec_file_lock);
63879 + read_unlock(&tasklist_lock);
63880 + return;
63881 +}
63882 +
63883 +int gr_check_secure_terminal(struct task_struct *task)
63884 +{
63885 + struct task_struct *p, *p2, *p3;
63886 + struct files_struct *files;
63887 + struct fdtable *fdt;
63888 + struct file *our_file = NULL, *file;
63889 + int i;
63890 +
63891 + if (task->signal->tty == NULL)
63892 + return 1;
63893 +
63894 + files = get_files_struct(task);
63895 + if (files != NULL) {
63896 + rcu_read_lock();
63897 + fdt = files_fdtable(files);
63898 + for (i=0; i < fdt->max_fds; i++) {
63899 + file = fcheck_files(files, i);
63900 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
63901 + get_file(file);
63902 + our_file = file;
63903 + }
63904 + }
63905 + rcu_read_unlock();
63906 + put_files_struct(files);
63907 + }
63908 +
63909 + if (our_file == NULL)
63910 + return 1;
63911 +
63912 + read_lock(&tasklist_lock);
63913 + do_each_thread(p2, p) {
63914 + files = get_files_struct(p);
63915 + if (files == NULL ||
63916 + (p->signal && p->signal->tty == task->signal->tty)) {
63917 + if (files != NULL)
63918 + put_files_struct(files);
63919 + continue;
63920 + }
63921 + rcu_read_lock();
63922 + fdt = files_fdtable(files);
63923 + for (i=0; i < fdt->max_fds; i++) {
63924 + file = fcheck_files(files, i);
63925 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
63926 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
63927 + p3 = task;
63928 + while (task_pid_nr(p3) > 0) {
63929 + if (p3 == p)
63930 + break;
63931 + p3 = p3->real_parent;
63932 + }
63933 + if (p3 == p)
63934 + break;
63935 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
63936 + gr_handle_alertkill(p);
63937 + rcu_read_unlock();
63938 + put_files_struct(files);
63939 + read_unlock(&tasklist_lock);
63940 + fput(our_file);
63941 + return 0;
63942 + }
63943 + }
63944 + rcu_read_unlock();
63945 + put_files_struct(files);
63946 + } while_each_thread(p2, p);
63947 + read_unlock(&tasklist_lock);
63948 +
63949 + fput(our_file);
63950 + return 1;
63951 +}
63952 +
63953 +static int gr_rbac_disable(void *unused)
63954 +{
63955 + pax_open_kernel();
63956 + gr_status &= ~GR_READY;
63957 + pax_close_kernel();
63958 +
63959 + return 0;
63960 +}
63961 +
63962 +ssize_t
63963 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
63964 +{
63965 + struct gr_arg_wrapper uwrap;
63966 + unsigned char *sprole_salt = NULL;
63967 + unsigned char *sprole_sum = NULL;
63968 + int error = 0;
63969 + int error2 = 0;
63970 + size_t req_count = 0;
63971 +
63972 + mutex_lock(&gr_dev_mutex);
63973 +
63974 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
63975 + error = -EPERM;
63976 + goto out;
63977 + }
63978 +
63979 +#ifdef CONFIG_COMPAT
63980 + pax_open_kernel();
63981 + if (is_compat_task()) {
63982 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
63983 + copy_gr_arg = &copy_gr_arg_compat;
63984 + copy_acl_object_label = &copy_acl_object_label_compat;
63985 + copy_acl_subject_label = &copy_acl_subject_label_compat;
63986 + copy_acl_role_label = &copy_acl_role_label_compat;
63987 + copy_acl_ip_label = &copy_acl_ip_label_compat;
63988 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
63989 + copy_role_transition = &copy_role_transition_compat;
63990 + copy_sprole_pw = &copy_sprole_pw_compat;
63991 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
63992 + copy_pointer_from_array = &copy_pointer_from_array_compat;
63993 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
63994 + } else {
63995 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
63996 + copy_gr_arg = &copy_gr_arg_normal;
63997 + copy_acl_object_label = &copy_acl_object_label_normal;
63998 + copy_acl_subject_label = &copy_acl_subject_label_normal;
63999 + copy_acl_role_label = &copy_acl_role_label_normal;
64000 + copy_acl_ip_label = &copy_acl_ip_label_normal;
64001 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
64002 + copy_role_transition = &copy_role_transition_normal;
64003 + copy_sprole_pw = &copy_sprole_pw_normal;
64004 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
64005 + copy_pointer_from_array = &copy_pointer_from_array_normal;
64006 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
64007 + }
64008 + pax_close_kernel();
64009 +#endif
64010 +
64011 + req_count = get_gr_arg_wrapper_size();
64012 +
64013 + if (count != req_count) {
64014 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
64015 + error = -EINVAL;
64016 + goto out;
64017 + }
64018 +
64019 +
64020 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
64021 + gr_auth_expires = 0;
64022 + gr_auth_attempts = 0;
64023 + }
64024 +
64025 + error = copy_gr_arg_wrapper(buf, &uwrap);
64026 + if (error)
64027 + goto out;
64028 +
64029 + error = copy_gr_arg(uwrap.arg, gr_usermode);
64030 + if (error)
64031 + goto out;
64032 +
64033 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
64034 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
64035 + time_after(gr_auth_expires, get_seconds())) {
64036 + error = -EBUSY;
64037 + goto out;
64038 + }
64039 +
64040 + /* if non-root trying to do anything other than use a special role,
64041 + do not attempt authentication, do not count towards authentication
64042 + locking
64043 + */
64044 +
64045 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
64046 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
64047 + gr_is_global_nonroot(current_uid())) {
64048 + error = -EPERM;
64049 + goto out;
64050 + }
64051 +
64052 + /* ensure pw and special role name are null terminated */
64053 +
64054 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
64055 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
64056 +
64057 + /* Okay.
64058 + * We have our enough of the argument structure..(we have yet
64059 + * to copy_from_user the tables themselves) . Copy the tables
64060 + * only if we need them, i.e. for loading operations. */
64061 +
64062 + switch (gr_usermode->mode) {
64063 + case GR_STATUS:
64064 + if (gr_status & GR_READY) {
64065 + error = 1;
64066 + if (!gr_check_secure_terminal(current))
64067 + error = 3;
64068 + } else
64069 + error = 2;
64070 + goto out;
64071 + case GR_SHUTDOWN:
64072 + if ((gr_status & GR_READY)
64073 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
64074 + stop_machine(gr_rbac_disable, NULL, NULL);
64075 + free_variables();
64076 + memset(gr_usermode, 0, sizeof (struct gr_arg));
64077 + memset(gr_system_salt, 0, GR_SALT_LEN);
64078 + memset(gr_system_sum, 0, GR_SHA_LEN);
64079 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
64080 + } else if (gr_status & GR_READY) {
64081 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
64082 + error = -EPERM;
64083 + } else {
64084 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
64085 + error = -EAGAIN;
64086 + }
64087 + break;
64088 + case GR_ENABLE:
64089 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
64090 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
64091 + else {
64092 + if (gr_status & GR_READY)
64093 + error = -EAGAIN;
64094 + else
64095 + error = error2;
64096 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
64097 + }
64098 + break;
64099 + case GR_RELOAD:
64100 + if (!(gr_status & GR_READY)) {
64101 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
64102 + error = -EAGAIN;
64103 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
64104 + stop_machine(gr_rbac_disable, NULL, NULL);
64105 + free_variables();
64106 + error2 = gracl_init(gr_usermode);
64107 + if (!error2)
64108 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
64109 + else {
64110 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
64111 + error = error2;
64112 + }
64113 + } else {
64114 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
64115 + error = -EPERM;
64116 + }
64117 + break;
64118 + case GR_SEGVMOD:
64119 + if (unlikely(!(gr_status & GR_READY))) {
64120 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
64121 + error = -EAGAIN;
64122 + break;
64123 + }
64124 +
64125 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
64126 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
64127 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
64128 + struct acl_subject_label *segvacl;
64129 + segvacl =
64130 + lookup_acl_subj_label(gr_usermode->segv_inode,
64131 + gr_usermode->segv_device,
64132 + current->role);
64133 + if (segvacl) {
64134 + segvacl->crashes = 0;
64135 + segvacl->expires = 0;
64136 + }
64137 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
64138 + gr_remove_uid(gr_usermode->segv_uid);
64139 + }
64140 + } else {
64141 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
64142 + error = -EPERM;
64143 + }
64144 + break;
64145 + case GR_SPROLE:
64146 + case GR_SPROLEPAM:
64147 + if (unlikely(!(gr_status & GR_READY))) {
64148 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
64149 + error = -EAGAIN;
64150 + break;
64151 + }
64152 +
64153 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
64154 + current->role->expires = 0;
64155 + current->role->auth_attempts = 0;
64156 + }
64157 +
64158 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
64159 + time_after(current->role->expires, get_seconds())) {
64160 + error = -EBUSY;
64161 + goto out;
64162 + }
64163 +
64164 + if (lookup_special_role_auth
64165 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
64166 + && ((!sprole_salt && !sprole_sum)
64167 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
64168 + char *p = "";
64169 + assign_special_role(gr_usermode->sp_role);
64170 + read_lock(&tasklist_lock);
64171 + if (current->real_parent)
64172 + p = current->real_parent->role->rolename;
64173 + read_unlock(&tasklist_lock);
64174 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
64175 + p, acl_sp_role_value);
64176 + } else {
64177 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
64178 + error = -EPERM;
64179 + if(!(current->role->auth_attempts++))
64180 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
64181 +
64182 + goto out;
64183 + }
64184 + break;
64185 + case GR_UNSPROLE:
64186 + if (unlikely(!(gr_status & GR_READY))) {
64187 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
64188 + error = -EAGAIN;
64189 + break;
64190 + }
64191 +
64192 + if (current->role->roletype & GR_ROLE_SPECIAL) {
64193 + char *p = "";
64194 + int i = 0;
64195 +
64196 + read_lock(&tasklist_lock);
64197 + if (current->real_parent) {
64198 + p = current->real_parent->role->rolename;
64199 + i = current->real_parent->acl_role_id;
64200 + }
64201 + read_unlock(&tasklist_lock);
64202 +
64203 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
64204 + gr_set_acls(1);
64205 + } else {
64206 + error = -EPERM;
64207 + goto out;
64208 + }
64209 + break;
64210 + default:
64211 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
64212 + error = -EINVAL;
64213 + break;
64214 + }
64215 +
64216 + if (error != -EPERM)
64217 + goto out;
64218 +
64219 + if(!(gr_auth_attempts++))
64220 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
64221 +
64222 + out:
64223 + mutex_unlock(&gr_dev_mutex);
64224 +
64225 + if (!error)
64226 + error = req_count;
64227 +
64228 + return error;
64229 +}
64230 +
64231 +/* must be called with
64232 + rcu_read_lock();
64233 + read_lock(&tasklist_lock);
64234 + read_lock(&grsec_exec_file_lock);
64235 +*/
64236 +int gr_apply_subject_to_task(struct task_struct *task)
64237 +{
64238 + struct acl_object_label *obj;
64239 + char *tmpname;
64240 + struct acl_subject_label *tmpsubj;
64241 + struct file *filp;
64242 + struct name_entry *nmatch;
64243 +
64244 + filp = task->exec_file;
64245 + if (filp == NULL)
64246 + return 0;
64247 +
64248 + /* the following is to apply the correct subject
64249 + on binaries running when the RBAC system
64250 + is enabled, when the binaries have been
64251 + replaced or deleted since their execution
64252 + -----
64253 + when the RBAC system starts, the inode/dev
64254 + from exec_file will be one the RBAC system
64255 + is unaware of. It only knows the inode/dev
64256 + of the present file on disk, or the absence
64257 + of it.
64258 + */
64259 + preempt_disable();
64260 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
64261 +
64262 + nmatch = lookup_name_entry(tmpname);
64263 + preempt_enable();
64264 + tmpsubj = NULL;
64265 + if (nmatch) {
64266 + if (nmatch->deleted)
64267 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
64268 + else
64269 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
64270 + if (tmpsubj != NULL)
64271 + task->acl = tmpsubj;
64272 + }
64273 + if (tmpsubj == NULL)
64274 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
64275 + task->role);
64276 + if (task->acl) {
64277 + task->is_writable = 0;
64278 + /* ignore additional mmap checks for processes that are writable
64279 + by the default ACL */
64280 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64281 + if (unlikely(obj->mode & GR_WRITE))
64282 + task->is_writable = 1;
64283 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64284 + if (unlikely(obj->mode & GR_WRITE))
64285 + task->is_writable = 1;
64286 +
64287 + gr_set_proc_res(task);
64288 +
64289 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64290 + 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);
64291 +#endif
64292 + } else {
64293 + return 1;
64294 + }
64295 +
64296 + return 0;
64297 +}
64298 +
64299 +int
64300 +gr_set_acls(const int type)
64301 +{
64302 + struct task_struct *task, *task2;
64303 + struct acl_role_label *role = current->role;
64304 + __u16 acl_role_id = current->acl_role_id;
64305 + const struct cred *cred;
64306 + int ret;
64307 +
64308 + rcu_read_lock();
64309 + read_lock(&tasklist_lock);
64310 + read_lock(&grsec_exec_file_lock);
64311 + do_each_thread(task2, task) {
64312 + /* check to see if we're called from the exit handler,
64313 + if so, only replace ACLs that have inherited the admin
64314 + ACL */
64315 +
64316 + if (type && (task->role != role ||
64317 + task->acl_role_id != acl_role_id))
64318 + continue;
64319 +
64320 + task->acl_role_id = 0;
64321 + task->acl_sp_role = 0;
64322 +
64323 + if (task->exec_file) {
64324 + cred = __task_cred(task);
64325 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
64326 + ret = gr_apply_subject_to_task(task);
64327 + if (ret) {
64328 + read_unlock(&grsec_exec_file_lock);
64329 + read_unlock(&tasklist_lock);
64330 + rcu_read_unlock();
64331 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
64332 + return ret;
64333 + }
64334 + } else {
64335 + // it's a kernel process
64336 + task->role = kernel_role;
64337 + task->acl = kernel_role->root_label;
64338 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
64339 + task->acl->mode &= ~GR_PROCFIND;
64340 +#endif
64341 + }
64342 + } while_each_thread(task2, task);
64343 + read_unlock(&grsec_exec_file_lock);
64344 + read_unlock(&tasklist_lock);
64345 + rcu_read_unlock();
64346 +
64347 + return 0;
64348 +}
64349 +
64350 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
64351 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
64352 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
64353 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
64354 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
64355 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
64356 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
64357 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
64358 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
64359 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
64360 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
64361 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
64362 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
64363 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
64364 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
64365 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
64366 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
64367 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
64368 +};
64369 +
64370 +void
64371 +gr_learn_resource(const struct task_struct *task,
64372 + const int res, const unsigned long wanted, const int gt)
64373 +{
64374 + struct acl_subject_label *acl;
64375 + const struct cred *cred;
64376 +
64377 + if (unlikely((gr_status & GR_READY) &&
64378 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
64379 + goto skip_reslog;
64380 +
64381 + gr_log_resource(task, res, wanted, gt);
64382 +skip_reslog:
64383 +
64384 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
64385 + return;
64386 +
64387 + acl = task->acl;
64388 +
64389 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
64390 + !(acl->resmask & (1U << (unsigned short) res))))
64391 + return;
64392 +
64393 + if (wanted >= acl->res[res].rlim_cur) {
64394 + unsigned long res_add;
64395 +
64396 + res_add = wanted + res_learn_bumps[res];
64397 +
64398 + acl->res[res].rlim_cur = res_add;
64399 +
64400 + if (wanted > acl->res[res].rlim_max)
64401 + acl->res[res].rlim_max = res_add;
64402 +
64403 + /* only log the subject filename, since resource logging is supported for
64404 + single-subject learning only */
64405 + rcu_read_lock();
64406 + cred = __task_cred(task);
64407 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
64408 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
64409 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
64410 + "", (unsigned long) res, &task->signal->saved_ip);
64411 + rcu_read_unlock();
64412 + }
64413 +
64414 + return;
64415 +}
64416 +EXPORT_SYMBOL(gr_learn_resource);
64417 +#endif
64418 +
64419 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
64420 +void
64421 +pax_set_initial_flags(struct linux_binprm *bprm)
64422 +{
64423 + struct task_struct *task = current;
64424 + struct acl_subject_label *proc;
64425 + unsigned long flags;
64426 +
64427 + if (unlikely(!(gr_status & GR_READY)))
64428 + return;
64429 +
64430 + flags = pax_get_flags(task);
64431 +
64432 + proc = task->acl;
64433 +
64434 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
64435 + flags &= ~MF_PAX_PAGEEXEC;
64436 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
64437 + flags &= ~MF_PAX_SEGMEXEC;
64438 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
64439 + flags &= ~MF_PAX_RANDMMAP;
64440 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
64441 + flags &= ~MF_PAX_EMUTRAMP;
64442 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
64443 + flags &= ~MF_PAX_MPROTECT;
64444 +
64445 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
64446 + flags |= MF_PAX_PAGEEXEC;
64447 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
64448 + flags |= MF_PAX_SEGMEXEC;
64449 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
64450 + flags |= MF_PAX_RANDMMAP;
64451 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
64452 + flags |= MF_PAX_EMUTRAMP;
64453 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
64454 + flags |= MF_PAX_MPROTECT;
64455 +
64456 + pax_set_flags(task, flags);
64457 +
64458 + return;
64459 +}
64460 +#endif
64461 +
64462 +int
64463 +gr_handle_proc_ptrace(struct task_struct *task)
64464 +{
64465 + struct file *filp;
64466 + struct task_struct *tmp = task;
64467 + struct task_struct *curtemp = current;
64468 + __u32 retmode;
64469 +
64470 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
64471 + if (unlikely(!(gr_status & GR_READY)))
64472 + return 0;
64473 +#endif
64474 +
64475 + read_lock(&tasklist_lock);
64476 + read_lock(&grsec_exec_file_lock);
64477 + filp = task->exec_file;
64478 +
64479 + while (task_pid_nr(tmp) > 0) {
64480 + if (tmp == curtemp)
64481 + break;
64482 + tmp = tmp->real_parent;
64483 + }
64484 +
64485 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
64486 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
64487 + read_unlock(&grsec_exec_file_lock);
64488 + read_unlock(&tasklist_lock);
64489 + return 1;
64490 + }
64491 +
64492 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64493 + if (!(gr_status & GR_READY)) {
64494 + read_unlock(&grsec_exec_file_lock);
64495 + read_unlock(&tasklist_lock);
64496 + return 0;
64497 + }
64498 +#endif
64499 +
64500 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
64501 + read_unlock(&grsec_exec_file_lock);
64502 + read_unlock(&tasklist_lock);
64503 +
64504 + if (retmode & GR_NOPTRACE)
64505 + return 1;
64506 +
64507 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
64508 + && (current->acl != task->acl || (current->acl != current->role->root_label
64509 + && task_pid_nr(current) != task_pid_nr(task))))
64510 + return 1;
64511 +
64512 + return 0;
64513 +}
64514 +
64515 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
64516 +{
64517 + if (unlikely(!(gr_status & GR_READY)))
64518 + return;
64519 +
64520 + if (!(current->role->roletype & GR_ROLE_GOD))
64521 + return;
64522 +
64523 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
64524 + p->role->rolename, gr_task_roletype_to_char(p),
64525 + p->acl->filename);
64526 +}
64527 +
64528 +int
64529 +gr_handle_ptrace(struct task_struct *task, const long request)
64530 +{
64531 + struct task_struct *tmp = task;
64532 + struct task_struct *curtemp = current;
64533 + __u32 retmode;
64534 +
64535 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
64536 + if (unlikely(!(gr_status & GR_READY)))
64537 + return 0;
64538 +#endif
64539 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
64540 + read_lock(&tasklist_lock);
64541 + while (task_pid_nr(tmp) > 0) {
64542 + if (tmp == curtemp)
64543 + break;
64544 + tmp = tmp->real_parent;
64545 + }
64546 +
64547 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
64548 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
64549 + read_unlock(&tasklist_lock);
64550 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
64551 + return 1;
64552 + }
64553 + read_unlock(&tasklist_lock);
64554 + }
64555 +
64556 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64557 + if (!(gr_status & GR_READY))
64558 + return 0;
64559 +#endif
64560 +
64561 + read_lock(&grsec_exec_file_lock);
64562 + if (unlikely(!task->exec_file)) {
64563 + read_unlock(&grsec_exec_file_lock);
64564 + return 0;
64565 + }
64566 +
64567 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
64568 + read_unlock(&grsec_exec_file_lock);
64569 +
64570 + if (retmode & GR_NOPTRACE) {
64571 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
64572 + return 1;
64573 + }
64574 +
64575 + if (retmode & GR_PTRACERD) {
64576 + switch (request) {
64577 + case PTRACE_SEIZE:
64578 + case PTRACE_POKETEXT:
64579 + case PTRACE_POKEDATA:
64580 + case PTRACE_POKEUSR:
64581 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
64582 + case PTRACE_SETREGS:
64583 + case PTRACE_SETFPREGS:
64584 +#endif
64585 +#ifdef CONFIG_X86
64586 + case PTRACE_SETFPXREGS:
64587 +#endif
64588 +#ifdef CONFIG_ALTIVEC
64589 + case PTRACE_SETVRREGS:
64590 +#endif
64591 + return 1;
64592 + default:
64593 + return 0;
64594 + }
64595 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
64596 + !(current->role->roletype & GR_ROLE_GOD) &&
64597 + (current->acl != task->acl)) {
64598 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
64599 + return 1;
64600 + }
64601 +
64602 + return 0;
64603 +}
64604 +
64605 +static int is_writable_mmap(const struct file *filp)
64606 +{
64607 + struct task_struct *task = current;
64608 + struct acl_object_label *obj, *obj2;
64609 +
64610 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
64611 + !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))) {
64612 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64613 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
64614 + task->role->root_label);
64615 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
64616 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
64617 + return 1;
64618 + }
64619 + }
64620 + return 0;
64621 +}
64622 +
64623 +int
64624 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
64625 +{
64626 + __u32 mode;
64627 +
64628 + if (unlikely(!file || !(prot & PROT_EXEC)))
64629 + return 1;
64630 +
64631 + if (is_writable_mmap(file))
64632 + return 0;
64633 +
64634 + mode =
64635 + gr_search_file(file->f_path.dentry,
64636 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
64637 + file->f_path.mnt);
64638 +
64639 + if (!gr_tpe_allow(file))
64640 + return 0;
64641 +
64642 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
64643 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64644 + return 0;
64645 + } else if (unlikely(!(mode & GR_EXEC))) {
64646 + return 0;
64647 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
64648 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64649 + return 1;
64650 + }
64651 +
64652 + return 1;
64653 +}
64654 +
64655 +int
64656 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64657 +{
64658 + __u32 mode;
64659 +
64660 + if (unlikely(!file || !(prot & PROT_EXEC)))
64661 + return 1;
64662 +
64663 + if (is_writable_mmap(file))
64664 + return 0;
64665 +
64666 + mode =
64667 + gr_search_file(file->f_path.dentry,
64668 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
64669 + file->f_path.mnt);
64670 +
64671 + if (!gr_tpe_allow(file))
64672 + return 0;
64673 +
64674 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
64675 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64676 + return 0;
64677 + } else if (unlikely(!(mode & GR_EXEC))) {
64678 + return 0;
64679 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
64680 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64681 + return 1;
64682 + }
64683 +
64684 + return 1;
64685 +}
64686 +
64687 +void
64688 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64689 +{
64690 + unsigned long runtime;
64691 + unsigned long cputime;
64692 + unsigned int wday, cday;
64693 + __u8 whr, chr;
64694 + __u8 wmin, cmin;
64695 + __u8 wsec, csec;
64696 + struct timespec timeval;
64697 +
64698 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
64699 + !(task->acl->mode & GR_PROCACCT)))
64700 + return;
64701 +
64702 + do_posix_clock_monotonic_gettime(&timeval);
64703 + runtime = timeval.tv_sec - task->start_time.tv_sec;
64704 + wday = runtime / (3600 * 24);
64705 + runtime -= wday * (3600 * 24);
64706 + whr = runtime / 3600;
64707 + runtime -= whr * 3600;
64708 + wmin = runtime / 60;
64709 + runtime -= wmin * 60;
64710 + wsec = runtime;
64711 +
64712 + cputime = (task->utime + task->stime) / HZ;
64713 + cday = cputime / (3600 * 24);
64714 + cputime -= cday * (3600 * 24);
64715 + chr = cputime / 3600;
64716 + cputime -= chr * 3600;
64717 + cmin = cputime / 60;
64718 + cputime -= cmin * 60;
64719 + csec = cputime;
64720 +
64721 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
64722 +
64723 + return;
64724 +}
64725 +
64726 +void gr_set_kernel_label(struct task_struct *task)
64727 +{
64728 + if (gr_status & GR_READY) {
64729 + task->role = kernel_role;
64730 + task->acl = kernel_role->root_label;
64731 + }
64732 + return;
64733 +}
64734 +
64735 +#ifdef CONFIG_TASKSTATS
64736 +int gr_is_taskstats_denied(int pid)
64737 +{
64738 + struct task_struct *task;
64739 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
64740 + const struct cred *cred;
64741 +#endif
64742 + int ret = 0;
64743 +
64744 + /* restrict taskstats viewing to un-chrooted root users
64745 + who have the 'view' subject flag if the RBAC system is enabled
64746 + */
64747 +
64748 + rcu_read_lock();
64749 + read_lock(&tasklist_lock);
64750 + task = find_task_by_vpid(pid);
64751 + if (task) {
64752 +#ifdef CONFIG_GRKERNSEC_CHROOT
64753 + if (proc_is_chrooted(task))
64754 + ret = -EACCES;
64755 +#endif
64756 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
64757 + cred = __task_cred(task);
64758 +#ifdef CONFIG_GRKERNSEC_PROC_USER
64759 + if (gr_is_global_nonroot(cred->uid))
64760 + ret = -EACCES;
64761 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
64762 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
64763 + ret = -EACCES;
64764 +#endif
64765 +#endif
64766 + if (gr_status & GR_READY) {
64767 + if (!(task->acl->mode & GR_VIEW))
64768 + ret = -EACCES;
64769 + }
64770 + } else
64771 + ret = -ENOENT;
64772 +
64773 + read_unlock(&tasklist_lock);
64774 + rcu_read_unlock();
64775 +
64776 + return ret;
64777 +}
64778 +#endif
64779 +
64780 +/* AUXV entries are filled via a descendant of search_binary_handler
64781 + after we've already applied the subject for the target
64782 +*/
64783 +int gr_acl_enable_at_secure(void)
64784 +{
64785 + if (unlikely(!(gr_status & GR_READY)))
64786 + return 0;
64787 +
64788 + if (current->acl->mode & GR_ATSECURE)
64789 + return 1;
64790 +
64791 + return 0;
64792 +}
64793 +
64794 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
64795 +{
64796 + struct task_struct *task = current;
64797 + struct dentry *dentry = file->f_path.dentry;
64798 + struct vfsmount *mnt = file->f_path.mnt;
64799 + struct acl_object_label *obj, *tmp;
64800 + struct acl_subject_label *subj;
64801 + unsigned int bufsize;
64802 + int is_not_root;
64803 + char *path;
64804 + dev_t dev = __get_dev(dentry);
64805 +
64806 + if (unlikely(!(gr_status & GR_READY)))
64807 + return 1;
64808 +
64809 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64810 + return 1;
64811 +
64812 + /* ignore Eric Biederman */
64813 + if (IS_PRIVATE(dentry->d_inode))
64814 + return 1;
64815 +
64816 + subj = task->acl;
64817 + read_lock(&gr_inode_lock);
64818 + do {
64819 + obj = lookup_acl_obj_label(ino, dev, subj);
64820 + if (obj != NULL) {
64821 + read_unlock(&gr_inode_lock);
64822 + return (obj->mode & GR_FIND) ? 1 : 0;
64823 + }
64824 + } while ((subj = subj->parent_subject));
64825 + read_unlock(&gr_inode_lock);
64826 +
64827 + /* this is purely an optimization since we're looking for an object
64828 + for the directory we're doing a readdir on
64829 + if it's possible for any globbed object to match the entry we're
64830 + filling into the directory, then the object we find here will be
64831 + an anchor point with attached globbed objects
64832 + */
64833 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
64834 + if (obj->globbed == NULL)
64835 + return (obj->mode & GR_FIND) ? 1 : 0;
64836 +
64837 + is_not_root = ((obj->filename[0] == '/') &&
64838 + (obj->filename[1] == '\0')) ? 0 : 1;
64839 + bufsize = PAGE_SIZE - namelen - is_not_root;
64840 +
64841 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
64842 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
64843 + return 1;
64844 +
64845 + preempt_disable();
64846 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
64847 + bufsize);
64848 +
64849 + bufsize = strlen(path);
64850 +
64851 + /* if base is "/", don't append an additional slash */
64852 + if (is_not_root)
64853 + *(path + bufsize) = '/';
64854 + memcpy(path + bufsize + is_not_root, name, namelen);
64855 + *(path + bufsize + namelen + is_not_root) = '\0';
64856 +
64857 + tmp = obj->globbed;
64858 + while (tmp) {
64859 + if (!glob_match(tmp->filename, path)) {
64860 + preempt_enable();
64861 + return (tmp->mode & GR_FIND) ? 1 : 0;
64862 + }
64863 + tmp = tmp->next;
64864 + }
64865 + preempt_enable();
64866 + return (obj->mode & GR_FIND) ? 1 : 0;
64867 +}
64868 +
64869 +void gr_put_exec_file(struct task_struct *task)
64870 +{
64871 + struct file *filp;
64872 +
64873 + write_lock(&grsec_exec_file_lock);
64874 + filp = task->exec_file;
64875 + task->exec_file = NULL;
64876 + write_unlock(&grsec_exec_file_lock);
64877 +
64878 + if (filp)
64879 + fput(filp);
64880 +
64881 + return;
64882 +}
64883 +
64884 +
64885 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
64886 +EXPORT_SYMBOL(gr_acl_is_enabled);
64887 +#endif
64888 +EXPORT_SYMBOL(gr_set_kernel_label);
64889 +#ifdef CONFIG_SECURITY
64890 +EXPORT_SYMBOL(gr_check_user_change);
64891 +EXPORT_SYMBOL(gr_check_group_change);
64892 +#endif
64893 +
64894 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
64895 new file mode 100644
64896 index 0000000..34fefda
64897 --- /dev/null
64898 +++ b/grsecurity/gracl_alloc.c
64899 @@ -0,0 +1,105 @@
64900 +#include <linux/kernel.h>
64901 +#include <linux/mm.h>
64902 +#include <linux/slab.h>
64903 +#include <linux/vmalloc.h>
64904 +#include <linux/gracl.h>
64905 +#include <linux/grsecurity.h>
64906 +
64907 +static unsigned long alloc_stack_next = 1;
64908 +static unsigned long alloc_stack_size = 1;
64909 +static void **alloc_stack;
64910 +
64911 +static __inline__ int
64912 +alloc_pop(void)
64913 +{
64914 + if (alloc_stack_next == 1)
64915 + return 0;
64916 +
64917 + kfree(alloc_stack[alloc_stack_next - 2]);
64918 +
64919 + alloc_stack_next--;
64920 +
64921 + return 1;
64922 +}
64923 +
64924 +static __inline__ int
64925 +alloc_push(void *buf)
64926 +{
64927 + if (alloc_stack_next >= alloc_stack_size)
64928 + return 1;
64929 +
64930 + alloc_stack[alloc_stack_next - 1] = buf;
64931 +
64932 + alloc_stack_next++;
64933 +
64934 + return 0;
64935 +}
64936 +
64937 +void *
64938 +acl_alloc(unsigned long len)
64939 +{
64940 + void *ret = NULL;
64941 +
64942 + if (!len || len > PAGE_SIZE)
64943 + goto out;
64944 +
64945 + ret = kmalloc(len, GFP_KERNEL);
64946 +
64947 + if (ret) {
64948 + if (alloc_push(ret)) {
64949 + kfree(ret);
64950 + ret = NULL;
64951 + }
64952 + }
64953 +
64954 +out:
64955 + return ret;
64956 +}
64957 +
64958 +void *
64959 +acl_alloc_num(unsigned long num, unsigned long len)
64960 +{
64961 + if (!len || (num > (PAGE_SIZE / len)))
64962 + return NULL;
64963 +
64964 + return acl_alloc(num * len);
64965 +}
64966 +
64967 +void
64968 +acl_free_all(void)
64969 +{
64970 + if (gr_acl_is_enabled() || !alloc_stack)
64971 + return;
64972 +
64973 + while (alloc_pop()) ;
64974 +
64975 + if (alloc_stack) {
64976 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
64977 + kfree(alloc_stack);
64978 + else
64979 + vfree(alloc_stack);
64980 + }
64981 +
64982 + alloc_stack = NULL;
64983 + alloc_stack_size = 1;
64984 + alloc_stack_next = 1;
64985 +
64986 + return;
64987 +}
64988 +
64989 +int
64990 +acl_alloc_stack_init(unsigned long size)
64991 +{
64992 + if ((size * sizeof (void *)) <= PAGE_SIZE)
64993 + alloc_stack =
64994 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
64995 + else
64996 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
64997 +
64998 + alloc_stack_size = size;
64999 +
65000 + if (!alloc_stack)
65001 + return 0;
65002 + else
65003 + return 1;
65004 +}
65005 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
65006 new file mode 100644
65007 index 0000000..bdd51ea
65008 --- /dev/null
65009 +++ b/grsecurity/gracl_cap.c
65010 @@ -0,0 +1,110 @@
65011 +#include <linux/kernel.h>
65012 +#include <linux/module.h>
65013 +#include <linux/sched.h>
65014 +#include <linux/gracl.h>
65015 +#include <linux/grsecurity.h>
65016 +#include <linux/grinternal.h>
65017 +
65018 +extern const char *captab_log[];
65019 +extern int captab_log_entries;
65020 +
65021 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
65022 +{
65023 + struct acl_subject_label *curracl;
65024 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
65025 + kernel_cap_t cap_audit = __cap_empty_set;
65026 +
65027 + if (!gr_acl_is_enabled())
65028 + return 1;
65029 +
65030 + curracl = task->acl;
65031 +
65032 + cap_drop = curracl->cap_lower;
65033 + cap_mask = curracl->cap_mask;
65034 + cap_audit = curracl->cap_invert_audit;
65035 +
65036 + while ((curracl = curracl->parent_subject)) {
65037 + /* if the cap isn't specified in the current computed mask but is specified in the
65038 + current level subject, and is lowered in the current level subject, then add
65039 + it to the set of dropped capabilities
65040 + otherwise, add the current level subject's mask to the current computed mask
65041 + */
65042 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65043 + cap_raise(cap_mask, cap);
65044 + if (cap_raised(curracl->cap_lower, cap))
65045 + cap_raise(cap_drop, cap);
65046 + if (cap_raised(curracl->cap_invert_audit, cap))
65047 + cap_raise(cap_audit, cap);
65048 + }
65049 + }
65050 +
65051 + if (!cap_raised(cap_drop, cap)) {
65052 + if (cap_raised(cap_audit, cap))
65053 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
65054 + return 1;
65055 + }
65056 +
65057 + curracl = task->acl;
65058 +
65059 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
65060 + && cap_raised(cred->cap_effective, cap)) {
65061 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65062 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
65063 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
65064 + gr_to_filename(task->exec_file->f_path.dentry,
65065 + task->exec_file->f_path.mnt) : curracl->filename,
65066 + curracl->filename, 0UL,
65067 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
65068 + return 1;
65069 + }
65070 +
65071 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
65072 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
65073 +
65074 + return 0;
65075 +}
65076 +
65077 +int
65078 +gr_acl_is_capable(const int cap)
65079 +{
65080 + return gr_task_acl_is_capable(current, current_cred(), cap);
65081 +}
65082 +
65083 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
65084 +{
65085 + struct acl_subject_label *curracl;
65086 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
65087 +
65088 + if (!gr_acl_is_enabled())
65089 + return 1;
65090 +
65091 + curracl = task->acl;
65092 +
65093 + cap_drop = curracl->cap_lower;
65094 + cap_mask = curracl->cap_mask;
65095 +
65096 + while ((curracl = curracl->parent_subject)) {
65097 + /* if the cap isn't specified in the current computed mask but is specified in the
65098 + current level subject, and is lowered in the current level subject, then add
65099 + it to the set of dropped capabilities
65100 + otherwise, add the current level subject's mask to the current computed mask
65101 + */
65102 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65103 + cap_raise(cap_mask, cap);
65104 + if (cap_raised(curracl->cap_lower, cap))
65105 + cap_raise(cap_drop, cap);
65106 + }
65107 + }
65108 +
65109 + if (!cap_raised(cap_drop, cap))
65110 + return 1;
65111 +
65112 + return 0;
65113 +}
65114 +
65115 +int
65116 +gr_acl_is_capable_nolog(const int cap)
65117 +{
65118 + return gr_task_acl_is_capable_nolog(current, cap);
65119 +}
65120 +
65121 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
65122 new file mode 100644
65123 index 0000000..a43dd06
65124 --- /dev/null
65125 +++ b/grsecurity/gracl_compat.c
65126 @@ -0,0 +1,269 @@
65127 +#include <linux/kernel.h>
65128 +#include <linux/gracl.h>
65129 +#include <linux/compat.h>
65130 +#include <linux/gracl_compat.h>
65131 +
65132 +#include <asm/uaccess.h>
65133 +
65134 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
65135 +{
65136 + struct gr_arg_wrapper_compat uwrapcompat;
65137 +
65138 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
65139 + return -EFAULT;
65140 +
65141 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
65142 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
65143 + return -EINVAL;
65144 +
65145 + uwrap->arg = compat_ptr(uwrapcompat.arg);
65146 + uwrap->version = uwrapcompat.version;
65147 + uwrap->size = sizeof(struct gr_arg);
65148 +
65149 + return 0;
65150 +}
65151 +
65152 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
65153 +{
65154 + struct gr_arg_compat argcompat;
65155 +
65156 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
65157 + return -EFAULT;
65158 +
65159 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
65160 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
65161 + arg->role_db.num_roles = argcompat.role_db.num_roles;
65162 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
65163 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
65164 + arg->role_db.num_objects = argcompat.role_db.num_objects;
65165 +
65166 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
65167 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
65168 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
65169 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
65170 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
65171 + arg->segv_device = argcompat.segv_device;
65172 + arg->segv_inode = argcompat.segv_inode;
65173 + arg->segv_uid = argcompat.segv_uid;
65174 + arg->num_sprole_pws = argcompat.num_sprole_pws;
65175 + arg->mode = argcompat.mode;
65176 +
65177 + return 0;
65178 +}
65179 +
65180 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
65181 +{
65182 + struct acl_object_label_compat objcompat;
65183 +
65184 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
65185 + return -EFAULT;
65186 +
65187 + obj->filename = compat_ptr(objcompat.filename);
65188 + obj->inode = objcompat.inode;
65189 + obj->device = objcompat.device;
65190 + obj->mode = objcompat.mode;
65191 +
65192 + obj->nested = compat_ptr(objcompat.nested);
65193 + obj->globbed = compat_ptr(objcompat.globbed);
65194 +
65195 + obj->prev = compat_ptr(objcompat.prev);
65196 + obj->next = compat_ptr(objcompat.next);
65197 +
65198 + return 0;
65199 +}
65200 +
65201 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
65202 +{
65203 + unsigned int i;
65204 + struct acl_subject_label_compat subjcompat;
65205 +
65206 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
65207 + return -EFAULT;
65208 +
65209 + subj->filename = compat_ptr(subjcompat.filename);
65210 + subj->inode = subjcompat.inode;
65211 + subj->device = subjcompat.device;
65212 + subj->mode = subjcompat.mode;
65213 + subj->cap_mask = subjcompat.cap_mask;
65214 + subj->cap_lower = subjcompat.cap_lower;
65215 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
65216 +
65217 + for (i = 0; i < GR_NLIMITS; i++) {
65218 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
65219 + subj->res[i].rlim_cur = RLIM_INFINITY;
65220 + else
65221 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
65222 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
65223 + subj->res[i].rlim_max = RLIM_INFINITY;
65224 + else
65225 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
65226 + }
65227 + subj->resmask = subjcompat.resmask;
65228 +
65229 + subj->user_trans_type = subjcompat.user_trans_type;
65230 + subj->group_trans_type = subjcompat.group_trans_type;
65231 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
65232 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
65233 + subj->user_trans_num = subjcompat.user_trans_num;
65234 + subj->group_trans_num = subjcompat.group_trans_num;
65235 +
65236 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
65237 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
65238 + subj->ip_type = subjcompat.ip_type;
65239 + subj->ips = compat_ptr(subjcompat.ips);
65240 + subj->ip_num = subjcompat.ip_num;
65241 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
65242 +
65243 + subj->crashes = subjcompat.crashes;
65244 + subj->expires = subjcompat.expires;
65245 +
65246 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
65247 + subj->hash = compat_ptr(subjcompat.hash);
65248 + subj->prev = compat_ptr(subjcompat.prev);
65249 + subj->next = compat_ptr(subjcompat.next);
65250 +
65251 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
65252 + subj->obj_hash_size = subjcompat.obj_hash_size;
65253 + subj->pax_flags = subjcompat.pax_flags;
65254 +
65255 + return 0;
65256 +}
65257 +
65258 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
65259 +{
65260 + struct acl_role_label_compat rolecompat;
65261 +
65262 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
65263 + return -EFAULT;
65264 +
65265 + role->rolename = compat_ptr(rolecompat.rolename);
65266 + role->uidgid = rolecompat.uidgid;
65267 + role->roletype = rolecompat.roletype;
65268 +
65269 + role->auth_attempts = rolecompat.auth_attempts;
65270 + role->expires = rolecompat.expires;
65271 +
65272 + role->root_label = compat_ptr(rolecompat.root_label);
65273 + role->hash = compat_ptr(rolecompat.hash);
65274 +
65275 + role->prev = compat_ptr(rolecompat.prev);
65276 + role->next = compat_ptr(rolecompat.next);
65277 +
65278 + role->transitions = compat_ptr(rolecompat.transitions);
65279 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
65280 + role->domain_children = compat_ptr(rolecompat.domain_children);
65281 + role->domain_child_num = rolecompat.domain_child_num;
65282 +
65283 + role->umask = rolecompat.umask;
65284 +
65285 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
65286 + role->subj_hash_size = rolecompat.subj_hash_size;
65287 +
65288 + return 0;
65289 +}
65290 +
65291 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
65292 +{
65293 + struct role_allowed_ip_compat roleip_compat;
65294 +
65295 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
65296 + return -EFAULT;
65297 +
65298 + roleip->addr = roleip_compat.addr;
65299 + roleip->netmask = roleip_compat.netmask;
65300 +
65301 + roleip->prev = compat_ptr(roleip_compat.prev);
65302 + roleip->next = compat_ptr(roleip_compat.next);
65303 +
65304 + return 0;
65305 +}
65306 +
65307 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
65308 +{
65309 + struct role_transition_compat trans_compat;
65310 +
65311 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
65312 + return -EFAULT;
65313 +
65314 + trans->rolename = compat_ptr(trans_compat.rolename);
65315 +
65316 + trans->prev = compat_ptr(trans_compat.prev);
65317 + trans->next = compat_ptr(trans_compat.next);
65318 +
65319 + return 0;
65320 +
65321 +}
65322 +
65323 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
65324 +{
65325 + struct gr_hash_struct_compat hash_compat;
65326 +
65327 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
65328 + return -EFAULT;
65329 +
65330 + hash->table = compat_ptr(hash_compat.table);
65331 + hash->nametable = compat_ptr(hash_compat.nametable);
65332 + hash->first = compat_ptr(hash_compat.first);
65333 +
65334 + hash->table_size = hash_compat.table_size;
65335 + hash->used_size = hash_compat.used_size;
65336 +
65337 + hash->type = hash_compat.type;
65338 +
65339 + return 0;
65340 +}
65341 +
65342 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
65343 +{
65344 + compat_uptr_t ptrcompat;
65345 +
65346 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
65347 + return -EFAULT;
65348 +
65349 + *(void **)ptr = compat_ptr(ptrcompat);
65350 +
65351 + return 0;
65352 +}
65353 +
65354 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
65355 +{
65356 + struct acl_ip_label_compat ip_compat;
65357 +
65358 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
65359 + return -EFAULT;
65360 +
65361 + ip->iface = compat_ptr(ip_compat.iface);
65362 + ip->addr = ip_compat.addr;
65363 + ip->netmask = ip_compat.netmask;
65364 + ip->low = ip_compat.low;
65365 + ip->high = ip_compat.high;
65366 + ip->mode = ip_compat.mode;
65367 + ip->type = ip_compat.type;
65368 +
65369 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
65370 +
65371 + ip->prev = compat_ptr(ip_compat.prev);
65372 + ip->next = compat_ptr(ip_compat.next);
65373 +
65374 + return 0;
65375 +}
65376 +
65377 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
65378 +{
65379 + struct sprole_pw_compat pw_compat;
65380 +
65381 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
65382 + return -EFAULT;
65383 +
65384 + pw->rolename = compat_ptr(pw_compat.rolename);
65385 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
65386 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
65387 +
65388 + return 0;
65389 +}
65390 +
65391 +size_t get_gr_arg_wrapper_size_compat(void)
65392 +{
65393 + return sizeof(struct gr_arg_wrapper_compat);
65394 +}
65395 +
65396 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
65397 new file mode 100644
65398 index 0000000..a340c17
65399 --- /dev/null
65400 +++ b/grsecurity/gracl_fs.c
65401 @@ -0,0 +1,431 @@
65402 +#include <linux/kernel.h>
65403 +#include <linux/sched.h>
65404 +#include <linux/types.h>
65405 +#include <linux/fs.h>
65406 +#include <linux/file.h>
65407 +#include <linux/stat.h>
65408 +#include <linux/grsecurity.h>
65409 +#include <linux/grinternal.h>
65410 +#include <linux/gracl.h>
65411 +
65412 +umode_t
65413 +gr_acl_umask(void)
65414 +{
65415 + if (unlikely(!gr_acl_is_enabled()))
65416 + return 0;
65417 +
65418 + return current->role->umask;
65419 +}
65420 +
65421 +__u32
65422 +gr_acl_handle_hidden_file(const struct dentry * dentry,
65423 + const struct vfsmount * mnt)
65424 +{
65425 + __u32 mode;
65426 +
65427 + if (unlikely(!dentry->d_inode))
65428 + return GR_FIND;
65429 +
65430 + mode =
65431 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
65432 +
65433 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
65434 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65435 + return mode;
65436 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
65437 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65438 + return 0;
65439 + } else if (unlikely(!(mode & GR_FIND)))
65440 + return 0;
65441 +
65442 + return GR_FIND;
65443 +}
65444 +
65445 +__u32
65446 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
65447 + int acc_mode)
65448 +{
65449 + __u32 reqmode = GR_FIND;
65450 + __u32 mode;
65451 +
65452 + if (unlikely(!dentry->d_inode))
65453 + return reqmode;
65454 +
65455 + if (acc_mode & MAY_APPEND)
65456 + reqmode |= GR_APPEND;
65457 + else if (acc_mode & MAY_WRITE)
65458 + reqmode |= GR_WRITE;
65459 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
65460 + reqmode |= GR_READ;
65461 +
65462 + mode =
65463 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
65464 + mnt);
65465 +
65466 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65467 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65468 + reqmode & GR_READ ? " reading" : "",
65469 + reqmode & GR_WRITE ? " writing" : reqmode &
65470 + GR_APPEND ? " appending" : "");
65471 + return reqmode;
65472 + } else
65473 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65474 + {
65475 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65476 + reqmode & GR_READ ? " reading" : "",
65477 + reqmode & GR_WRITE ? " writing" : reqmode &
65478 + GR_APPEND ? " appending" : "");
65479 + return 0;
65480 + } else if (unlikely((mode & reqmode) != reqmode))
65481 + return 0;
65482 +
65483 + return reqmode;
65484 +}
65485 +
65486 +__u32
65487 +gr_acl_handle_creat(const struct dentry * dentry,
65488 + const struct dentry * p_dentry,
65489 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
65490 + const int imode)
65491 +{
65492 + __u32 reqmode = GR_WRITE | GR_CREATE;
65493 + __u32 mode;
65494 +
65495 + if (acc_mode & MAY_APPEND)
65496 + reqmode |= GR_APPEND;
65497 + // if a directory was required or the directory already exists, then
65498 + // don't count this open as a read
65499 + if ((acc_mode & MAY_READ) &&
65500 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
65501 + reqmode |= GR_READ;
65502 + if ((open_flags & O_CREAT) &&
65503 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
65504 + reqmode |= GR_SETID;
65505 +
65506 + mode =
65507 + gr_check_create(dentry, p_dentry, p_mnt,
65508 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
65509 +
65510 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65511 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
65512 + reqmode & GR_READ ? " reading" : "",
65513 + reqmode & GR_WRITE ? " writing" : reqmode &
65514 + GR_APPEND ? " appending" : "");
65515 + return reqmode;
65516 + } else
65517 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65518 + {
65519 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
65520 + reqmode & GR_READ ? " reading" : "",
65521 + reqmode & GR_WRITE ? " writing" : reqmode &
65522 + GR_APPEND ? " appending" : "");
65523 + return 0;
65524 + } else if (unlikely((mode & reqmode) != reqmode))
65525 + return 0;
65526 +
65527 + return reqmode;
65528 +}
65529 +
65530 +__u32
65531 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
65532 + const int fmode)
65533 +{
65534 + __u32 mode, reqmode = GR_FIND;
65535 +
65536 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
65537 + reqmode |= GR_EXEC;
65538 + if (fmode & S_IWOTH)
65539 + reqmode |= GR_WRITE;
65540 + if (fmode & S_IROTH)
65541 + reqmode |= GR_READ;
65542 +
65543 + mode =
65544 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
65545 + mnt);
65546 +
65547 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65548 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
65549 + reqmode & GR_READ ? " reading" : "",
65550 + reqmode & GR_WRITE ? " writing" : "",
65551 + reqmode & GR_EXEC ? " executing" : "");
65552 + return reqmode;
65553 + } else
65554 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65555 + {
65556 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
65557 + reqmode & GR_READ ? " reading" : "",
65558 + reqmode & GR_WRITE ? " writing" : "",
65559 + reqmode & GR_EXEC ? " executing" : "");
65560 + return 0;
65561 + } else if (unlikely((mode & reqmode) != reqmode))
65562 + return 0;
65563 +
65564 + return reqmode;
65565 +}
65566 +
65567 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
65568 +{
65569 + __u32 mode;
65570 +
65571 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
65572 +
65573 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
65574 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
65575 + return mode;
65576 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
65577 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
65578 + return 0;
65579 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
65580 + return 0;
65581 +
65582 + return (reqmode);
65583 +}
65584 +
65585 +__u32
65586 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
65587 +{
65588 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
65589 +}
65590 +
65591 +__u32
65592 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
65593 +{
65594 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
65595 +}
65596 +
65597 +__u32
65598 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
65599 +{
65600 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
65601 +}
65602 +
65603 +__u32
65604 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
65605 +{
65606 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
65607 +}
65608 +
65609 +__u32
65610 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
65611 + umode_t *modeptr)
65612 +{
65613 + umode_t mode;
65614 +
65615 + *modeptr &= ~gr_acl_umask();
65616 + mode = *modeptr;
65617 +
65618 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
65619 + return 1;
65620 +
65621 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
65622 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
65623 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
65624 + GR_CHMOD_ACL_MSG);
65625 + } else {
65626 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
65627 + }
65628 +}
65629 +
65630 +__u32
65631 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
65632 +{
65633 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
65634 +}
65635 +
65636 +__u32
65637 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
65638 +{
65639 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
65640 +}
65641 +
65642 +__u32
65643 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
65644 +{
65645 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
65646 +}
65647 +
65648 +__u32
65649 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
65650 +{
65651 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
65652 + GR_UNIXCONNECT_ACL_MSG);
65653 +}
65654 +
65655 +/* hardlinks require at minimum create and link permission,
65656 + any additional privilege required is based on the
65657 + privilege of the file being linked to
65658 +*/
65659 +__u32
65660 +gr_acl_handle_link(const struct dentry * new_dentry,
65661 + const struct dentry * parent_dentry,
65662 + const struct vfsmount * parent_mnt,
65663 + const struct dentry * old_dentry,
65664 + const struct vfsmount * old_mnt, const struct filename *to)
65665 +{
65666 + __u32 mode;
65667 + __u32 needmode = GR_CREATE | GR_LINK;
65668 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
65669 +
65670 + mode =
65671 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
65672 + old_mnt);
65673 +
65674 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
65675 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
65676 + return mode;
65677 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
65678 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
65679 + return 0;
65680 + } else if (unlikely((mode & needmode) != needmode))
65681 + return 0;
65682 +
65683 + return 1;
65684 +}
65685 +
65686 +__u32
65687 +gr_acl_handle_symlink(const struct dentry * new_dentry,
65688 + const struct dentry * parent_dentry,
65689 + const struct vfsmount * parent_mnt, const struct filename *from)
65690 +{
65691 + __u32 needmode = GR_WRITE | GR_CREATE;
65692 + __u32 mode;
65693 +
65694 + mode =
65695 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
65696 + GR_CREATE | GR_AUDIT_CREATE |
65697 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
65698 +
65699 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
65700 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
65701 + return mode;
65702 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
65703 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
65704 + return 0;
65705 + } else if (unlikely((mode & needmode) != needmode))
65706 + return 0;
65707 +
65708 + return (GR_WRITE | GR_CREATE);
65709 +}
65710 +
65711 +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)
65712 +{
65713 + __u32 mode;
65714 +
65715 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
65716 +
65717 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
65718 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
65719 + return mode;
65720 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
65721 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
65722 + return 0;
65723 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
65724 + return 0;
65725 +
65726 + return (reqmode);
65727 +}
65728 +
65729 +__u32
65730 +gr_acl_handle_mknod(const struct dentry * new_dentry,
65731 + const struct dentry * parent_dentry,
65732 + const struct vfsmount * parent_mnt,
65733 + const int mode)
65734 +{
65735 + __u32 reqmode = GR_WRITE | GR_CREATE;
65736 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
65737 + reqmode |= GR_SETID;
65738 +
65739 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
65740 + reqmode, GR_MKNOD_ACL_MSG);
65741 +}
65742 +
65743 +__u32
65744 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
65745 + const struct dentry *parent_dentry,
65746 + const struct vfsmount *parent_mnt)
65747 +{
65748 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
65749 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
65750 +}
65751 +
65752 +#define RENAME_CHECK_SUCCESS(old, new) \
65753 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
65754 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
65755 +
65756 +int
65757 +gr_acl_handle_rename(struct dentry *new_dentry,
65758 + struct dentry *parent_dentry,
65759 + const struct vfsmount *parent_mnt,
65760 + struct dentry *old_dentry,
65761 + struct inode *old_parent_inode,
65762 + struct vfsmount *old_mnt, const struct filename *newname)
65763 +{
65764 + __u32 comp1, comp2;
65765 + int error = 0;
65766 +
65767 + if (unlikely(!gr_acl_is_enabled()))
65768 + return 0;
65769 +
65770 + if (!new_dentry->d_inode) {
65771 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
65772 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
65773 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
65774 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
65775 + GR_DELETE | GR_AUDIT_DELETE |
65776 + GR_AUDIT_READ | GR_AUDIT_WRITE |
65777 + GR_SUPPRESS, old_mnt);
65778 + } else {
65779 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
65780 + GR_CREATE | GR_DELETE |
65781 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
65782 + GR_AUDIT_READ | GR_AUDIT_WRITE |
65783 + GR_SUPPRESS, parent_mnt);
65784 + comp2 =
65785 + gr_search_file(old_dentry,
65786 + GR_READ | GR_WRITE | GR_AUDIT_READ |
65787 + GR_DELETE | GR_AUDIT_DELETE |
65788 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
65789 + }
65790 +
65791 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
65792 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
65793 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
65794 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
65795 + && !(comp2 & GR_SUPPRESS)) {
65796 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
65797 + error = -EACCES;
65798 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
65799 + error = -EACCES;
65800 +
65801 + return error;
65802 +}
65803 +
65804 +void
65805 +gr_acl_handle_exit(void)
65806 +{
65807 + u16 id;
65808 + char *rolename;
65809 +
65810 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
65811 + !(current->role->roletype & GR_ROLE_PERSIST))) {
65812 + id = current->acl_role_id;
65813 + rolename = current->role->rolename;
65814 + gr_set_acls(1);
65815 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
65816 + }
65817 +
65818 + gr_put_exec_file(current);
65819 + return;
65820 +}
65821 +
65822 +int
65823 +gr_acl_handle_procpidmem(const struct task_struct *task)
65824 +{
65825 + if (unlikely(!gr_acl_is_enabled()))
65826 + return 0;
65827 +
65828 + if (task != current && task->acl->mode & GR_PROTPROCFD)
65829 + return -EACCES;
65830 +
65831 + return 0;
65832 +}
65833 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
65834 new file mode 100644
65835 index 0000000..8132048
65836 --- /dev/null
65837 +++ b/grsecurity/gracl_ip.c
65838 @@ -0,0 +1,387 @@
65839 +#include <linux/kernel.h>
65840 +#include <asm/uaccess.h>
65841 +#include <asm/errno.h>
65842 +#include <net/sock.h>
65843 +#include <linux/file.h>
65844 +#include <linux/fs.h>
65845 +#include <linux/net.h>
65846 +#include <linux/in.h>
65847 +#include <linux/skbuff.h>
65848 +#include <linux/ip.h>
65849 +#include <linux/udp.h>
65850 +#include <linux/types.h>
65851 +#include <linux/sched.h>
65852 +#include <linux/netdevice.h>
65853 +#include <linux/inetdevice.h>
65854 +#include <linux/gracl.h>
65855 +#include <linux/grsecurity.h>
65856 +#include <linux/grinternal.h>
65857 +
65858 +#define GR_BIND 0x01
65859 +#define GR_CONNECT 0x02
65860 +#define GR_INVERT 0x04
65861 +#define GR_BINDOVERRIDE 0x08
65862 +#define GR_CONNECTOVERRIDE 0x10
65863 +#define GR_SOCK_FAMILY 0x20
65864 +
65865 +static const char * gr_protocols[IPPROTO_MAX] = {
65866 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
65867 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
65868 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
65869 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
65870 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
65871 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
65872 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
65873 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
65874 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
65875 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
65876 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
65877 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
65878 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
65879 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
65880 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
65881 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
65882 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
65883 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
65884 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
65885 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
65886 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
65887 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
65888 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
65889 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
65890 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
65891 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
65892 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
65893 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
65894 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
65895 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
65896 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
65897 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
65898 + };
65899 +
65900 +static const char * gr_socktypes[SOCK_MAX] = {
65901 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
65902 + "unknown:7", "unknown:8", "unknown:9", "packet"
65903 + };
65904 +
65905 +static const char * gr_sockfamilies[AF_MAX+1] = {
65906 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
65907 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
65908 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
65909 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
65910 + };
65911 +
65912 +const char *
65913 +gr_proto_to_name(unsigned char proto)
65914 +{
65915 + return gr_protocols[proto];
65916 +}
65917 +
65918 +const char *
65919 +gr_socktype_to_name(unsigned char type)
65920 +{
65921 + return gr_socktypes[type];
65922 +}
65923 +
65924 +const char *
65925 +gr_sockfamily_to_name(unsigned char family)
65926 +{
65927 + return gr_sockfamilies[family];
65928 +}
65929 +
65930 +int
65931 +gr_search_socket(const int domain, const int type, const int protocol)
65932 +{
65933 + struct acl_subject_label *curr;
65934 + const struct cred *cred = current_cred();
65935 +
65936 + if (unlikely(!gr_acl_is_enabled()))
65937 + goto exit;
65938 +
65939 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
65940 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
65941 + goto exit; // let the kernel handle it
65942 +
65943 + curr = current->acl;
65944 +
65945 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
65946 + /* the family is allowed, if this is PF_INET allow it only if
65947 + the extra sock type/protocol checks pass */
65948 + if (domain == PF_INET)
65949 + goto inet_check;
65950 + goto exit;
65951 + } else {
65952 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
65953 + __u32 fakeip = 0;
65954 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
65955 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
65956 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
65957 + gr_to_filename(current->exec_file->f_path.dentry,
65958 + current->exec_file->f_path.mnt) :
65959 + curr->filename, curr->filename,
65960 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
65961 + &current->signal->saved_ip);
65962 + goto exit;
65963 + }
65964 + goto exit_fail;
65965 + }
65966 +
65967 +inet_check:
65968 + /* the rest of this checking is for IPv4 only */
65969 + if (!curr->ips)
65970 + goto exit;
65971 +
65972 + if ((curr->ip_type & (1U << type)) &&
65973 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
65974 + goto exit;
65975 +
65976 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
65977 + /* we don't place acls on raw sockets , and sometimes
65978 + dgram/ip sockets are opened for ioctl and not
65979 + bind/connect, so we'll fake a bind learn log */
65980 + if (type == SOCK_RAW || type == SOCK_PACKET) {
65981 + __u32 fakeip = 0;
65982 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
65983 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
65984 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
65985 + gr_to_filename(current->exec_file->f_path.dentry,
65986 + current->exec_file->f_path.mnt) :
65987 + curr->filename, curr->filename,
65988 + &fakeip, 0, type,
65989 + protocol, GR_CONNECT, &current->signal->saved_ip);
65990 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
65991 + __u32 fakeip = 0;
65992 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
65993 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
65994 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
65995 + gr_to_filename(current->exec_file->f_path.dentry,
65996 + current->exec_file->f_path.mnt) :
65997 + curr->filename, curr->filename,
65998 + &fakeip, 0, type,
65999 + protocol, GR_BIND, &current->signal->saved_ip);
66000 + }
66001 + /* we'll log when they use connect or bind */
66002 + goto exit;
66003 + }
66004 +
66005 +exit_fail:
66006 + if (domain == PF_INET)
66007 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
66008 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
66009 + else
66010 +#ifndef CONFIG_IPV6
66011 + if (domain != PF_INET6)
66012 +#endif
66013 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
66014 + gr_socktype_to_name(type), protocol);
66015 +
66016 + return 0;
66017 +exit:
66018 + return 1;
66019 +}
66020 +
66021 +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)
66022 +{
66023 + if ((ip->mode & mode) &&
66024 + (ip_port >= ip->low) &&
66025 + (ip_port <= ip->high) &&
66026 + ((ntohl(ip_addr) & our_netmask) ==
66027 + (ntohl(our_addr) & our_netmask))
66028 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
66029 + && (ip->type & (1U << type))) {
66030 + if (ip->mode & GR_INVERT)
66031 + return 2; // specifically denied
66032 + else
66033 + return 1; // allowed
66034 + }
66035 +
66036 + return 0; // not specifically allowed, may continue parsing
66037 +}
66038 +
66039 +static int
66040 +gr_search_connectbind(const int full_mode, struct sock *sk,
66041 + struct sockaddr_in *addr, const int type)
66042 +{
66043 + char iface[IFNAMSIZ] = {0};
66044 + struct acl_subject_label *curr;
66045 + struct acl_ip_label *ip;
66046 + struct inet_sock *isk;
66047 + struct net_device *dev;
66048 + struct in_device *idev;
66049 + unsigned long i;
66050 + int ret;
66051 + int mode = full_mode & (GR_BIND | GR_CONNECT);
66052 + __u32 ip_addr = 0;
66053 + __u32 our_addr;
66054 + __u32 our_netmask;
66055 + char *p;
66056 + __u16 ip_port = 0;
66057 + const struct cred *cred = current_cred();
66058 +
66059 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
66060 + return 0;
66061 +
66062 + curr = current->acl;
66063 + isk = inet_sk(sk);
66064 +
66065 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
66066 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
66067 + addr->sin_addr.s_addr = curr->inaddr_any_override;
66068 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
66069 + struct sockaddr_in saddr;
66070 + int err;
66071 +
66072 + saddr.sin_family = AF_INET;
66073 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
66074 + saddr.sin_port = isk->inet_sport;
66075 +
66076 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66077 + if (err)
66078 + return err;
66079 +
66080 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66081 + if (err)
66082 + return err;
66083 + }
66084 +
66085 + if (!curr->ips)
66086 + return 0;
66087 +
66088 + ip_addr = addr->sin_addr.s_addr;
66089 + ip_port = ntohs(addr->sin_port);
66090 +
66091 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66092 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66093 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66094 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66095 + gr_to_filename(current->exec_file->f_path.dentry,
66096 + current->exec_file->f_path.mnt) :
66097 + curr->filename, curr->filename,
66098 + &ip_addr, ip_port, type,
66099 + sk->sk_protocol, mode, &current->signal->saved_ip);
66100 + return 0;
66101 + }
66102 +
66103 + for (i = 0; i < curr->ip_num; i++) {
66104 + ip = *(curr->ips + i);
66105 + if (ip->iface != NULL) {
66106 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
66107 + p = strchr(iface, ':');
66108 + if (p != NULL)
66109 + *p = '\0';
66110 + dev = dev_get_by_name(sock_net(sk), iface);
66111 + if (dev == NULL)
66112 + continue;
66113 + idev = in_dev_get(dev);
66114 + if (idev == NULL) {
66115 + dev_put(dev);
66116 + continue;
66117 + }
66118 + rcu_read_lock();
66119 + for_ifa(idev) {
66120 + if (!strcmp(ip->iface, ifa->ifa_label)) {
66121 + our_addr = ifa->ifa_address;
66122 + our_netmask = 0xffffffff;
66123 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66124 + if (ret == 1) {
66125 + rcu_read_unlock();
66126 + in_dev_put(idev);
66127 + dev_put(dev);
66128 + return 0;
66129 + } else if (ret == 2) {
66130 + rcu_read_unlock();
66131 + in_dev_put(idev);
66132 + dev_put(dev);
66133 + goto denied;
66134 + }
66135 + }
66136 + } endfor_ifa(idev);
66137 + rcu_read_unlock();
66138 + in_dev_put(idev);
66139 + dev_put(dev);
66140 + } else {
66141 + our_addr = ip->addr;
66142 + our_netmask = ip->netmask;
66143 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66144 + if (ret == 1)
66145 + return 0;
66146 + else if (ret == 2)
66147 + goto denied;
66148 + }
66149 + }
66150 +
66151 +denied:
66152 + if (mode == GR_BIND)
66153 + 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));
66154 + else if (mode == GR_CONNECT)
66155 + 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));
66156 +
66157 + return -EACCES;
66158 +}
66159 +
66160 +int
66161 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
66162 +{
66163 + /* always allow disconnection of dgram sockets with connect */
66164 + if (addr->sin_family == AF_UNSPEC)
66165 + return 0;
66166 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
66167 +}
66168 +
66169 +int
66170 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
66171 +{
66172 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
66173 +}
66174 +
66175 +int gr_search_listen(struct socket *sock)
66176 +{
66177 + struct sock *sk = sock->sk;
66178 + struct sockaddr_in addr;
66179 +
66180 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66181 + addr.sin_port = inet_sk(sk)->inet_sport;
66182 +
66183 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66184 +}
66185 +
66186 +int gr_search_accept(struct socket *sock)
66187 +{
66188 + struct sock *sk = sock->sk;
66189 + struct sockaddr_in addr;
66190 +
66191 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66192 + addr.sin_port = inet_sk(sk)->inet_sport;
66193 +
66194 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66195 +}
66196 +
66197 +int
66198 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
66199 +{
66200 + if (addr)
66201 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
66202 + else {
66203 + struct sockaddr_in sin;
66204 + const struct inet_sock *inet = inet_sk(sk);
66205 +
66206 + sin.sin_addr.s_addr = inet->inet_daddr;
66207 + sin.sin_port = inet->inet_dport;
66208 +
66209 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66210 + }
66211 +}
66212 +
66213 +int
66214 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
66215 +{
66216 + struct sockaddr_in sin;
66217 +
66218 + if (unlikely(skb->len < sizeof (struct udphdr)))
66219 + return 0; // skip this packet
66220 +
66221 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
66222 + sin.sin_port = udp_hdr(skb)->source;
66223 +
66224 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66225 +}
66226 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
66227 new file mode 100644
66228 index 0000000..25f54ef
66229 --- /dev/null
66230 +++ b/grsecurity/gracl_learn.c
66231 @@ -0,0 +1,207 @@
66232 +#include <linux/kernel.h>
66233 +#include <linux/mm.h>
66234 +#include <linux/sched.h>
66235 +#include <linux/poll.h>
66236 +#include <linux/string.h>
66237 +#include <linux/file.h>
66238 +#include <linux/types.h>
66239 +#include <linux/vmalloc.h>
66240 +#include <linux/grinternal.h>
66241 +
66242 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
66243 + size_t count, loff_t *ppos);
66244 +extern int gr_acl_is_enabled(void);
66245 +
66246 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
66247 +static int gr_learn_attached;
66248 +
66249 +/* use a 512k buffer */
66250 +#define LEARN_BUFFER_SIZE (512 * 1024)
66251 +
66252 +static DEFINE_SPINLOCK(gr_learn_lock);
66253 +static DEFINE_MUTEX(gr_learn_user_mutex);
66254 +
66255 +/* we need to maintain two buffers, so that the kernel context of grlearn
66256 + uses a semaphore around the userspace copying, and the other kernel contexts
66257 + use a spinlock when copying into the buffer, since they cannot sleep
66258 +*/
66259 +static char *learn_buffer;
66260 +static char *learn_buffer_user;
66261 +static int learn_buffer_len;
66262 +static int learn_buffer_user_len;
66263 +
66264 +static ssize_t
66265 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
66266 +{
66267 + DECLARE_WAITQUEUE(wait, current);
66268 + ssize_t retval = 0;
66269 +
66270 + add_wait_queue(&learn_wait, &wait);
66271 + set_current_state(TASK_INTERRUPTIBLE);
66272 + do {
66273 + mutex_lock(&gr_learn_user_mutex);
66274 + spin_lock(&gr_learn_lock);
66275 + if (learn_buffer_len)
66276 + break;
66277 + spin_unlock(&gr_learn_lock);
66278 + mutex_unlock(&gr_learn_user_mutex);
66279 + if (file->f_flags & O_NONBLOCK) {
66280 + retval = -EAGAIN;
66281 + goto out;
66282 + }
66283 + if (signal_pending(current)) {
66284 + retval = -ERESTARTSYS;
66285 + goto out;
66286 + }
66287 +
66288 + schedule();
66289 + } while (1);
66290 +
66291 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
66292 + learn_buffer_user_len = learn_buffer_len;
66293 + retval = learn_buffer_len;
66294 + learn_buffer_len = 0;
66295 +
66296 + spin_unlock(&gr_learn_lock);
66297 +
66298 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
66299 + retval = -EFAULT;
66300 +
66301 + mutex_unlock(&gr_learn_user_mutex);
66302 +out:
66303 + set_current_state(TASK_RUNNING);
66304 + remove_wait_queue(&learn_wait, &wait);
66305 + return retval;
66306 +}
66307 +
66308 +static unsigned int
66309 +poll_learn(struct file * file, poll_table * wait)
66310 +{
66311 + poll_wait(file, &learn_wait, wait);
66312 +
66313 + if (learn_buffer_len)
66314 + return (POLLIN | POLLRDNORM);
66315 +
66316 + return 0;
66317 +}
66318 +
66319 +void
66320 +gr_clear_learn_entries(void)
66321 +{
66322 + char *tmp;
66323 +
66324 + mutex_lock(&gr_learn_user_mutex);
66325 + spin_lock(&gr_learn_lock);
66326 + tmp = learn_buffer;
66327 + learn_buffer = NULL;
66328 + spin_unlock(&gr_learn_lock);
66329 + if (tmp)
66330 + vfree(tmp);
66331 + if (learn_buffer_user != NULL) {
66332 + vfree(learn_buffer_user);
66333 + learn_buffer_user = NULL;
66334 + }
66335 + learn_buffer_len = 0;
66336 + mutex_unlock(&gr_learn_user_mutex);
66337 +
66338 + return;
66339 +}
66340 +
66341 +void
66342 +gr_add_learn_entry(const char *fmt, ...)
66343 +{
66344 + va_list args;
66345 + unsigned int len;
66346 +
66347 + if (!gr_learn_attached)
66348 + return;
66349 +
66350 + spin_lock(&gr_learn_lock);
66351 +
66352 + /* leave a gap at the end so we know when it's "full" but don't have to
66353 + compute the exact length of the string we're trying to append
66354 + */
66355 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
66356 + spin_unlock(&gr_learn_lock);
66357 + wake_up_interruptible(&learn_wait);
66358 + return;
66359 + }
66360 + if (learn_buffer == NULL) {
66361 + spin_unlock(&gr_learn_lock);
66362 + return;
66363 + }
66364 +
66365 + va_start(args, fmt);
66366 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
66367 + va_end(args);
66368 +
66369 + learn_buffer_len += len + 1;
66370 +
66371 + spin_unlock(&gr_learn_lock);
66372 + wake_up_interruptible(&learn_wait);
66373 +
66374 + return;
66375 +}
66376 +
66377 +static int
66378 +open_learn(struct inode *inode, struct file *file)
66379 +{
66380 + if (file->f_mode & FMODE_READ && gr_learn_attached)
66381 + return -EBUSY;
66382 + if (file->f_mode & FMODE_READ) {
66383 + int retval = 0;
66384 + mutex_lock(&gr_learn_user_mutex);
66385 + if (learn_buffer == NULL)
66386 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
66387 + if (learn_buffer_user == NULL)
66388 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
66389 + if (learn_buffer == NULL) {
66390 + retval = -ENOMEM;
66391 + goto out_error;
66392 + }
66393 + if (learn_buffer_user == NULL) {
66394 + retval = -ENOMEM;
66395 + goto out_error;
66396 + }
66397 + learn_buffer_len = 0;
66398 + learn_buffer_user_len = 0;
66399 + gr_learn_attached = 1;
66400 +out_error:
66401 + mutex_unlock(&gr_learn_user_mutex);
66402 + return retval;
66403 + }
66404 + return 0;
66405 +}
66406 +
66407 +static int
66408 +close_learn(struct inode *inode, struct file *file)
66409 +{
66410 + if (file->f_mode & FMODE_READ) {
66411 + char *tmp = NULL;
66412 + mutex_lock(&gr_learn_user_mutex);
66413 + spin_lock(&gr_learn_lock);
66414 + tmp = learn_buffer;
66415 + learn_buffer = NULL;
66416 + spin_unlock(&gr_learn_lock);
66417 + if (tmp)
66418 + vfree(tmp);
66419 + if (learn_buffer_user != NULL) {
66420 + vfree(learn_buffer_user);
66421 + learn_buffer_user = NULL;
66422 + }
66423 + learn_buffer_len = 0;
66424 + learn_buffer_user_len = 0;
66425 + gr_learn_attached = 0;
66426 + mutex_unlock(&gr_learn_user_mutex);
66427 + }
66428 +
66429 + return 0;
66430 +}
66431 +
66432 +const struct file_operations grsec_fops = {
66433 + .read = read_learn,
66434 + .write = write_grsec_handler,
66435 + .open = open_learn,
66436 + .release = close_learn,
66437 + .poll = poll_learn,
66438 +};
66439 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
66440 new file mode 100644
66441 index 0000000..39645c9
66442 --- /dev/null
66443 +++ b/grsecurity/gracl_res.c
66444 @@ -0,0 +1,68 @@
66445 +#include <linux/kernel.h>
66446 +#include <linux/sched.h>
66447 +#include <linux/gracl.h>
66448 +#include <linux/grinternal.h>
66449 +
66450 +static const char *restab_log[] = {
66451 + [RLIMIT_CPU] = "RLIMIT_CPU",
66452 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
66453 + [RLIMIT_DATA] = "RLIMIT_DATA",
66454 + [RLIMIT_STACK] = "RLIMIT_STACK",
66455 + [RLIMIT_CORE] = "RLIMIT_CORE",
66456 + [RLIMIT_RSS] = "RLIMIT_RSS",
66457 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
66458 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
66459 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
66460 + [RLIMIT_AS] = "RLIMIT_AS",
66461 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
66462 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
66463 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
66464 + [RLIMIT_NICE] = "RLIMIT_NICE",
66465 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
66466 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
66467 + [GR_CRASH_RES] = "RLIMIT_CRASH"
66468 +};
66469 +
66470 +void
66471 +gr_log_resource(const struct task_struct *task,
66472 + const int res, const unsigned long wanted, const int gt)
66473 +{
66474 + const struct cred *cred;
66475 + unsigned long rlim;
66476 +
66477 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
66478 + return;
66479 +
66480 + // not yet supported resource
66481 + if (unlikely(!restab_log[res]))
66482 + return;
66483 +
66484 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
66485 + rlim = task_rlimit_max(task, res);
66486 + else
66487 + rlim = task_rlimit(task, res);
66488 +
66489 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
66490 + return;
66491 +
66492 + rcu_read_lock();
66493 + cred = __task_cred(task);
66494 +
66495 + if (res == RLIMIT_NPROC &&
66496 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
66497 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
66498 + goto out_rcu_unlock;
66499 + else if (res == RLIMIT_MEMLOCK &&
66500 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
66501 + goto out_rcu_unlock;
66502 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
66503 + goto out_rcu_unlock;
66504 + rcu_read_unlock();
66505 +
66506 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
66507 +
66508 + return;
66509 +out_rcu_unlock:
66510 + rcu_read_unlock();
66511 + return;
66512 +}
66513 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
66514 new file mode 100644
66515 index 0000000..3c38bfe
66516 --- /dev/null
66517 +++ b/grsecurity/gracl_segv.c
66518 @@ -0,0 +1,305 @@
66519 +#include <linux/kernel.h>
66520 +#include <linux/mm.h>
66521 +#include <asm/uaccess.h>
66522 +#include <asm/errno.h>
66523 +#include <asm/mman.h>
66524 +#include <net/sock.h>
66525 +#include <linux/file.h>
66526 +#include <linux/fs.h>
66527 +#include <linux/net.h>
66528 +#include <linux/in.h>
66529 +#include <linux/slab.h>
66530 +#include <linux/types.h>
66531 +#include <linux/sched.h>
66532 +#include <linux/timer.h>
66533 +#include <linux/gracl.h>
66534 +#include <linux/grsecurity.h>
66535 +#include <linux/grinternal.h>
66536 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
66537 +#include <linux/magic.h>
66538 +#include <linux/pagemap.h>
66539 +#include "../fs/btrfs/async-thread.h"
66540 +#include "../fs/btrfs/ctree.h"
66541 +#include "../fs/btrfs/btrfs_inode.h"
66542 +#endif
66543 +
66544 +static struct crash_uid *uid_set;
66545 +static unsigned short uid_used;
66546 +static DEFINE_SPINLOCK(gr_uid_lock);
66547 +extern rwlock_t gr_inode_lock;
66548 +extern struct acl_subject_label *
66549 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
66550 + struct acl_role_label *role);
66551 +
66552 +static inline dev_t __get_dev(const struct dentry *dentry)
66553 +{
66554 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
66555 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
66556 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
66557 + else
66558 +#endif
66559 + return dentry->d_sb->s_dev;
66560 +}
66561 +
66562 +int
66563 +gr_init_uidset(void)
66564 +{
66565 + uid_set =
66566 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
66567 + uid_used = 0;
66568 +
66569 + return uid_set ? 1 : 0;
66570 +}
66571 +
66572 +void
66573 +gr_free_uidset(void)
66574 +{
66575 + if (uid_set)
66576 + kfree(uid_set);
66577 +
66578 + return;
66579 +}
66580 +
66581 +int
66582 +gr_find_uid(const uid_t uid)
66583 +{
66584 + struct crash_uid *tmp = uid_set;
66585 + uid_t buid;
66586 + int low = 0, high = uid_used - 1, mid;
66587 +
66588 + while (high >= low) {
66589 + mid = (low + high) >> 1;
66590 + buid = tmp[mid].uid;
66591 + if (buid == uid)
66592 + return mid;
66593 + if (buid > uid)
66594 + high = mid - 1;
66595 + if (buid < uid)
66596 + low = mid + 1;
66597 + }
66598 +
66599 + return -1;
66600 +}
66601 +
66602 +static __inline__ void
66603 +gr_insertsort(void)
66604 +{
66605 + unsigned short i, j;
66606 + struct crash_uid index;
66607 +
66608 + for (i = 1; i < uid_used; i++) {
66609 + index = uid_set[i];
66610 + j = i;
66611 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
66612 + uid_set[j] = uid_set[j - 1];
66613 + j--;
66614 + }
66615 + uid_set[j] = index;
66616 + }
66617 +
66618 + return;
66619 +}
66620 +
66621 +static __inline__ void
66622 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
66623 +{
66624 + int loc;
66625 + uid_t uid = GR_GLOBAL_UID(kuid);
66626 +
66627 + if (uid_used == GR_UIDTABLE_MAX)
66628 + return;
66629 +
66630 + loc = gr_find_uid(uid);
66631 +
66632 + if (loc >= 0) {
66633 + uid_set[loc].expires = expires;
66634 + return;
66635 + }
66636 +
66637 + uid_set[uid_used].uid = uid;
66638 + uid_set[uid_used].expires = expires;
66639 + uid_used++;
66640 +
66641 + gr_insertsort();
66642 +
66643 + return;
66644 +}
66645 +
66646 +void
66647 +gr_remove_uid(const unsigned short loc)
66648 +{
66649 + unsigned short i;
66650 +
66651 + for (i = loc + 1; i < uid_used; i++)
66652 + uid_set[i - 1] = uid_set[i];
66653 +
66654 + uid_used--;
66655 +
66656 + return;
66657 +}
66658 +
66659 +int
66660 +gr_check_crash_uid(const kuid_t kuid)
66661 +{
66662 + int loc;
66663 + int ret = 0;
66664 + uid_t uid;
66665 +
66666 + if (unlikely(!gr_acl_is_enabled()))
66667 + return 0;
66668 +
66669 + uid = GR_GLOBAL_UID(kuid);
66670 +
66671 + spin_lock(&gr_uid_lock);
66672 + loc = gr_find_uid(uid);
66673 +
66674 + if (loc < 0)
66675 + goto out_unlock;
66676 +
66677 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
66678 + gr_remove_uid(loc);
66679 + else
66680 + ret = 1;
66681 +
66682 +out_unlock:
66683 + spin_unlock(&gr_uid_lock);
66684 + return ret;
66685 +}
66686 +
66687 +static __inline__ int
66688 +proc_is_setxid(const struct cred *cred)
66689 +{
66690 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
66691 + !uid_eq(cred->uid, cred->fsuid))
66692 + return 1;
66693 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
66694 + !gid_eq(cred->gid, cred->fsgid))
66695 + return 1;
66696 +
66697 + return 0;
66698 +}
66699 +
66700 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
66701 +
66702 +void
66703 +gr_handle_crash(struct task_struct *task, const int sig)
66704 +{
66705 + struct acl_subject_label *curr;
66706 + struct task_struct *tsk, *tsk2;
66707 + const struct cred *cred;
66708 + const struct cred *cred2;
66709 +
66710 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
66711 + return;
66712 +
66713 + if (unlikely(!gr_acl_is_enabled()))
66714 + return;
66715 +
66716 + curr = task->acl;
66717 +
66718 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
66719 + return;
66720 +
66721 + if (time_before_eq(curr->expires, get_seconds())) {
66722 + curr->expires = 0;
66723 + curr->crashes = 0;
66724 + }
66725 +
66726 + curr->crashes++;
66727 +
66728 + if (!curr->expires)
66729 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
66730 +
66731 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
66732 + time_after(curr->expires, get_seconds())) {
66733 + rcu_read_lock();
66734 + cred = __task_cred(task);
66735 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
66736 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
66737 + spin_lock(&gr_uid_lock);
66738 + gr_insert_uid(cred->uid, curr->expires);
66739 + spin_unlock(&gr_uid_lock);
66740 + curr->expires = 0;
66741 + curr->crashes = 0;
66742 + read_lock(&tasklist_lock);
66743 + do_each_thread(tsk2, tsk) {
66744 + cred2 = __task_cred(tsk);
66745 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
66746 + gr_fake_force_sig(SIGKILL, tsk);
66747 + } while_each_thread(tsk2, tsk);
66748 + read_unlock(&tasklist_lock);
66749 + } else {
66750 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
66751 + read_lock(&tasklist_lock);
66752 + read_lock(&grsec_exec_file_lock);
66753 + do_each_thread(tsk2, tsk) {
66754 + if (likely(tsk != task)) {
66755 + // if this thread has the same subject as the one that triggered
66756 + // RES_CRASH and it's the same binary, kill it
66757 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
66758 + gr_fake_force_sig(SIGKILL, tsk);
66759 + }
66760 + } while_each_thread(tsk2, tsk);
66761 + read_unlock(&grsec_exec_file_lock);
66762 + read_unlock(&tasklist_lock);
66763 + }
66764 + rcu_read_unlock();
66765 + }
66766 +
66767 + return;
66768 +}
66769 +
66770 +int
66771 +gr_check_crash_exec(const struct file *filp)
66772 +{
66773 + struct acl_subject_label *curr;
66774 +
66775 + if (unlikely(!gr_acl_is_enabled()))
66776 + return 0;
66777 +
66778 + read_lock(&gr_inode_lock);
66779 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
66780 + __get_dev(filp->f_path.dentry),
66781 + current->role);
66782 + read_unlock(&gr_inode_lock);
66783 +
66784 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
66785 + (!curr->crashes && !curr->expires))
66786 + return 0;
66787 +
66788 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
66789 + time_after(curr->expires, get_seconds()))
66790 + return 1;
66791 + else if (time_before_eq(curr->expires, get_seconds())) {
66792 + curr->crashes = 0;
66793 + curr->expires = 0;
66794 + }
66795 +
66796 + return 0;
66797 +}
66798 +
66799 +void
66800 +gr_handle_alertkill(struct task_struct *task)
66801 +{
66802 + struct acl_subject_label *curracl;
66803 + __u32 curr_ip;
66804 + struct task_struct *p, *p2;
66805 +
66806 + if (unlikely(!gr_acl_is_enabled()))
66807 + return;
66808 +
66809 + curracl = task->acl;
66810 + curr_ip = task->signal->curr_ip;
66811 +
66812 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
66813 + read_lock(&tasklist_lock);
66814 + do_each_thread(p2, p) {
66815 + if (p->signal->curr_ip == curr_ip)
66816 + gr_fake_force_sig(SIGKILL, p);
66817 + } while_each_thread(p2, p);
66818 + read_unlock(&tasklist_lock);
66819 + } else if (curracl->mode & GR_KILLPROC)
66820 + gr_fake_force_sig(SIGKILL, task);
66821 +
66822 + return;
66823 +}
66824 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
66825 new file mode 100644
66826 index 0000000..98011b0
66827 --- /dev/null
66828 +++ b/grsecurity/gracl_shm.c
66829 @@ -0,0 +1,40 @@
66830 +#include <linux/kernel.h>
66831 +#include <linux/mm.h>
66832 +#include <linux/sched.h>
66833 +#include <linux/file.h>
66834 +#include <linux/ipc.h>
66835 +#include <linux/gracl.h>
66836 +#include <linux/grsecurity.h>
66837 +#include <linux/grinternal.h>
66838 +
66839 +int
66840 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
66841 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
66842 +{
66843 + struct task_struct *task;
66844 +
66845 + if (!gr_acl_is_enabled())
66846 + return 1;
66847 +
66848 + rcu_read_lock();
66849 + read_lock(&tasklist_lock);
66850 +
66851 + task = find_task_by_vpid(shm_cprid);
66852 +
66853 + if (unlikely(!task))
66854 + task = find_task_by_vpid(shm_lapid);
66855 +
66856 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
66857 + (task_pid_nr(task) == shm_lapid)) &&
66858 + (task->acl->mode & GR_PROTSHM) &&
66859 + (task->acl != current->acl))) {
66860 + read_unlock(&tasklist_lock);
66861 + rcu_read_unlock();
66862 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
66863 + return 0;
66864 + }
66865 + read_unlock(&tasklist_lock);
66866 + rcu_read_unlock();
66867 +
66868 + return 1;
66869 +}
66870 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
66871 new file mode 100644
66872 index 0000000..bc0be01
66873 --- /dev/null
66874 +++ b/grsecurity/grsec_chdir.c
66875 @@ -0,0 +1,19 @@
66876 +#include <linux/kernel.h>
66877 +#include <linux/sched.h>
66878 +#include <linux/fs.h>
66879 +#include <linux/file.h>
66880 +#include <linux/grsecurity.h>
66881 +#include <linux/grinternal.h>
66882 +
66883 +void
66884 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
66885 +{
66886 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66887 + if ((grsec_enable_chdir && grsec_enable_group &&
66888 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
66889 + !grsec_enable_group)) {
66890 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
66891 + }
66892 +#endif
66893 + return;
66894 +}
66895 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
66896 new file mode 100644
66897 index 0000000..bd6e105
66898 --- /dev/null
66899 +++ b/grsecurity/grsec_chroot.c
66900 @@ -0,0 +1,370 @@
66901 +#include <linux/kernel.h>
66902 +#include <linux/module.h>
66903 +#include <linux/sched.h>
66904 +#include <linux/file.h>
66905 +#include <linux/fs.h>
66906 +#include <linux/mount.h>
66907 +#include <linux/types.h>
66908 +#include "../fs/mount.h"
66909 +#include <linux/grsecurity.h>
66910 +#include <linux/grinternal.h>
66911 +
66912 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
66913 +static int gr_init_ran;
66914 +#endif
66915 +
66916 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
66917 +{
66918 +#ifdef CONFIG_GRKERNSEC
66919 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
66920 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
66921 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
66922 + && gr_init_ran
66923 +#endif
66924 + )
66925 + task->gr_is_chrooted = 1;
66926 + else {
66927 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
66928 + if (task_pid_nr(task) == 1 && !gr_init_ran)
66929 + gr_init_ran = 1;
66930 +#endif
66931 + task->gr_is_chrooted = 0;
66932 + }
66933 +
66934 + task->gr_chroot_dentry = path->dentry;
66935 +#endif
66936 + return;
66937 +}
66938 +
66939 +void gr_clear_chroot_entries(struct task_struct *task)
66940 +{
66941 +#ifdef CONFIG_GRKERNSEC
66942 + task->gr_is_chrooted = 0;
66943 + task->gr_chroot_dentry = NULL;
66944 +#endif
66945 + return;
66946 +}
66947 +
66948 +int
66949 +gr_handle_chroot_unix(const pid_t pid)
66950 +{
66951 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66952 + struct task_struct *p;
66953 +
66954 + if (unlikely(!grsec_enable_chroot_unix))
66955 + return 1;
66956 +
66957 + if (likely(!proc_is_chrooted(current)))
66958 + return 1;
66959 +
66960 + rcu_read_lock();
66961 + read_lock(&tasklist_lock);
66962 + p = find_task_by_vpid_unrestricted(pid);
66963 + if (unlikely(p && !have_same_root(current, p))) {
66964 + read_unlock(&tasklist_lock);
66965 + rcu_read_unlock();
66966 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
66967 + return 0;
66968 + }
66969 + read_unlock(&tasklist_lock);
66970 + rcu_read_unlock();
66971 +#endif
66972 + return 1;
66973 +}
66974 +
66975 +int
66976 +gr_handle_chroot_nice(void)
66977 +{
66978 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66979 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
66980 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
66981 + return -EPERM;
66982 + }
66983 +#endif
66984 + return 0;
66985 +}
66986 +
66987 +int
66988 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
66989 +{
66990 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66991 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
66992 + && proc_is_chrooted(current)) {
66993 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
66994 + return -EACCES;
66995 + }
66996 +#endif
66997 + return 0;
66998 +}
66999 +
67000 +int
67001 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
67002 +{
67003 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
67004 + struct task_struct *p;
67005 + int ret = 0;
67006 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
67007 + return ret;
67008 +
67009 + read_lock(&tasklist_lock);
67010 + do_each_pid_task(pid, type, p) {
67011 + if (!have_same_root(current, p)) {
67012 + ret = 1;
67013 + goto out;
67014 + }
67015 + } while_each_pid_task(pid, type, p);
67016 +out:
67017 + read_unlock(&tasklist_lock);
67018 + return ret;
67019 +#endif
67020 + return 0;
67021 +}
67022 +
67023 +int
67024 +gr_pid_is_chrooted(struct task_struct *p)
67025 +{
67026 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
67027 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
67028 + return 0;
67029 +
67030 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
67031 + !have_same_root(current, p)) {
67032 + return 1;
67033 + }
67034 +#endif
67035 + return 0;
67036 +}
67037 +
67038 +EXPORT_SYMBOL(gr_pid_is_chrooted);
67039 +
67040 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
67041 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
67042 +{
67043 + struct path path, currentroot;
67044 + int ret = 0;
67045 +
67046 + path.dentry = (struct dentry *)u_dentry;
67047 + path.mnt = (struct vfsmount *)u_mnt;
67048 + get_fs_root(current->fs, &currentroot);
67049 + if (path_is_under(&path, &currentroot))
67050 + ret = 1;
67051 + path_put(&currentroot);
67052 +
67053 + return ret;
67054 +}
67055 +#endif
67056 +
67057 +int
67058 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
67059 +{
67060 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
67061 + if (!grsec_enable_chroot_fchdir)
67062 + return 1;
67063 +
67064 + if (!proc_is_chrooted(current))
67065 + return 1;
67066 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
67067 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
67068 + return 0;
67069 + }
67070 +#endif
67071 + return 1;
67072 +}
67073 +
67074 +int
67075 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
67076 + const time_t shm_createtime)
67077 +{
67078 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
67079 + struct task_struct *p;
67080 + time_t starttime;
67081 +
67082 + if (unlikely(!grsec_enable_chroot_shmat))
67083 + return 1;
67084 +
67085 + if (likely(!proc_is_chrooted(current)))
67086 + return 1;
67087 +
67088 + rcu_read_lock();
67089 + read_lock(&tasklist_lock);
67090 +
67091 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
67092 + starttime = p->start_time.tv_sec;
67093 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
67094 + if (have_same_root(current, p)) {
67095 + goto allow;
67096 + } else {
67097 + read_unlock(&tasklist_lock);
67098 + rcu_read_unlock();
67099 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
67100 + return 0;
67101 + }
67102 + }
67103 + /* creator exited, pid reuse, fall through to next check */
67104 + }
67105 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
67106 + if (unlikely(!have_same_root(current, p))) {
67107 + read_unlock(&tasklist_lock);
67108 + rcu_read_unlock();
67109 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
67110 + return 0;
67111 + }
67112 + }
67113 +
67114 +allow:
67115 + read_unlock(&tasklist_lock);
67116 + rcu_read_unlock();
67117 +#endif
67118 + return 1;
67119 +}
67120 +
67121 +void
67122 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
67123 +{
67124 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
67125 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
67126 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
67127 +#endif
67128 + return;
67129 +}
67130 +
67131 +int
67132 +gr_handle_chroot_mknod(const struct dentry *dentry,
67133 + const struct vfsmount *mnt, const int mode)
67134 +{
67135 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
67136 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
67137 + proc_is_chrooted(current)) {
67138 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
67139 + return -EPERM;
67140 + }
67141 +#endif
67142 + return 0;
67143 +}
67144 +
67145 +int
67146 +gr_handle_chroot_mount(const struct dentry *dentry,
67147 + const struct vfsmount *mnt, const char *dev_name)
67148 +{
67149 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
67150 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
67151 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
67152 + return -EPERM;
67153 + }
67154 +#endif
67155 + return 0;
67156 +}
67157 +
67158 +int
67159 +gr_handle_chroot_pivot(void)
67160 +{
67161 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
67162 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
67163 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
67164 + return -EPERM;
67165 + }
67166 +#endif
67167 + return 0;
67168 +}
67169 +
67170 +int
67171 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
67172 +{
67173 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
67174 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
67175 + !gr_is_outside_chroot(dentry, mnt)) {
67176 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
67177 + return -EPERM;
67178 + }
67179 +#endif
67180 + return 0;
67181 +}
67182 +
67183 +extern const char *captab_log[];
67184 +extern int captab_log_entries;
67185 +
67186 +int
67187 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
67188 +{
67189 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
67190 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
67191 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
67192 + if (cap_raised(chroot_caps, cap)) {
67193 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
67194 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
67195 + }
67196 + return 0;
67197 + }
67198 + }
67199 +#endif
67200 + return 1;
67201 +}
67202 +
67203 +int
67204 +gr_chroot_is_capable(const int cap)
67205 +{
67206 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
67207 + return gr_task_chroot_is_capable(current, current_cred(), cap);
67208 +#endif
67209 + return 1;
67210 +}
67211 +
67212 +int
67213 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
67214 +{
67215 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
67216 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
67217 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
67218 + if (cap_raised(chroot_caps, cap)) {
67219 + return 0;
67220 + }
67221 + }
67222 +#endif
67223 + return 1;
67224 +}
67225 +
67226 +int
67227 +gr_chroot_is_capable_nolog(const int cap)
67228 +{
67229 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
67230 + return gr_task_chroot_is_capable_nolog(current, cap);
67231 +#endif
67232 + return 1;
67233 +}
67234 +
67235 +int
67236 +gr_handle_chroot_sysctl(const int op)
67237 +{
67238 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
67239 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
67240 + proc_is_chrooted(current))
67241 + return -EACCES;
67242 +#endif
67243 + return 0;
67244 +}
67245 +
67246 +void
67247 +gr_handle_chroot_chdir(const struct path *path)
67248 +{
67249 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
67250 + if (grsec_enable_chroot_chdir)
67251 + set_fs_pwd(current->fs, path);
67252 +#endif
67253 + return;
67254 +}
67255 +
67256 +int
67257 +gr_handle_chroot_chmod(const struct dentry *dentry,
67258 + const struct vfsmount *mnt, const int mode)
67259 +{
67260 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
67261 + /* allow chmod +s on directories, but not files */
67262 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
67263 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
67264 + proc_is_chrooted(current)) {
67265 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
67266 + return -EPERM;
67267 + }
67268 +#endif
67269 + return 0;
67270 +}
67271 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
67272 new file mode 100644
67273 index 0000000..ce65ceb
67274 --- /dev/null
67275 +++ b/grsecurity/grsec_disabled.c
67276 @@ -0,0 +1,434 @@
67277 +#include <linux/kernel.h>
67278 +#include <linux/module.h>
67279 +#include <linux/sched.h>
67280 +#include <linux/file.h>
67281 +#include <linux/fs.h>
67282 +#include <linux/kdev_t.h>
67283 +#include <linux/net.h>
67284 +#include <linux/in.h>
67285 +#include <linux/ip.h>
67286 +#include <linux/skbuff.h>
67287 +#include <linux/sysctl.h>
67288 +
67289 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
67290 +void
67291 +pax_set_initial_flags(struct linux_binprm *bprm)
67292 +{
67293 + return;
67294 +}
67295 +#endif
67296 +
67297 +#ifdef CONFIG_SYSCTL
67298 +__u32
67299 +gr_handle_sysctl(const struct ctl_table * table, const int op)
67300 +{
67301 + return 0;
67302 +}
67303 +#endif
67304 +
67305 +#ifdef CONFIG_TASKSTATS
67306 +int gr_is_taskstats_denied(int pid)
67307 +{
67308 + return 0;
67309 +}
67310 +#endif
67311 +
67312 +int
67313 +gr_acl_is_enabled(void)
67314 +{
67315 + return 0;
67316 +}
67317 +
67318 +void
67319 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
67320 +{
67321 + return;
67322 +}
67323 +
67324 +int
67325 +gr_handle_rawio(const struct inode *inode)
67326 +{
67327 + return 0;
67328 +}
67329 +
67330 +void
67331 +gr_acl_handle_psacct(struct task_struct *task, const long code)
67332 +{
67333 + return;
67334 +}
67335 +
67336 +int
67337 +gr_handle_ptrace(struct task_struct *task, const long request)
67338 +{
67339 + return 0;
67340 +}
67341 +
67342 +int
67343 +gr_handle_proc_ptrace(struct task_struct *task)
67344 +{
67345 + return 0;
67346 +}
67347 +
67348 +int
67349 +gr_set_acls(const int type)
67350 +{
67351 + return 0;
67352 +}
67353 +
67354 +int
67355 +gr_check_hidden_task(const struct task_struct *tsk)
67356 +{
67357 + return 0;
67358 +}
67359 +
67360 +int
67361 +gr_check_protected_task(const struct task_struct *task)
67362 +{
67363 + return 0;
67364 +}
67365 +
67366 +int
67367 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
67368 +{
67369 + return 0;
67370 +}
67371 +
67372 +void
67373 +gr_copy_label(struct task_struct *tsk)
67374 +{
67375 + return;
67376 +}
67377 +
67378 +void
67379 +gr_set_pax_flags(struct task_struct *task)
67380 +{
67381 + return;
67382 +}
67383 +
67384 +int
67385 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
67386 + const int unsafe_share)
67387 +{
67388 + return 0;
67389 +}
67390 +
67391 +void
67392 +gr_handle_delete(const ino_t ino, const dev_t dev)
67393 +{
67394 + return;
67395 +}
67396 +
67397 +void
67398 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
67399 +{
67400 + return;
67401 +}
67402 +
67403 +void
67404 +gr_handle_crash(struct task_struct *task, const int sig)
67405 +{
67406 + return;
67407 +}
67408 +
67409 +int
67410 +gr_check_crash_exec(const struct file *filp)
67411 +{
67412 + return 0;
67413 +}
67414 +
67415 +int
67416 +gr_check_crash_uid(const kuid_t uid)
67417 +{
67418 + return 0;
67419 +}
67420 +
67421 +void
67422 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
67423 + struct dentry *old_dentry,
67424 + struct dentry *new_dentry,
67425 + struct vfsmount *mnt, const __u8 replace)
67426 +{
67427 + return;
67428 +}
67429 +
67430 +int
67431 +gr_search_socket(const int family, const int type, const int protocol)
67432 +{
67433 + return 1;
67434 +}
67435 +
67436 +int
67437 +gr_search_connectbind(const int mode, const struct socket *sock,
67438 + const struct sockaddr_in *addr)
67439 +{
67440 + return 0;
67441 +}
67442 +
67443 +void
67444 +gr_handle_alertkill(struct task_struct *task)
67445 +{
67446 + return;
67447 +}
67448 +
67449 +__u32
67450 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
67451 +{
67452 + return 1;
67453 +}
67454 +
67455 +__u32
67456 +gr_acl_handle_hidden_file(const struct dentry * dentry,
67457 + const struct vfsmount * mnt)
67458 +{
67459 + return 1;
67460 +}
67461 +
67462 +__u32
67463 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
67464 + int acc_mode)
67465 +{
67466 + return 1;
67467 +}
67468 +
67469 +__u32
67470 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67471 +{
67472 + return 1;
67473 +}
67474 +
67475 +__u32
67476 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
67477 +{
67478 + return 1;
67479 +}
67480 +
67481 +int
67482 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
67483 + unsigned int *vm_flags)
67484 +{
67485 + return 1;
67486 +}
67487 +
67488 +__u32
67489 +gr_acl_handle_truncate(const struct dentry * dentry,
67490 + const struct vfsmount * mnt)
67491 +{
67492 + return 1;
67493 +}
67494 +
67495 +__u32
67496 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
67497 +{
67498 + return 1;
67499 +}
67500 +
67501 +__u32
67502 +gr_acl_handle_access(const struct dentry * dentry,
67503 + const struct vfsmount * mnt, const int fmode)
67504 +{
67505 + return 1;
67506 +}
67507 +
67508 +__u32
67509 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
67510 + umode_t *mode)
67511 +{
67512 + return 1;
67513 +}
67514 +
67515 +__u32
67516 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
67517 +{
67518 + return 1;
67519 +}
67520 +
67521 +__u32
67522 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
67523 +{
67524 + return 1;
67525 +}
67526 +
67527 +void
67528 +grsecurity_init(void)
67529 +{
67530 + return;
67531 +}
67532 +
67533 +umode_t gr_acl_umask(void)
67534 +{
67535 + return 0;
67536 +}
67537 +
67538 +__u32
67539 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67540 + const struct dentry * parent_dentry,
67541 + const struct vfsmount * parent_mnt,
67542 + const int mode)
67543 +{
67544 + return 1;
67545 +}
67546 +
67547 +__u32
67548 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
67549 + const struct dentry * parent_dentry,
67550 + const struct vfsmount * parent_mnt)
67551 +{
67552 + return 1;
67553 +}
67554 +
67555 +__u32
67556 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67557 + const struct dentry * parent_dentry,
67558 + const struct vfsmount * parent_mnt, const struct filename *from)
67559 +{
67560 + return 1;
67561 +}
67562 +
67563 +__u32
67564 +gr_acl_handle_link(const struct dentry * new_dentry,
67565 + const struct dentry * parent_dentry,
67566 + const struct vfsmount * parent_mnt,
67567 + const struct dentry * old_dentry,
67568 + const struct vfsmount * old_mnt, const struct filename *to)
67569 +{
67570 + return 1;
67571 +}
67572 +
67573 +int
67574 +gr_acl_handle_rename(const struct dentry *new_dentry,
67575 + const struct dentry *parent_dentry,
67576 + const struct vfsmount *parent_mnt,
67577 + const struct dentry *old_dentry,
67578 + const struct inode *old_parent_inode,
67579 + const struct vfsmount *old_mnt, const struct filename *newname)
67580 +{
67581 + return 0;
67582 +}
67583 +
67584 +int
67585 +gr_acl_handle_filldir(const struct file *file, const char *name,
67586 + const int namelen, const ino_t ino)
67587 +{
67588 + return 1;
67589 +}
67590 +
67591 +int
67592 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
67593 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
67594 +{
67595 + return 1;
67596 +}
67597 +
67598 +int
67599 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
67600 +{
67601 + return 0;
67602 +}
67603 +
67604 +int
67605 +gr_search_accept(const struct socket *sock)
67606 +{
67607 + return 0;
67608 +}
67609 +
67610 +int
67611 +gr_search_listen(const struct socket *sock)
67612 +{
67613 + return 0;
67614 +}
67615 +
67616 +int
67617 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
67618 +{
67619 + return 0;
67620 +}
67621 +
67622 +__u32
67623 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
67624 +{
67625 + return 1;
67626 +}
67627 +
67628 +__u32
67629 +gr_acl_handle_creat(const struct dentry * dentry,
67630 + const struct dentry * p_dentry,
67631 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
67632 + const int imode)
67633 +{
67634 + return 1;
67635 +}
67636 +
67637 +void
67638 +gr_acl_handle_exit(void)
67639 +{
67640 + return;
67641 +}
67642 +
67643 +int
67644 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
67645 +{
67646 + return 1;
67647 +}
67648 +
67649 +void
67650 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
67651 +{
67652 + return;
67653 +}
67654 +
67655 +int
67656 +gr_acl_handle_procpidmem(const struct task_struct *task)
67657 +{
67658 + return 0;
67659 +}
67660 +
67661 +int
67662 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
67663 +{
67664 + return 0;
67665 +}
67666 +
67667 +int
67668 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
67669 +{
67670 + return 0;
67671 +}
67672 +
67673 +void
67674 +gr_set_kernel_label(struct task_struct *task)
67675 +{
67676 + return;
67677 +}
67678 +
67679 +int
67680 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
67681 +{
67682 + return 0;
67683 +}
67684 +
67685 +int
67686 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
67687 +{
67688 + return 0;
67689 +}
67690 +
67691 +int gr_acl_enable_at_secure(void)
67692 +{
67693 + return 0;
67694 +}
67695 +
67696 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
67697 +{
67698 + return dentry->d_sb->s_dev;
67699 +}
67700 +
67701 +void gr_put_exec_file(struct task_struct *task)
67702 +{
67703 + return;
67704 +}
67705 +
67706 +EXPORT_SYMBOL(gr_set_kernel_label);
67707 +#ifdef CONFIG_SECURITY
67708 +EXPORT_SYMBOL(gr_check_user_change);
67709 +EXPORT_SYMBOL(gr_check_group_change);
67710 +#endif
67711 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
67712 new file mode 100644
67713 index 0000000..387032b
67714 --- /dev/null
67715 +++ b/grsecurity/grsec_exec.c
67716 @@ -0,0 +1,187 @@
67717 +#include <linux/kernel.h>
67718 +#include <linux/sched.h>
67719 +#include <linux/file.h>
67720 +#include <linux/binfmts.h>
67721 +#include <linux/fs.h>
67722 +#include <linux/types.h>
67723 +#include <linux/grdefs.h>
67724 +#include <linux/grsecurity.h>
67725 +#include <linux/grinternal.h>
67726 +#include <linux/capability.h>
67727 +#include <linux/module.h>
67728 +#include <linux/compat.h>
67729 +
67730 +#include <asm/uaccess.h>
67731 +
67732 +#ifdef CONFIG_GRKERNSEC_EXECLOG
67733 +static char gr_exec_arg_buf[132];
67734 +static DEFINE_MUTEX(gr_exec_arg_mutex);
67735 +#endif
67736 +
67737 +struct user_arg_ptr {
67738 +#ifdef CONFIG_COMPAT
67739 + bool is_compat;
67740 +#endif
67741 + union {
67742 + const char __user *const __user *native;
67743 +#ifdef CONFIG_COMPAT
67744 + const compat_uptr_t __user *compat;
67745 +#endif
67746 + } ptr;
67747 +};
67748 +
67749 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
67750 +
67751 +void
67752 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
67753 +{
67754 +#ifdef CONFIG_GRKERNSEC_EXECLOG
67755 + char *grarg = gr_exec_arg_buf;
67756 + unsigned int i, x, execlen = 0;
67757 + char c;
67758 +
67759 + if (!((grsec_enable_execlog && grsec_enable_group &&
67760 + in_group_p(grsec_audit_gid))
67761 + || (grsec_enable_execlog && !grsec_enable_group)))
67762 + return;
67763 +
67764 + mutex_lock(&gr_exec_arg_mutex);
67765 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
67766 +
67767 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
67768 + const char __user *p;
67769 + unsigned int len;
67770 +
67771 + p = get_user_arg_ptr(argv, i);
67772 + if (IS_ERR(p))
67773 + goto log;
67774 +
67775 + len = strnlen_user(p, 128 - execlen);
67776 + if (len > 128 - execlen)
67777 + len = 128 - execlen;
67778 + else if (len > 0)
67779 + len--;
67780 + if (copy_from_user(grarg + execlen, p, len))
67781 + goto log;
67782 +
67783 + /* rewrite unprintable characters */
67784 + for (x = 0; x < len; x++) {
67785 + c = *(grarg + execlen + x);
67786 + if (c < 32 || c > 126)
67787 + *(grarg + execlen + x) = ' ';
67788 + }
67789 +
67790 + execlen += len;
67791 + *(grarg + execlen) = ' ';
67792 + *(grarg + execlen + 1) = '\0';
67793 + execlen++;
67794 + }
67795 +
67796 + log:
67797 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
67798 + bprm->file->f_path.mnt, grarg);
67799 + mutex_unlock(&gr_exec_arg_mutex);
67800 +#endif
67801 + return;
67802 +}
67803 +
67804 +#ifdef CONFIG_GRKERNSEC
67805 +extern int gr_acl_is_capable(const int cap);
67806 +extern int gr_acl_is_capable_nolog(const int cap);
67807 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
67808 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
67809 +extern int gr_chroot_is_capable(const int cap);
67810 +extern int gr_chroot_is_capable_nolog(const int cap);
67811 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
67812 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
67813 +#endif
67814 +
67815 +const char *captab_log[] = {
67816 + "CAP_CHOWN",
67817 + "CAP_DAC_OVERRIDE",
67818 + "CAP_DAC_READ_SEARCH",
67819 + "CAP_FOWNER",
67820 + "CAP_FSETID",
67821 + "CAP_KILL",
67822 + "CAP_SETGID",
67823 + "CAP_SETUID",
67824 + "CAP_SETPCAP",
67825 + "CAP_LINUX_IMMUTABLE",
67826 + "CAP_NET_BIND_SERVICE",
67827 + "CAP_NET_BROADCAST",
67828 + "CAP_NET_ADMIN",
67829 + "CAP_NET_RAW",
67830 + "CAP_IPC_LOCK",
67831 + "CAP_IPC_OWNER",
67832 + "CAP_SYS_MODULE",
67833 + "CAP_SYS_RAWIO",
67834 + "CAP_SYS_CHROOT",
67835 + "CAP_SYS_PTRACE",
67836 + "CAP_SYS_PACCT",
67837 + "CAP_SYS_ADMIN",
67838 + "CAP_SYS_BOOT",
67839 + "CAP_SYS_NICE",
67840 + "CAP_SYS_RESOURCE",
67841 + "CAP_SYS_TIME",
67842 + "CAP_SYS_TTY_CONFIG",
67843 + "CAP_MKNOD",
67844 + "CAP_LEASE",
67845 + "CAP_AUDIT_WRITE",
67846 + "CAP_AUDIT_CONTROL",
67847 + "CAP_SETFCAP",
67848 + "CAP_MAC_OVERRIDE",
67849 + "CAP_MAC_ADMIN",
67850 + "CAP_SYSLOG",
67851 + "CAP_WAKE_ALARM"
67852 +};
67853 +
67854 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
67855 +
67856 +int gr_is_capable(const int cap)
67857 +{
67858 +#ifdef CONFIG_GRKERNSEC
67859 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
67860 + return 1;
67861 + return 0;
67862 +#else
67863 + return 1;
67864 +#endif
67865 +}
67866 +
67867 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
67868 +{
67869 +#ifdef CONFIG_GRKERNSEC
67870 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
67871 + return 1;
67872 + return 0;
67873 +#else
67874 + return 1;
67875 +#endif
67876 +}
67877 +
67878 +int gr_is_capable_nolog(const int cap)
67879 +{
67880 +#ifdef CONFIG_GRKERNSEC
67881 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
67882 + return 1;
67883 + return 0;
67884 +#else
67885 + return 1;
67886 +#endif
67887 +}
67888 +
67889 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
67890 +{
67891 +#ifdef CONFIG_GRKERNSEC
67892 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
67893 + return 1;
67894 + return 0;
67895 +#else
67896 + return 1;
67897 +#endif
67898 +}
67899 +
67900 +EXPORT_SYMBOL(gr_is_capable);
67901 +EXPORT_SYMBOL(gr_is_capable_nolog);
67902 +EXPORT_SYMBOL(gr_task_is_capable);
67903 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
67904 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
67905 new file mode 100644
67906 index 0000000..06cc6ea
67907 --- /dev/null
67908 +++ b/grsecurity/grsec_fifo.c
67909 @@ -0,0 +1,24 @@
67910 +#include <linux/kernel.h>
67911 +#include <linux/sched.h>
67912 +#include <linux/fs.h>
67913 +#include <linux/file.h>
67914 +#include <linux/grinternal.h>
67915 +
67916 +int
67917 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
67918 + const struct dentry *dir, const int flag, const int acc_mode)
67919 +{
67920 +#ifdef CONFIG_GRKERNSEC_FIFO
67921 + const struct cred *cred = current_cred();
67922 +
67923 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
67924 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
67925 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
67926 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
67927 + if (!inode_permission(dentry->d_inode, acc_mode))
67928 + 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));
67929 + return -EACCES;
67930 + }
67931 +#endif
67932 + return 0;
67933 +}
67934 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
67935 new file mode 100644
67936 index 0000000..8ca18bf
67937 --- /dev/null
67938 +++ b/grsecurity/grsec_fork.c
67939 @@ -0,0 +1,23 @@
67940 +#include <linux/kernel.h>
67941 +#include <linux/sched.h>
67942 +#include <linux/grsecurity.h>
67943 +#include <linux/grinternal.h>
67944 +#include <linux/errno.h>
67945 +
67946 +void
67947 +gr_log_forkfail(const int retval)
67948 +{
67949 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
67950 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
67951 + switch (retval) {
67952 + case -EAGAIN:
67953 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
67954 + break;
67955 + case -ENOMEM:
67956 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
67957 + break;
67958 + }
67959 + }
67960 +#endif
67961 + return;
67962 +}
67963 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
67964 new file mode 100644
67965 index 0000000..ab2d875
67966 --- /dev/null
67967 +++ b/grsecurity/grsec_init.c
67968 @@ -0,0 +1,279 @@
67969 +#include <linux/kernel.h>
67970 +#include <linux/sched.h>
67971 +#include <linux/mm.h>
67972 +#include <linux/gracl.h>
67973 +#include <linux/slab.h>
67974 +#include <linux/vmalloc.h>
67975 +#include <linux/percpu.h>
67976 +#include <linux/module.h>
67977 +
67978 +int grsec_enable_ptrace_readexec;
67979 +int grsec_enable_setxid;
67980 +int grsec_enable_symlinkown;
67981 +kgid_t grsec_symlinkown_gid;
67982 +int grsec_enable_brute;
67983 +int grsec_enable_link;
67984 +int grsec_enable_dmesg;
67985 +int grsec_enable_harden_ptrace;
67986 +int grsec_enable_fifo;
67987 +int grsec_enable_execlog;
67988 +int grsec_enable_signal;
67989 +int grsec_enable_forkfail;
67990 +int grsec_enable_audit_ptrace;
67991 +int grsec_enable_time;
67992 +int grsec_enable_group;
67993 +kgid_t grsec_audit_gid;
67994 +int grsec_enable_chdir;
67995 +int grsec_enable_mount;
67996 +int grsec_enable_rofs;
67997 +int grsec_enable_chroot_findtask;
67998 +int grsec_enable_chroot_mount;
67999 +int grsec_enable_chroot_shmat;
68000 +int grsec_enable_chroot_fchdir;
68001 +int grsec_enable_chroot_double;
68002 +int grsec_enable_chroot_pivot;
68003 +int grsec_enable_chroot_chdir;
68004 +int grsec_enable_chroot_chmod;
68005 +int grsec_enable_chroot_mknod;
68006 +int grsec_enable_chroot_nice;
68007 +int grsec_enable_chroot_execlog;
68008 +int grsec_enable_chroot_caps;
68009 +int grsec_enable_chroot_sysctl;
68010 +int grsec_enable_chroot_unix;
68011 +int grsec_enable_tpe;
68012 +kgid_t grsec_tpe_gid;
68013 +int grsec_enable_blackhole;
68014 +#ifdef CONFIG_IPV6_MODULE
68015 +EXPORT_SYMBOL(grsec_enable_blackhole);
68016 +#endif
68017 +int grsec_lastack_retries;
68018 +int grsec_enable_tpe_all;
68019 +int grsec_enable_tpe_invert;
68020 +int grsec_enable_socket_all;
68021 +kgid_t grsec_socket_all_gid;
68022 +int grsec_enable_socket_client;
68023 +kgid_t grsec_socket_client_gid;
68024 +int grsec_enable_socket_server;
68025 +kgid_t grsec_socket_server_gid;
68026 +int grsec_resource_logging;
68027 +int grsec_disable_privio;
68028 +int grsec_enable_log_rwxmaps;
68029 +int grsec_lock;
68030 +
68031 +DEFINE_SPINLOCK(grsec_alert_lock);
68032 +unsigned long grsec_alert_wtime = 0;
68033 +unsigned long grsec_alert_fyet = 0;
68034 +
68035 +DEFINE_SPINLOCK(grsec_audit_lock);
68036 +
68037 +DEFINE_RWLOCK(grsec_exec_file_lock);
68038 +
68039 +char *gr_shared_page[4];
68040 +
68041 +char *gr_alert_log_fmt;
68042 +char *gr_audit_log_fmt;
68043 +char *gr_alert_log_buf;
68044 +char *gr_audit_log_buf;
68045 +
68046 +extern struct gr_arg *gr_usermode;
68047 +extern unsigned char *gr_system_salt;
68048 +extern unsigned char *gr_system_sum;
68049 +
68050 +void __init
68051 +grsecurity_init(void)
68052 +{
68053 + int j;
68054 + /* create the per-cpu shared pages */
68055 +
68056 +#ifdef CONFIG_X86
68057 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
68058 +#endif
68059 +
68060 + for (j = 0; j < 4; j++) {
68061 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
68062 + if (gr_shared_page[j] == NULL) {
68063 + panic("Unable to allocate grsecurity shared page");
68064 + return;
68065 + }
68066 + }
68067 +
68068 + /* allocate log buffers */
68069 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
68070 + if (!gr_alert_log_fmt) {
68071 + panic("Unable to allocate grsecurity alert log format buffer");
68072 + return;
68073 + }
68074 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
68075 + if (!gr_audit_log_fmt) {
68076 + panic("Unable to allocate grsecurity audit log format buffer");
68077 + return;
68078 + }
68079 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
68080 + if (!gr_alert_log_buf) {
68081 + panic("Unable to allocate grsecurity alert log buffer");
68082 + return;
68083 + }
68084 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
68085 + if (!gr_audit_log_buf) {
68086 + panic("Unable to allocate grsecurity audit log buffer");
68087 + return;
68088 + }
68089 +
68090 + /* allocate memory for authentication structure */
68091 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
68092 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
68093 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
68094 +
68095 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
68096 + panic("Unable to allocate grsecurity authentication structure");
68097 + return;
68098 + }
68099 +
68100 +
68101 +#ifdef CONFIG_GRKERNSEC_IO
68102 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
68103 + grsec_disable_privio = 1;
68104 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
68105 + grsec_disable_privio = 1;
68106 +#else
68107 + grsec_disable_privio = 0;
68108 +#endif
68109 +#endif
68110 +
68111 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
68112 + /* for backward compatibility, tpe_invert always defaults to on if
68113 + enabled in the kernel
68114 + */
68115 + grsec_enable_tpe_invert = 1;
68116 +#endif
68117 +
68118 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
68119 +#ifndef CONFIG_GRKERNSEC_SYSCTL
68120 + grsec_lock = 1;
68121 +#endif
68122 +
68123 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
68124 + grsec_enable_log_rwxmaps = 1;
68125 +#endif
68126 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
68127 + grsec_enable_group = 1;
68128 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
68129 +#endif
68130 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
68131 + grsec_enable_ptrace_readexec = 1;
68132 +#endif
68133 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
68134 + grsec_enable_chdir = 1;
68135 +#endif
68136 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
68137 + grsec_enable_harden_ptrace = 1;
68138 +#endif
68139 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
68140 + grsec_enable_mount = 1;
68141 +#endif
68142 +#ifdef CONFIG_GRKERNSEC_LINK
68143 + grsec_enable_link = 1;
68144 +#endif
68145 +#ifdef CONFIG_GRKERNSEC_BRUTE
68146 + grsec_enable_brute = 1;
68147 +#endif
68148 +#ifdef CONFIG_GRKERNSEC_DMESG
68149 + grsec_enable_dmesg = 1;
68150 +#endif
68151 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
68152 + grsec_enable_blackhole = 1;
68153 + grsec_lastack_retries = 4;
68154 +#endif
68155 +#ifdef CONFIG_GRKERNSEC_FIFO
68156 + grsec_enable_fifo = 1;
68157 +#endif
68158 +#ifdef CONFIG_GRKERNSEC_EXECLOG
68159 + grsec_enable_execlog = 1;
68160 +#endif
68161 +#ifdef CONFIG_GRKERNSEC_SETXID
68162 + grsec_enable_setxid = 1;
68163 +#endif
68164 +#ifdef CONFIG_GRKERNSEC_SIGNAL
68165 + grsec_enable_signal = 1;
68166 +#endif
68167 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
68168 + grsec_enable_forkfail = 1;
68169 +#endif
68170 +#ifdef CONFIG_GRKERNSEC_TIME
68171 + grsec_enable_time = 1;
68172 +#endif
68173 +#ifdef CONFIG_GRKERNSEC_RESLOG
68174 + grsec_resource_logging = 1;
68175 +#endif
68176 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68177 + grsec_enable_chroot_findtask = 1;
68178 +#endif
68179 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68180 + grsec_enable_chroot_unix = 1;
68181 +#endif
68182 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68183 + grsec_enable_chroot_mount = 1;
68184 +#endif
68185 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68186 + grsec_enable_chroot_fchdir = 1;
68187 +#endif
68188 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68189 + grsec_enable_chroot_shmat = 1;
68190 +#endif
68191 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
68192 + grsec_enable_audit_ptrace = 1;
68193 +#endif
68194 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68195 + grsec_enable_chroot_double = 1;
68196 +#endif
68197 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68198 + grsec_enable_chroot_pivot = 1;
68199 +#endif
68200 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
68201 + grsec_enable_chroot_chdir = 1;
68202 +#endif
68203 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
68204 + grsec_enable_chroot_chmod = 1;
68205 +#endif
68206 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68207 + grsec_enable_chroot_mknod = 1;
68208 +#endif
68209 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68210 + grsec_enable_chroot_nice = 1;
68211 +#endif
68212 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68213 + grsec_enable_chroot_execlog = 1;
68214 +#endif
68215 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68216 + grsec_enable_chroot_caps = 1;
68217 +#endif
68218 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
68219 + grsec_enable_chroot_sysctl = 1;
68220 +#endif
68221 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
68222 + grsec_enable_symlinkown = 1;
68223 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
68224 +#endif
68225 +#ifdef CONFIG_GRKERNSEC_TPE
68226 + grsec_enable_tpe = 1;
68227 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
68228 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
68229 + grsec_enable_tpe_all = 1;
68230 +#endif
68231 +#endif
68232 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
68233 + grsec_enable_socket_all = 1;
68234 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
68235 +#endif
68236 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
68237 + grsec_enable_socket_client = 1;
68238 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
68239 +#endif
68240 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
68241 + grsec_enable_socket_server = 1;
68242 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
68243 +#endif
68244 +#endif
68245 +
68246 + return;
68247 +}
68248 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
68249 new file mode 100644
68250 index 0000000..5e05e20
68251 --- /dev/null
68252 +++ b/grsecurity/grsec_link.c
68253 @@ -0,0 +1,58 @@
68254 +#include <linux/kernel.h>
68255 +#include <linux/sched.h>
68256 +#include <linux/fs.h>
68257 +#include <linux/file.h>
68258 +#include <linux/grinternal.h>
68259 +
68260 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
68261 +{
68262 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
68263 + const struct inode *link_inode = link->dentry->d_inode;
68264 +
68265 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
68266 + /* ignore root-owned links, e.g. /proc/self */
68267 + gr_is_global_nonroot(link_inode->i_uid) && target &&
68268 + !uid_eq(link_inode->i_uid, target->i_uid)) {
68269 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
68270 + return 1;
68271 + }
68272 +#endif
68273 + return 0;
68274 +}
68275 +
68276 +int
68277 +gr_handle_follow_link(const struct inode *parent,
68278 + const struct inode *inode,
68279 + const struct dentry *dentry, const struct vfsmount *mnt)
68280 +{
68281 +#ifdef CONFIG_GRKERNSEC_LINK
68282 + const struct cred *cred = current_cred();
68283 +
68284 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
68285 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
68286 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
68287 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
68288 + return -EACCES;
68289 + }
68290 +#endif
68291 + return 0;
68292 +}
68293 +
68294 +int
68295 +gr_handle_hardlink(const struct dentry *dentry,
68296 + const struct vfsmount *mnt,
68297 + struct inode *inode, const int mode, const struct filename *to)
68298 +{
68299 +#ifdef CONFIG_GRKERNSEC_LINK
68300 + const struct cred *cred = current_cred();
68301 +
68302 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
68303 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
68304 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
68305 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
68306 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
68307 + return -EPERM;
68308 + }
68309 +#endif
68310 + return 0;
68311 +}
68312 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
68313 new file mode 100644
68314 index 0000000..dbe0a6b
68315 --- /dev/null
68316 +++ b/grsecurity/grsec_log.c
68317 @@ -0,0 +1,341 @@
68318 +#include <linux/kernel.h>
68319 +#include <linux/sched.h>
68320 +#include <linux/file.h>
68321 +#include <linux/tty.h>
68322 +#include <linux/fs.h>
68323 +#include <linux/mm.h>
68324 +#include <linux/grinternal.h>
68325 +
68326 +#ifdef CONFIG_TREE_PREEMPT_RCU
68327 +#define DISABLE_PREEMPT() preempt_disable()
68328 +#define ENABLE_PREEMPT() preempt_enable()
68329 +#else
68330 +#define DISABLE_PREEMPT()
68331 +#define ENABLE_PREEMPT()
68332 +#endif
68333 +
68334 +#define BEGIN_LOCKS(x) \
68335 + DISABLE_PREEMPT(); \
68336 + rcu_read_lock(); \
68337 + read_lock(&tasklist_lock); \
68338 + read_lock(&grsec_exec_file_lock); \
68339 + if (x != GR_DO_AUDIT) \
68340 + spin_lock(&grsec_alert_lock); \
68341 + else \
68342 + spin_lock(&grsec_audit_lock)
68343 +
68344 +#define END_LOCKS(x) \
68345 + if (x != GR_DO_AUDIT) \
68346 + spin_unlock(&grsec_alert_lock); \
68347 + else \
68348 + spin_unlock(&grsec_audit_lock); \
68349 + read_unlock(&grsec_exec_file_lock); \
68350 + read_unlock(&tasklist_lock); \
68351 + rcu_read_unlock(); \
68352 + ENABLE_PREEMPT(); \
68353 + if (x == GR_DONT_AUDIT) \
68354 + gr_handle_alertkill(current)
68355 +
68356 +enum {
68357 + FLOODING,
68358 + NO_FLOODING
68359 +};
68360 +
68361 +extern char *gr_alert_log_fmt;
68362 +extern char *gr_audit_log_fmt;
68363 +extern char *gr_alert_log_buf;
68364 +extern char *gr_audit_log_buf;
68365 +
68366 +static int gr_log_start(int audit)
68367 +{
68368 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
68369 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
68370 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
68371 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
68372 + unsigned long curr_secs = get_seconds();
68373 +
68374 + if (audit == GR_DO_AUDIT)
68375 + goto set_fmt;
68376 +
68377 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
68378 + grsec_alert_wtime = curr_secs;
68379 + grsec_alert_fyet = 0;
68380 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
68381 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
68382 + grsec_alert_fyet++;
68383 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
68384 + grsec_alert_wtime = curr_secs;
68385 + grsec_alert_fyet++;
68386 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
68387 + return FLOODING;
68388 + }
68389 + else return FLOODING;
68390 +
68391 +set_fmt:
68392 +#endif
68393 + memset(buf, 0, PAGE_SIZE);
68394 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
68395 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
68396 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
68397 + } else if (current->signal->curr_ip) {
68398 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
68399 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
68400 + } else if (gr_acl_is_enabled()) {
68401 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
68402 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
68403 + } else {
68404 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
68405 + strcpy(buf, fmt);
68406 + }
68407 +
68408 + return NO_FLOODING;
68409 +}
68410 +
68411 +static void gr_log_middle(int audit, const char *msg, va_list ap)
68412 + __attribute__ ((format (printf, 2, 0)));
68413 +
68414 +static void gr_log_middle(int audit, const char *msg, va_list ap)
68415 +{
68416 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
68417 + unsigned int len = strlen(buf);
68418 +
68419 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
68420 +
68421 + return;
68422 +}
68423 +
68424 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
68425 + __attribute__ ((format (printf, 2, 3)));
68426 +
68427 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
68428 +{
68429 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
68430 + unsigned int len = strlen(buf);
68431 + va_list ap;
68432 +
68433 + va_start(ap, msg);
68434 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
68435 + va_end(ap);
68436 +
68437 + return;
68438 +}
68439 +
68440 +static void gr_log_end(int audit, int append_default)
68441 +{
68442 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
68443 + if (append_default) {
68444 + struct task_struct *task = current;
68445 + struct task_struct *parent = task->real_parent;
68446 + const struct cred *cred = __task_cred(task);
68447 + const struct cred *pcred = __task_cred(parent);
68448 + unsigned int len = strlen(buf);
68449 +
68450 + 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));
68451 + }
68452 +
68453 + printk("%s\n", buf);
68454 +
68455 + return;
68456 +}
68457 +
68458 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
68459 +{
68460 + int logtype;
68461 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
68462 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
68463 + void *voidptr = NULL;
68464 + int num1 = 0, num2 = 0;
68465 + unsigned long ulong1 = 0, ulong2 = 0;
68466 + struct dentry *dentry = NULL;
68467 + struct vfsmount *mnt = NULL;
68468 + struct file *file = NULL;
68469 + struct task_struct *task = NULL;
68470 + struct vm_area_struct *vma = NULL;
68471 + const struct cred *cred, *pcred;
68472 + va_list ap;
68473 +
68474 + BEGIN_LOCKS(audit);
68475 + logtype = gr_log_start(audit);
68476 + if (logtype == FLOODING) {
68477 + END_LOCKS(audit);
68478 + return;
68479 + }
68480 + va_start(ap, argtypes);
68481 + switch (argtypes) {
68482 + case GR_TTYSNIFF:
68483 + task = va_arg(ap, struct task_struct *);
68484 + 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));
68485 + break;
68486 + case GR_SYSCTL_HIDDEN:
68487 + str1 = va_arg(ap, char *);
68488 + gr_log_middle_varargs(audit, msg, result, str1);
68489 + break;
68490 + case GR_RBAC:
68491 + dentry = va_arg(ap, struct dentry *);
68492 + mnt = va_arg(ap, struct vfsmount *);
68493 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
68494 + break;
68495 + case GR_RBAC_STR:
68496 + dentry = va_arg(ap, struct dentry *);
68497 + mnt = va_arg(ap, struct vfsmount *);
68498 + str1 = va_arg(ap, char *);
68499 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
68500 + break;
68501 + case GR_STR_RBAC:
68502 + str1 = va_arg(ap, char *);
68503 + dentry = va_arg(ap, struct dentry *);
68504 + mnt = va_arg(ap, struct vfsmount *);
68505 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
68506 + break;
68507 + case GR_RBAC_MODE2:
68508 + dentry = va_arg(ap, struct dentry *);
68509 + mnt = va_arg(ap, struct vfsmount *);
68510 + str1 = va_arg(ap, char *);
68511 + str2 = va_arg(ap, char *);
68512 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
68513 + break;
68514 + case GR_RBAC_MODE3:
68515 + dentry = va_arg(ap, struct dentry *);
68516 + mnt = va_arg(ap, struct vfsmount *);
68517 + str1 = va_arg(ap, char *);
68518 + str2 = va_arg(ap, char *);
68519 + str3 = va_arg(ap, char *);
68520 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
68521 + break;
68522 + case GR_FILENAME:
68523 + dentry = va_arg(ap, struct dentry *);
68524 + mnt = va_arg(ap, struct vfsmount *);
68525 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
68526 + break;
68527 + case GR_STR_FILENAME:
68528 + str1 = va_arg(ap, char *);
68529 + dentry = va_arg(ap, struct dentry *);
68530 + mnt = va_arg(ap, struct vfsmount *);
68531 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
68532 + break;
68533 + case GR_FILENAME_STR:
68534 + dentry = va_arg(ap, struct dentry *);
68535 + mnt = va_arg(ap, struct vfsmount *);
68536 + str1 = va_arg(ap, char *);
68537 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
68538 + break;
68539 + case GR_FILENAME_TWO_INT:
68540 + dentry = va_arg(ap, struct dentry *);
68541 + mnt = va_arg(ap, struct vfsmount *);
68542 + num1 = va_arg(ap, int);
68543 + num2 = va_arg(ap, int);
68544 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
68545 + break;
68546 + case GR_FILENAME_TWO_INT_STR:
68547 + dentry = va_arg(ap, struct dentry *);
68548 + mnt = va_arg(ap, struct vfsmount *);
68549 + num1 = va_arg(ap, int);
68550 + num2 = va_arg(ap, int);
68551 + str1 = va_arg(ap, char *);
68552 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
68553 + break;
68554 + case GR_TEXTREL:
68555 + file = va_arg(ap, struct file *);
68556 + ulong1 = va_arg(ap, unsigned long);
68557 + ulong2 = va_arg(ap, unsigned long);
68558 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
68559 + break;
68560 + case GR_PTRACE:
68561 + task = va_arg(ap, struct task_struct *);
68562 + 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));
68563 + break;
68564 + case GR_RESOURCE:
68565 + task = va_arg(ap, struct task_struct *);
68566 + cred = __task_cred(task);
68567 + pcred = __task_cred(task->real_parent);
68568 + ulong1 = va_arg(ap, unsigned long);
68569 + str1 = va_arg(ap, char *);
68570 + ulong2 = va_arg(ap, unsigned long);
68571 + 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));
68572 + break;
68573 + case GR_CAP:
68574 + task = va_arg(ap, struct task_struct *);
68575 + cred = __task_cred(task);
68576 + pcred = __task_cred(task->real_parent);
68577 + str1 = va_arg(ap, char *);
68578 + 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));
68579 + break;
68580 + case GR_SIG:
68581 + str1 = va_arg(ap, char *);
68582 + voidptr = va_arg(ap, void *);
68583 + gr_log_middle_varargs(audit, msg, str1, voidptr);
68584 + break;
68585 + case GR_SIG2:
68586 + task = va_arg(ap, struct task_struct *);
68587 + cred = __task_cred(task);
68588 + pcred = __task_cred(task->real_parent);
68589 + num1 = va_arg(ap, int);
68590 + 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));
68591 + break;
68592 + case GR_CRASH1:
68593 + task = va_arg(ap, struct task_struct *);
68594 + cred = __task_cred(task);
68595 + pcred = __task_cred(task->real_parent);
68596 + ulong1 = va_arg(ap, unsigned long);
68597 + 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);
68598 + break;
68599 + case GR_CRASH2:
68600 + task = va_arg(ap, struct task_struct *);
68601 + cred = __task_cred(task);
68602 + pcred = __task_cred(task->real_parent);
68603 + ulong1 = va_arg(ap, unsigned long);
68604 + 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);
68605 + break;
68606 + case GR_RWXMAP:
68607 + file = va_arg(ap, struct file *);
68608 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
68609 + break;
68610 + case GR_RWXMAPVMA:
68611 + vma = va_arg(ap, struct vm_area_struct *);
68612 + if (vma->vm_file)
68613 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
68614 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
68615 + str1 = "<stack>";
68616 + else if (vma->vm_start <= current->mm->brk &&
68617 + vma->vm_end >= current->mm->start_brk)
68618 + str1 = "<heap>";
68619 + else
68620 + str1 = "<anonymous mapping>";
68621 + gr_log_middle_varargs(audit, msg, str1);
68622 + break;
68623 + case GR_PSACCT:
68624 + {
68625 + unsigned int wday, cday;
68626 + __u8 whr, chr;
68627 + __u8 wmin, cmin;
68628 + __u8 wsec, csec;
68629 + char cur_tty[64] = { 0 };
68630 + char parent_tty[64] = { 0 };
68631 +
68632 + task = va_arg(ap, struct task_struct *);
68633 + wday = va_arg(ap, unsigned int);
68634 + cday = va_arg(ap, unsigned int);
68635 + whr = va_arg(ap, int);
68636 + chr = va_arg(ap, int);
68637 + wmin = va_arg(ap, int);
68638 + cmin = va_arg(ap, int);
68639 + wsec = va_arg(ap, int);
68640 + csec = va_arg(ap, int);
68641 + ulong1 = va_arg(ap, unsigned long);
68642 + cred = __task_cred(task);
68643 + pcred = __task_cred(task->real_parent);
68644 +
68645 + 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));
68646 + }
68647 + break;
68648 + default:
68649 + gr_log_middle(audit, msg, ap);
68650 + }
68651 + va_end(ap);
68652 + // these don't need DEFAULTSECARGS printed on the end
68653 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
68654 + gr_log_end(audit, 0);
68655 + else
68656 + gr_log_end(audit, 1);
68657 + END_LOCKS(audit);
68658 +}
68659 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
68660 new file mode 100644
68661 index 0000000..f536303
68662 --- /dev/null
68663 +++ b/grsecurity/grsec_mem.c
68664 @@ -0,0 +1,40 @@
68665 +#include <linux/kernel.h>
68666 +#include <linux/sched.h>
68667 +#include <linux/mm.h>
68668 +#include <linux/mman.h>
68669 +#include <linux/grinternal.h>
68670 +
68671 +void
68672 +gr_handle_ioperm(void)
68673 +{
68674 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
68675 + return;
68676 +}
68677 +
68678 +void
68679 +gr_handle_iopl(void)
68680 +{
68681 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
68682 + return;
68683 +}
68684 +
68685 +void
68686 +gr_handle_mem_readwrite(u64 from, u64 to)
68687 +{
68688 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
68689 + return;
68690 +}
68691 +
68692 +void
68693 +gr_handle_vm86(void)
68694 +{
68695 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
68696 + return;
68697 +}
68698 +
68699 +void
68700 +gr_log_badprocpid(const char *entry)
68701 +{
68702 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
68703 + return;
68704 +}
68705 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
68706 new file mode 100644
68707 index 0000000..2131422
68708 --- /dev/null
68709 +++ b/grsecurity/grsec_mount.c
68710 @@ -0,0 +1,62 @@
68711 +#include <linux/kernel.h>
68712 +#include <linux/sched.h>
68713 +#include <linux/mount.h>
68714 +#include <linux/grsecurity.h>
68715 +#include <linux/grinternal.h>
68716 +
68717 +void
68718 +gr_log_remount(const char *devname, const int retval)
68719 +{
68720 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
68721 + if (grsec_enable_mount && (retval >= 0))
68722 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
68723 +#endif
68724 + return;
68725 +}
68726 +
68727 +void
68728 +gr_log_unmount(const char *devname, const int retval)
68729 +{
68730 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
68731 + if (grsec_enable_mount && (retval >= 0))
68732 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
68733 +#endif
68734 + return;
68735 +}
68736 +
68737 +void
68738 +gr_log_mount(const char *from, const char *to, const int retval)
68739 +{
68740 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
68741 + if (grsec_enable_mount && (retval >= 0))
68742 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
68743 +#endif
68744 + return;
68745 +}
68746 +
68747 +int
68748 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
68749 +{
68750 +#ifdef CONFIG_GRKERNSEC_ROFS
68751 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
68752 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
68753 + return -EPERM;
68754 + } else
68755 + return 0;
68756 +#endif
68757 + return 0;
68758 +}
68759 +
68760 +int
68761 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
68762 +{
68763 +#ifdef CONFIG_GRKERNSEC_ROFS
68764 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
68765 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
68766 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
68767 + return -EPERM;
68768 + } else
68769 + return 0;
68770 +#endif
68771 + return 0;
68772 +}
68773 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
68774 new file mode 100644
68775 index 0000000..6ee9d50
68776 --- /dev/null
68777 +++ b/grsecurity/grsec_pax.c
68778 @@ -0,0 +1,45 @@
68779 +#include <linux/kernel.h>
68780 +#include <linux/sched.h>
68781 +#include <linux/mm.h>
68782 +#include <linux/file.h>
68783 +#include <linux/grinternal.h>
68784 +#include <linux/grsecurity.h>
68785 +
68786 +void
68787 +gr_log_textrel(struct vm_area_struct * vma)
68788 +{
68789 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
68790 + if (grsec_enable_log_rwxmaps)
68791 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
68792 +#endif
68793 + return;
68794 +}
68795 +
68796 +void gr_log_ptgnustack(struct file *file)
68797 +{
68798 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
68799 + if (grsec_enable_log_rwxmaps)
68800 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
68801 +#endif
68802 + return;
68803 +}
68804 +
68805 +void
68806 +gr_log_rwxmmap(struct file *file)
68807 +{
68808 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
68809 + if (grsec_enable_log_rwxmaps)
68810 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
68811 +#endif
68812 + return;
68813 +}
68814 +
68815 +void
68816 +gr_log_rwxmprotect(struct vm_area_struct *vma)
68817 +{
68818 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
68819 + if (grsec_enable_log_rwxmaps)
68820 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
68821 +#endif
68822 + return;
68823 +}
68824 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
68825 new file mode 100644
68826 index 0000000..f7f29aa
68827 --- /dev/null
68828 +++ b/grsecurity/grsec_ptrace.c
68829 @@ -0,0 +1,30 @@
68830 +#include <linux/kernel.h>
68831 +#include <linux/sched.h>
68832 +#include <linux/grinternal.h>
68833 +#include <linux/security.h>
68834 +
68835 +void
68836 +gr_audit_ptrace(struct task_struct *task)
68837 +{
68838 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
68839 + if (grsec_enable_audit_ptrace)
68840 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
68841 +#endif
68842 + return;
68843 +}
68844 +
68845 +int
68846 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
68847 +{
68848 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
68849 + const struct dentry *dentry = file->f_path.dentry;
68850 + const struct vfsmount *mnt = file->f_path.mnt;
68851 +
68852 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
68853 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
68854 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
68855 + return -EACCES;
68856 + }
68857 +#endif
68858 + return 0;
68859 +}
68860 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
68861 new file mode 100644
68862 index 0000000..4e29cc7
68863 --- /dev/null
68864 +++ b/grsecurity/grsec_sig.c
68865 @@ -0,0 +1,246 @@
68866 +#include <linux/kernel.h>
68867 +#include <linux/sched.h>
68868 +#include <linux/fs.h>
68869 +#include <linux/delay.h>
68870 +#include <linux/grsecurity.h>
68871 +#include <linux/grinternal.h>
68872 +#include <linux/hardirq.h>
68873 +
68874 +char *signames[] = {
68875 + [SIGSEGV] = "Segmentation fault",
68876 + [SIGILL] = "Illegal instruction",
68877 + [SIGABRT] = "Abort",
68878 + [SIGBUS] = "Invalid alignment/Bus error"
68879 +};
68880 +
68881 +void
68882 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
68883 +{
68884 +#ifdef CONFIG_GRKERNSEC_SIGNAL
68885 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
68886 + (sig == SIGABRT) || (sig == SIGBUS))) {
68887 + if (task_pid_nr(t) == task_pid_nr(current)) {
68888 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
68889 + } else {
68890 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
68891 + }
68892 + }
68893 +#endif
68894 + return;
68895 +}
68896 +
68897 +int
68898 +gr_handle_signal(const struct task_struct *p, const int sig)
68899 +{
68900 +#ifdef CONFIG_GRKERNSEC
68901 + /* ignore the 0 signal for protected task checks */
68902 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
68903 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
68904 + return -EPERM;
68905 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
68906 + return -EPERM;
68907 + }
68908 +#endif
68909 + return 0;
68910 +}
68911 +
68912 +#ifdef CONFIG_GRKERNSEC
68913 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
68914 +
68915 +int gr_fake_force_sig(int sig, struct task_struct *t)
68916 +{
68917 + unsigned long int flags;
68918 + int ret, blocked, ignored;
68919 + struct k_sigaction *action;
68920 +
68921 + spin_lock_irqsave(&t->sighand->siglock, flags);
68922 + action = &t->sighand->action[sig-1];
68923 + ignored = action->sa.sa_handler == SIG_IGN;
68924 + blocked = sigismember(&t->blocked, sig);
68925 + if (blocked || ignored) {
68926 + action->sa.sa_handler = SIG_DFL;
68927 + if (blocked) {
68928 + sigdelset(&t->blocked, sig);
68929 + recalc_sigpending_and_wake(t);
68930 + }
68931 + }
68932 + if (action->sa.sa_handler == SIG_DFL)
68933 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
68934 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
68935 +
68936 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
68937 +
68938 + return ret;
68939 +}
68940 +#endif
68941 +
68942 +#ifdef CONFIG_GRKERNSEC_BRUTE
68943 +#define GR_USER_BAN_TIME (15 * 60)
68944 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
68945 +
68946 +static int __get_dumpable(unsigned long mm_flags)
68947 +{
68948 + int ret;
68949 +
68950 + ret = mm_flags & MMF_DUMPABLE_MASK;
68951 + return (ret >= 2) ? 2 : ret;
68952 +}
68953 +#endif
68954 +
68955 +void gr_handle_brute_attach(unsigned long mm_flags)
68956 +{
68957 +#ifdef CONFIG_GRKERNSEC_BRUTE
68958 + struct task_struct *p = current;
68959 + kuid_t uid = GLOBAL_ROOT_UID;
68960 + int daemon = 0;
68961 +
68962 + if (!grsec_enable_brute)
68963 + return;
68964 +
68965 + rcu_read_lock();
68966 + read_lock(&tasklist_lock);
68967 + read_lock(&grsec_exec_file_lock);
68968 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
68969 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
68970 + p->real_parent->brute = 1;
68971 + daemon = 1;
68972 + } else {
68973 + const struct cred *cred = __task_cred(p), *cred2;
68974 + struct task_struct *tsk, *tsk2;
68975 +
68976 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
68977 + struct user_struct *user;
68978 +
68979 + uid = cred->uid;
68980 +
68981 + /* this is put upon execution past expiration */
68982 + user = find_user(uid);
68983 + if (user == NULL)
68984 + goto unlock;
68985 + user->suid_banned = 1;
68986 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
68987 + if (user->suid_ban_expires == ~0UL)
68988 + user->suid_ban_expires--;
68989 +
68990 + /* only kill other threads of the same binary, from the same user */
68991 + do_each_thread(tsk2, tsk) {
68992 + cred2 = __task_cred(tsk);
68993 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
68994 + gr_fake_force_sig(SIGKILL, tsk);
68995 + } while_each_thread(tsk2, tsk);
68996 + }
68997 + }
68998 +unlock:
68999 + read_unlock(&grsec_exec_file_lock);
69000 + read_unlock(&tasklist_lock);
69001 + rcu_read_unlock();
69002 +
69003 + if (gr_is_global_nonroot(uid))
69004 + 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);
69005 + else if (daemon)
69006 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
69007 +
69008 +#endif
69009 + return;
69010 +}
69011 +
69012 +void gr_handle_brute_check(void)
69013 +{
69014 +#ifdef CONFIG_GRKERNSEC_BRUTE
69015 + struct task_struct *p = current;
69016 +
69017 + if (unlikely(p->brute)) {
69018 + if (!grsec_enable_brute)
69019 + p->brute = 0;
69020 + else if (time_before(get_seconds(), p->brute_expires))
69021 + msleep(30 * 1000);
69022 + }
69023 +#endif
69024 + return;
69025 +}
69026 +
69027 +void gr_handle_kernel_exploit(void)
69028 +{
69029 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
69030 + const struct cred *cred;
69031 + struct task_struct *tsk, *tsk2;
69032 + struct user_struct *user;
69033 + kuid_t uid;
69034 +
69035 + if (in_irq() || in_serving_softirq() || in_nmi())
69036 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
69037 +
69038 + uid = current_uid();
69039 +
69040 + if (gr_is_global_root(uid))
69041 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
69042 + else {
69043 + /* kill all the processes of this user, hold a reference
69044 + to their creds struct, and prevent them from creating
69045 + another process until system reset
69046 + */
69047 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
69048 + GR_GLOBAL_UID(uid));
69049 + /* we intentionally leak this ref */
69050 + user = get_uid(current->cred->user);
69051 + if (user)
69052 + user->kernel_banned = 1;
69053 +
69054 + /* kill all processes of this user */
69055 + read_lock(&tasklist_lock);
69056 + do_each_thread(tsk2, tsk) {
69057 + cred = __task_cred(tsk);
69058 + if (uid_eq(cred->uid, uid))
69059 + gr_fake_force_sig(SIGKILL, tsk);
69060 + } while_each_thread(tsk2, tsk);
69061 + read_unlock(&tasklist_lock);
69062 + }
69063 +#endif
69064 +}
69065 +
69066 +#ifdef CONFIG_GRKERNSEC_BRUTE
69067 +static bool suid_ban_expired(struct user_struct *user)
69068 +{
69069 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
69070 + user->suid_banned = 0;
69071 + user->suid_ban_expires = 0;
69072 + free_uid(user);
69073 + return true;
69074 + }
69075 +
69076 + return false;
69077 +}
69078 +#endif
69079 +
69080 +int gr_process_kernel_exec_ban(void)
69081 +{
69082 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
69083 + if (unlikely(current->cred->user->kernel_banned))
69084 + return -EPERM;
69085 +#endif
69086 + return 0;
69087 +}
69088 +
69089 +int gr_process_kernel_setuid_ban(struct user_struct *user)
69090 +{
69091 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
69092 + if (unlikely(user->kernel_banned))
69093 + gr_fake_force_sig(SIGKILL, current);
69094 +#endif
69095 + return 0;
69096 +}
69097 +
69098 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
69099 +{
69100 +#ifdef CONFIG_GRKERNSEC_BRUTE
69101 + struct user_struct *user = current->cred->user;
69102 + if (unlikely(user->suid_banned)) {
69103 + if (suid_ban_expired(user))
69104 + return 0;
69105 + /* disallow execution of suid binaries only */
69106 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
69107 + return -EPERM;
69108 + }
69109 +#endif
69110 + return 0;
69111 +}
69112 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
69113 new file mode 100644
69114 index 0000000..4030d57
69115 --- /dev/null
69116 +++ b/grsecurity/grsec_sock.c
69117 @@ -0,0 +1,244 @@
69118 +#include <linux/kernel.h>
69119 +#include <linux/module.h>
69120 +#include <linux/sched.h>
69121 +#include <linux/file.h>
69122 +#include <linux/net.h>
69123 +#include <linux/in.h>
69124 +#include <linux/ip.h>
69125 +#include <net/sock.h>
69126 +#include <net/inet_sock.h>
69127 +#include <linux/grsecurity.h>
69128 +#include <linux/grinternal.h>
69129 +#include <linux/gracl.h>
69130 +
69131 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
69132 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
69133 +
69134 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
69135 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
69136 +
69137 +#ifdef CONFIG_UNIX_MODULE
69138 +EXPORT_SYMBOL(gr_acl_handle_unix);
69139 +EXPORT_SYMBOL(gr_acl_handle_mknod);
69140 +EXPORT_SYMBOL(gr_handle_chroot_unix);
69141 +EXPORT_SYMBOL(gr_handle_create);
69142 +#endif
69143 +
69144 +#ifdef CONFIG_GRKERNSEC
69145 +#define gr_conn_table_size 32749
69146 +struct conn_table_entry {
69147 + struct conn_table_entry *next;
69148 + struct signal_struct *sig;
69149 +};
69150 +
69151 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
69152 +DEFINE_SPINLOCK(gr_conn_table_lock);
69153 +
69154 +extern const char * gr_socktype_to_name(unsigned char type);
69155 +extern const char * gr_proto_to_name(unsigned char proto);
69156 +extern const char * gr_sockfamily_to_name(unsigned char family);
69157 +
69158 +static __inline__ int
69159 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
69160 +{
69161 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
69162 +}
69163 +
69164 +static __inline__ int
69165 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
69166 + __u16 sport, __u16 dport)
69167 +{
69168 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
69169 + sig->gr_sport == sport && sig->gr_dport == dport))
69170 + return 1;
69171 + else
69172 + return 0;
69173 +}
69174 +
69175 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
69176 +{
69177 + struct conn_table_entry **match;
69178 + unsigned int index;
69179 +
69180 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
69181 + sig->gr_sport, sig->gr_dport,
69182 + gr_conn_table_size);
69183 +
69184 + newent->sig = sig;
69185 +
69186 + match = &gr_conn_table[index];
69187 + newent->next = *match;
69188 + *match = newent;
69189 +
69190 + return;
69191 +}
69192 +
69193 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
69194 +{
69195 + struct conn_table_entry *match, *last = NULL;
69196 + unsigned int index;
69197 +
69198 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
69199 + sig->gr_sport, sig->gr_dport,
69200 + gr_conn_table_size);
69201 +
69202 + match = gr_conn_table[index];
69203 + while (match && !conn_match(match->sig,
69204 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
69205 + sig->gr_dport)) {
69206 + last = match;
69207 + match = match->next;
69208 + }
69209 +
69210 + if (match) {
69211 + if (last)
69212 + last->next = match->next;
69213 + else
69214 + gr_conn_table[index] = NULL;
69215 + kfree(match);
69216 + }
69217 +
69218 + return;
69219 +}
69220 +
69221 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
69222 + __u16 sport, __u16 dport)
69223 +{
69224 + struct conn_table_entry *match;
69225 + unsigned int index;
69226 +
69227 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
69228 +
69229 + match = gr_conn_table[index];
69230 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
69231 + match = match->next;
69232 +
69233 + if (match)
69234 + return match->sig;
69235 + else
69236 + return NULL;
69237 +}
69238 +
69239 +#endif
69240 +
69241 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
69242 +{
69243 +#ifdef CONFIG_GRKERNSEC
69244 + struct signal_struct *sig = task->signal;
69245 + struct conn_table_entry *newent;
69246 +
69247 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
69248 + if (newent == NULL)
69249 + return;
69250 + /* no bh lock needed since we are called with bh disabled */
69251 + spin_lock(&gr_conn_table_lock);
69252 + gr_del_task_from_ip_table_nolock(sig);
69253 + sig->gr_saddr = inet->inet_rcv_saddr;
69254 + sig->gr_daddr = inet->inet_daddr;
69255 + sig->gr_sport = inet->inet_sport;
69256 + sig->gr_dport = inet->inet_dport;
69257 + gr_add_to_task_ip_table_nolock(sig, newent);
69258 + spin_unlock(&gr_conn_table_lock);
69259 +#endif
69260 + return;
69261 +}
69262 +
69263 +void gr_del_task_from_ip_table(struct task_struct *task)
69264 +{
69265 +#ifdef CONFIG_GRKERNSEC
69266 + spin_lock_bh(&gr_conn_table_lock);
69267 + gr_del_task_from_ip_table_nolock(task->signal);
69268 + spin_unlock_bh(&gr_conn_table_lock);
69269 +#endif
69270 + return;
69271 +}
69272 +
69273 +void
69274 +gr_attach_curr_ip(const struct sock *sk)
69275 +{
69276 +#ifdef CONFIG_GRKERNSEC
69277 + struct signal_struct *p, *set;
69278 + const struct inet_sock *inet = inet_sk(sk);
69279 +
69280 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
69281 + return;
69282 +
69283 + set = current->signal;
69284 +
69285 + spin_lock_bh(&gr_conn_table_lock);
69286 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
69287 + inet->inet_dport, inet->inet_sport);
69288 + if (unlikely(p != NULL)) {
69289 + set->curr_ip = p->curr_ip;
69290 + set->used_accept = 1;
69291 + gr_del_task_from_ip_table_nolock(p);
69292 + spin_unlock_bh(&gr_conn_table_lock);
69293 + return;
69294 + }
69295 + spin_unlock_bh(&gr_conn_table_lock);
69296 +
69297 + set->curr_ip = inet->inet_daddr;
69298 + set->used_accept = 1;
69299 +#endif
69300 + return;
69301 +}
69302 +
69303 +int
69304 +gr_handle_sock_all(const int family, const int type, const int protocol)
69305 +{
69306 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69307 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
69308 + (family != AF_UNIX)) {
69309 + if (family == AF_INET)
69310 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
69311 + else
69312 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
69313 + return -EACCES;
69314 + }
69315 +#endif
69316 + return 0;
69317 +}
69318 +
69319 +int
69320 +gr_handle_sock_server(const struct sockaddr *sck)
69321 +{
69322 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69323 + if (grsec_enable_socket_server &&
69324 + in_group_p(grsec_socket_server_gid) &&
69325 + sck && (sck->sa_family != AF_UNIX) &&
69326 + (sck->sa_family != AF_LOCAL)) {
69327 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
69328 + return -EACCES;
69329 + }
69330 +#endif
69331 + return 0;
69332 +}
69333 +
69334 +int
69335 +gr_handle_sock_server_other(const struct sock *sck)
69336 +{
69337 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69338 + if (grsec_enable_socket_server &&
69339 + in_group_p(grsec_socket_server_gid) &&
69340 + sck && (sck->sk_family != AF_UNIX) &&
69341 + (sck->sk_family != AF_LOCAL)) {
69342 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
69343 + return -EACCES;
69344 + }
69345 +#endif
69346 + return 0;
69347 +}
69348 +
69349 +int
69350 +gr_handle_sock_client(const struct sockaddr *sck)
69351 +{
69352 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69353 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
69354 + sck && (sck->sa_family != AF_UNIX) &&
69355 + (sck->sa_family != AF_LOCAL)) {
69356 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
69357 + return -EACCES;
69358 + }
69359 +#endif
69360 + return 0;
69361 +}
69362 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
69363 new file mode 100644
69364 index 0000000..7624d1c
69365 --- /dev/null
69366 +++ b/grsecurity/grsec_sysctl.c
69367 @@ -0,0 +1,460 @@
69368 +#include <linux/kernel.h>
69369 +#include <linux/sched.h>
69370 +#include <linux/sysctl.h>
69371 +#include <linux/grsecurity.h>
69372 +#include <linux/grinternal.h>
69373 +
69374 +int
69375 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
69376 +{
69377 +#ifdef CONFIG_GRKERNSEC_SYSCTL
69378 + if (dirname == NULL || name == NULL)
69379 + return 0;
69380 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
69381 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
69382 + return -EACCES;
69383 + }
69384 +#endif
69385 + return 0;
69386 +}
69387 +
69388 +#ifdef CONFIG_GRKERNSEC_ROFS
69389 +static int __maybe_unused one = 1;
69390 +#endif
69391 +
69392 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
69393 +struct ctl_table grsecurity_table[] = {
69394 +#ifdef CONFIG_GRKERNSEC_SYSCTL
69395 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
69396 +#ifdef CONFIG_GRKERNSEC_IO
69397 + {
69398 + .procname = "disable_priv_io",
69399 + .data = &grsec_disable_privio,
69400 + .maxlen = sizeof(int),
69401 + .mode = 0600,
69402 + .proc_handler = &proc_dointvec,
69403 + },
69404 +#endif
69405 +#endif
69406 +#ifdef CONFIG_GRKERNSEC_LINK
69407 + {
69408 + .procname = "linking_restrictions",
69409 + .data = &grsec_enable_link,
69410 + .maxlen = sizeof(int),
69411 + .mode = 0600,
69412 + .proc_handler = &proc_dointvec,
69413 + },
69414 +#endif
69415 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69416 + {
69417 + .procname = "enforce_symlinksifowner",
69418 + .data = &grsec_enable_symlinkown,
69419 + .maxlen = sizeof(int),
69420 + .mode = 0600,
69421 + .proc_handler = &proc_dointvec,
69422 + },
69423 + {
69424 + .procname = "symlinkown_gid",
69425 + .data = &grsec_symlinkown_gid,
69426 + .maxlen = sizeof(int),
69427 + .mode = 0600,
69428 + .proc_handler = &proc_dointvec,
69429 + },
69430 +#endif
69431 +#ifdef CONFIG_GRKERNSEC_BRUTE
69432 + {
69433 + .procname = "deter_bruteforce",
69434 + .data = &grsec_enable_brute,
69435 + .maxlen = sizeof(int),
69436 + .mode = 0600,
69437 + .proc_handler = &proc_dointvec,
69438 + },
69439 +#endif
69440 +#ifdef CONFIG_GRKERNSEC_FIFO
69441 + {
69442 + .procname = "fifo_restrictions",
69443 + .data = &grsec_enable_fifo,
69444 + .maxlen = sizeof(int),
69445 + .mode = 0600,
69446 + .proc_handler = &proc_dointvec,
69447 + },
69448 +#endif
69449 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69450 + {
69451 + .procname = "ptrace_readexec",
69452 + .data = &grsec_enable_ptrace_readexec,
69453 + .maxlen = sizeof(int),
69454 + .mode = 0600,
69455 + .proc_handler = &proc_dointvec,
69456 + },
69457 +#endif
69458 +#ifdef CONFIG_GRKERNSEC_SETXID
69459 + {
69460 + .procname = "consistent_setxid",
69461 + .data = &grsec_enable_setxid,
69462 + .maxlen = sizeof(int),
69463 + .mode = 0600,
69464 + .proc_handler = &proc_dointvec,
69465 + },
69466 +#endif
69467 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69468 + {
69469 + .procname = "ip_blackhole",
69470 + .data = &grsec_enable_blackhole,
69471 + .maxlen = sizeof(int),
69472 + .mode = 0600,
69473 + .proc_handler = &proc_dointvec,
69474 + },
69475 + {
69476 + .procname = "lastack_retries",
69477 + .data = &grsec_lastack_retries,
69478 + .maxlen = sizeof(int),
69479 + .mode = 0600,
69480 + .proc_handler = &proc_dointvec,
69481 + },
69482 +#endif
69483 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69484 + {
69485 + .procname = "exec_logging",
69486 + .data = &grsec_enable_execlog,
69487 + .maxlen = sizeof(int),
69488 + .mode = 0600,
69489 + .proc_handler = &proc_dointvec,
69490 + },
69491 +#endif
69492 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69493 + {
69494 + .procname = "rwxmap_logging",
69495 + .data = &grsec_enable_log_rwxmaps,
69496 + .maxlen = sizeof(int),
69497 + .mode = 0600,
69498 + .proc_handler = &proc_dointvec,
69499 + },
69500 +#endif
69501 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69502 + {
69503 + .procname = "signal_logging",
69504 + .data = &grsec_enable_signal,
69505 + .maxlen = sizeof(int),
69506 + .mode = 0600,
69507 + .proc_handler = &proc_dointvec,
69508 + },
69509 +#endif
69510 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69511 + {
69512 + .procname = "forkfail_logging",
69513 + .data = &grsec_enable_forkfail,
69514 + .maxlen = sizeof(int),
69515 + .mode = 0600,
69516 + .proc_handler = &proc_dointvec,
69517 + },
69518 +#endif
69519 +#ifdef CONFIG_GRKERNSEC_TIME
69520 + {
69521 + .procname = "timechange_logging",
69522 + .data = &grsec_enable_time,
69523 + .maxlen = sizeof(int),
69524 + .mode = 0600,
69525 + .proc_handler = &proc_dointvec,
69526 + },
69527 +#endif
69528 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69529 + {
69530 + .procname = "chroot_deny_shmat",
69531 + .data = &grsec_enable_chroot_shmat,
69532 + .maxlen = sizeof(int),
69533 + .mode = 0600,
69534 + .proc_handler = &proc_dointvec,
69535 + },
69536 +#endif
69537 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69538 + {
69539 + .procname = "chroot_deny_unix",
69540 + .data = &grsec_enable_chroot_unix,
69541 + .maxlen = sizeof(int),
69542 + .mode = 0600,
69543 + .proc_handler = &proc_dointvec,
69544 + },
69545 +#endif
69546 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69547 + {
69548 + .procname = "chroot_deny_mount",
69549 + .data = &grsec_enable_chroot_mount,
69550 + .maxlen = sizeof(int),
69551 + .mode = 0600,
69552 + .proc_handler = &proc_dointvec,
69553 + },
69554 +#endif
69555 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69556 + {
69557 + .procname = "chroot_deny_fchdir",
69558 + .data = &grsec_enable_chroot_fchdir,
69559 + .maxlen = sizeof(int),
69560 + .mode = 0600,
69561 + .proc_handler = &proc_dointvec,
69562 + },
69563 +#endif
69564 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69565 + {
69566 + .procname = "chroot_deny_chroot",
69567 + .data = &grsec_enable_chroot_double,
69568 + .maxlen = sizeof(int),
69569 + .mode = 0600,
69570 + .proc_handler = &proc_dointvec,
69571 + },
69572 +#endif
69573 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69574 + {
69575 + .procname = "chroot_deny_pivot",
69576 + .data = &grsec_enable_chroot_pivot,
69577 + .maxlen = sizeof(int),
69578 + .mode = 0600,
69579 + .proc_handler = &proc_dointvec,
69580 + },
69581 +#endif
69582 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69583 + {
69584 + .procname = "chroot_enforce_chdir",
69585 + .data = &grsec_enable_chroot_chdir,
69586 + .maxlen = sizeof(int),
69587 + .mode = 0600,
69588 + .proc_handler = &proc_dointvec,
69589 + },
69590 +#endif
69591 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69592 + {
69593 + .procname = "chroot_deny_chmod",
69594 + .data = &grsec_enable_chroot_chmod,
69595 + .maxlen = sizeof(int),
69596 + .mode = 0600,
69597 + .proc_handler = &proc_dointvec,
69598 + },
69599 +#endif
69600 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69601 + {
69602 + .procname = "chroot_deny_mknod",
69603 + .data = &grsec_enable_chroot_mknod,
69604 + .maxlen = sizeof(int),
69605 + .mode = 0600,
69606 + .proc_handler = &proc_dointvec,
69607 + },
69608 +#endif
69609 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69610 + {
69611 + .procname = "chroot_restrict_nice",
69612 + .data = &grsec_enable_chroot_nice,
69613 + .maxlen = sizeof(int),
69614 + .mode = 0600,
69615 + .proc_handler = &proc_dointvec,
69616 + },
69617 +#endif
69618 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69619 + {
69620 + .procname = "chroot_execlog",
69621 + .data = &grsec_enable_chroot_execlog,
69622 + .maxlen = sizeof(int),
69623 + .mode = 0600,
69624 + .proc_handler = &proc_dointvec,
69625 + },
69626 +#endif
69627 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69628 + {
69629 + .procname = "chroot_caps",
69630 + .data = &grsec_enable_chroot_caps,
69631 + .maxlen = sizeof(int),
69632 + .mode = 0600,
69633 + .proc_handler = &proc_dointvec,
69634 + },
69635 +#endif
69636 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69637 + {
69638 + .procname = "chroot_deny_sysctl",
69639 + .data = &grsec_enable_chroot_sysctl,
69640 + .maxlen = sizeof(int),
69641 + .mode = 0600,
69642 + .proc_handler = &proc_dointvec,
69643 + },
69644 +#endif
69645 +#ifdef CONFIG_GRKERNSEC_TPE
69646 + {
69647 + .procname = "tpe",
69648 + .data = &grsec_enable_tpe,
69649 + .maxlen = sizeof(int),
69650 + .mode = 0600,
69651 + .proc_handler = &proc_dointvec,
69652 + },
69653 + {
69654 + .procname = "tpe_gid",
69655 + .data = &grsec_tpe_gid,
69656 + .maxlen = sizeof(int),
69657 + .mode = 0600,
69658 + .proc_handler = &proc_dointvec,
69659 + },
69660 +#endif
69661 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69662 + {
69663 + .procname = "tpe_invert",
69664 + .data = &grsec_enable_tpe_invert,
69665 + .maxlen = sizeof(int),
69666 + .mode = 0600,
69667 + .proc_handler = &proc_dointvec,
69668 + },
69669 +#endif
69670 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69671 + {
69672 + .procname = "tpe_restrict_all",
69673 + .data = &grsec_enable_tpe_all,
69674 + .maxlen = sizeof(int),
69675 + .mode = 0600,
69676 + .proc_handler = &proc_dointvec,
69677 + },
69678 +#endif
69679 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69680 + {
69681 + .procname = "socket_all",
69682 + .data = &grsec_enable_socket_all,
69683 + .maxlen = sizeof(int),
69684 + .mode = 0600,
69685 + .proc_handler = &proc_dointvec,
69686 + },
69687 + {
69688 + .procname = "socket_all_gid",
69689 + .data = &grsec_socket_all_gid,
69690 + .maxlen = sizeof(int),
69691 + .mode = 0600,
69692 + .proc_handler = &proc_dointvec,
69693 + },
69694 +#endif
69695 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69696 + {
69697 + .procname = "socket_client",
69698 + .data = &grsec_enable_socket_client,
69699 + .maxlen = sizeof(int),
69700 + .mode = 0600,
69701 + .proc_handler = &proc_dointvec,
69702 + },
69703 + {
69704 + .procname = "socket_client_gid",
69705 + .data = &grsec_socket_client_gid,
69706 + .maxlen = sizeof(int),
69707 + .mode = 0600,
69708 + .proc_handler = &proc_dointvec,
69709 + },
69710 +#endif
69711 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69712 + {
69713 + .procname = "socket_server",
69714 + .data = &grsec_enable_socket_server,
69715 + .maxlen = sizeof(int),
69716 + .mode = 0600,
69717 + .proc_handler = &proc_dointvec,
69718 + },
69719 + {
69720 + .procname = "socket_server_gid",
69721 + .data = &grsec_socket_server_gid,
69722 + .maxlen = sizeof(int),
69723 + .mode = 0600,
69724 + .proc_handler = &proc_dointvec,
69725 + },
69726 +#endif
69727 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69728 + {
69729 + .procname = "audit_group",
69730 + .data = &grsec_enable_group,
69731 + .maxlen = sizeof(int),
69732 + .mode = 0600,
69733 + .proc_handler = &proc_dointvec,
69734 + },
69735 + {
69736 + .procname = "audit_gid",
69737 + .data = &grsec_audit_gid,
69738 + .maxlen = sizeof(int),
69739 + .mode = 0600,
69740 + .proc_handler = &proc_dointvec,
69741 + },
69742 +#endif
69743 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69744 + {
69745 + .procname = "audit_chdir",
69746 + .data = &grsec_enable_chdir,
69747 + .maxlen = sizeof(int),
69748 + .mode = 0600,
69749 + .proc_handler = &proc_dointvec,
69750 + },
69751 +#endif
69752 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69753 + {
69754 + .procname = "audit_mount",
69755 + .data = &grsec_enable_mount,
69756 + .maxlen = sizeof(int),
69757 + .mode = 0600,
69758 + .proc_handler = &proc_dointvec,
69759 + },
69760 +#endif
69761 +#ifdef CONFIG_GRKERNSEC_DMESG
69762 + {
69763 + .procname = "dmesg",
69764 + .data = &grsec_enable_dmesg,
69765 + .maxlen = sizeof(int),
69766 + .mode = 0600,
69767 + .proc_handler = &proc_dointvec,
69768 + },
69769 +#endif
69770 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69771 + {
69772 + .procname = "chroot_findtask",
69773 + .data = &grsec_enable_chroot_findtask,
69774 + .maxlen = sizeof(int),
69775 + .mode = 0600,
69776 + .proc_handler = &proc_dointvec,
69777 + },
69778 +#endif
69779 +#ifdef CONFIG_GRKERNSEC_RESLOG
69780 + {
69781 + .procname = "resource_logging",
69782 + .data = &grsec_resource_logging,
69783 + .maxlen = sizeof(int),
69784 + .mode = 0600,
69785 + .proc_handler = &proc_dointvec,
69786 + },
69787 +#endif
69788 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69789 + {
69790 + .procname = "audit_ptrace",
69791 + .data = &grsec_enable_audit_ptrace,
69792 + .maxlen = sizeof(int),
69793 + .mode = 0600,
69794 + .proc_handler = &proc_dointvec,
69795 + },
69796 +#endif
69797 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69798 + {
69799 + .procname = "harden_ptrace",
69800 + .data = &grsec_enable_harden_ptrace,
69801 + .maxlen = sizeof(int),
69802 + .mode = 0600,
69803 + .proc_handler = &proc_dointvec,
69804 + },
69805 +#endif
69806 + {
69807 + .procname = "grsec_lock",
69808 + .data = &grsec_lock,
69809 + .maxlen = sizeof(int),
69810 + .mode = 0600,
69811 + .proc_handler = &proc_dointvec,
69812 + },
69813 +#endif
69814 +#ifdef CONFIG_GRKERNSEC_ROFS
69815 + {
69816 + .procname = "romount_protect",
69817 + .data = &grsec_enable_rofs,
69818 + .maxlen = sizeof(int),
69819 + .mode = 0600,
69820 + .proc_handler = &proc_dointvec_minmax,
69821 + .extra1 = &one,
69822 + .extra2 = &one,
69823 + },
69824 +#endif
69825 + { }
69826 +};
69827 +#endif
69828 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
69829 new file mode 100644
69830 index 0000000..0dc13c3
69831 --- /dev/null
69832 +++ b/grsecurity/grsec_time.c
69833 @@ -0,0 +1,16 @@
69834 +#include <linux/kernel.h>
69835 +#include <linux/sched.h>
69836 +#include <linux/grinternal.h>
69837 +#include <linux/module.h>
69838 +
69839 +void
69840 +gr_log_timechange(void)
69841 +{
69842 +#ifdef CONFIG_GRKERNSEC_TIME
69843 + if (grsec_enable_time)
69844 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
69845 +#endif
69846 + return;
69847 +}
69848 +
69849 +EXPORT_SYMBOL(gr_log_timechange);
69850 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
69851 new file mode 100644
69852 index 0000000..ee57dcf
69853 --- /dev/null
69854 +++ b/grsecurity/grsec_tpe.c
69855 @@ -0,0 +1,73 @@
69856 +#include <linux/kernel.h>
69857 +#include <linux/sched.h>
69858 +#include <linux/file.h>
69859 +#include <linux/fs.h>
69860 +#include <linux/grinternal.h>
69861 +
69862 +extern int gr_acl_tpe_check(void);
69863 +
69864 +int
69865 +gr_tpe_allow(const struct file *file)
69866 +{
69867 +#ifdef CONFIG_GRKERNSEC
69868 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
69869 + const struct cred *cred = current_cred();
69870 + char *msg = NULL;
69871 + char *msg2 = NULL;
69872 +
69873 + // never restrict root
69874 + if (gr_is_global_root(cred->uid))
69875 + return 1;
69876 +
69877 + if (grsec_enable_tpe) {
69878 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69879 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
69880 + msg = "not being in trusted group";
69881 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
69882 + msg = "being in untrusted group";
69883 +#else
69884 + if (in_group_p(grsec_tpe_gid))
69885 + msg = "being in untrusted group";
69886 +#endif
69887 + }
69888 + if (!msg && gr_acl_tpe_check())
69889 + msg = "being in untrusted role";
69890 +
69891 + // not in any affected group/role
69892 + if (!msg)
69893 + goto next_check;
69894 +
69895 + if (gr_is_global_nonroot(inode->i_uid))
69896 + msg2 = "file in non-root-owned directory";
69897 + else if (inode->i_mode & S_IWOTH)
69898 + msg2 = "file in world-writable directory";
69899 + else if (inode->i_mode & S_IWGRP)
69900 + msg2 = "file in group-writable directory";
69901 +
69902 + if (msg && msg2) {
69903 + char fullmsg[70] = {0};
69904 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
69905 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
69906 + return 0;
69907 + }
69908 + msg = NULL;
69909 +next_check:
69910 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69911 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
69912 + return 1;
69913 +
69914 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
69915 + msg = "directory not owned by user";
69916 + else if (inode->i_mode & S_IWOTH)
69917 + msg = "file in world-writable directory";
69918 + else if (inode->i_mode & S_IWGRP)
69919 + msg = "file in group-writable directory";
69920 +
69921 + if (msg) {
69922 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
69923 + return 0;
69924 + }
69925 +#endif
69926 +#endif
69927 + return 1;
69928 +}
69929 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
69930 new file mode 100644
69931 index 0000000..9f7b1ac
69932 --- /dev/null
69933 +++ b/grsecurity/grsum.c
69934 @@ -0,0 +1,61 @@
69935 +#include <linux/err.h>
69936 +#include <linux/kernel.h>
69937 +#include <linux/sched.h>
69938 +#include <linux/mm.h>
69939 +#include <linux/scatterlist.h>
69940 +#include <linux/crypto.h>
69941 +#include <linux/gracl.h>
69942 +
69943 +
69944 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
69945 +#error "crypto and sha256 must be built into the kernel"
69946 +#endif
69947 +
69948 +int
69949 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
69950 +{
69951 + char *p;
69952 + struct crypto_hash *tfm;
69953 + struct hash_desc desc;
69954 + struct scatterlist sg;
69955 + unsigned char temp_sum[GR_SHA_LEN];
69956 + volatile int retval = 0;
69957 + volatile int dummy = 0;
69958 + unsigned int i;
69959 +
69960 + sg_init_table(&sg, 1);
69961 +
69962 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
69963 + if (IS_ERR(tfm)) {
69964 + /* should never happen, since sha256 should be built in */
69965 + return 1;
69966 + }
69967 +
69968 + desc.tfm = tfm;
69969 + desc.flags = 0;
69970 +
69971 + crypto_hash_init(&desc);
69972 +
69973 + p = salt;
69974 + sg_set_buf(&sg, p, GR_SALT_LEN);
69975 + crypto_hash_update(&desc, &sg, sg.length);
69976 +
69977 + p = entry->pw;
69978 + sg_set_buf(&sg, p, strlen(p));
69979 +
69980 + crypto_hash_update(&desc, &sg, sg.length);
69981 +
69982 + crypto_hash_final(&desc, temp_sum);
69983 +
69984 + memset(entry->pw, 0, GR_PW_LEN);
69985 +
69986 + for (i = 0; i < GR_SHA_LEN; i++)
69987 + if (sum[i] != temp_sum[i])
69988 + retval = 1;
69989 + else
69990 + dummy = 1; // waste a cycle
69991 +
69992 + crypto_free_hash(tfm);
69993 +
69994 + return retval;
69995 +}
69996 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
69997 index 77ff547..181834f 100644
69998 --- a/include/asm-generic/4level-fixup.h
69999 +++ b/include/asm-generic/4level-fixup.h
70000 @@ -13,8 +13,10 @@
70001 #define pmd_alloc(mm, pud, address) \
70002 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
70003 NULL: pmd_offset(pud, address))
70004 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
70005
70006 #define pud_alloc(mm, pgd, address) (pgd)
70007 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
70008 #define pud_offset(pgd, start) (pgd)
70009 #define pud_none(pud) 0
70010 #define pud_bad(pud) 0
70011 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
70012 index b7babf0..04ad282 100644
70013 --- a/include/asm-generic/atomic-long.h
70014 +++ b/include/asm-generic/atomic-long.h
70015 @@ -22,6 +22,12 @@
70016
70017 typedef atomic64_t atomic_long_t;
70018
70019 +#ifdef CONFIG_PAX_REFCOUNT
70020 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
70021 +#else
70022 +typedef atomic64_t atomic_long_unchecked_t;
70023 +#endif
70024 +
70025 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
70026
70027 static inline long atomic_long_read(atomic_long_t *l)
70028 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
70029 return (long)atomic64_read(v);
70030 }
70031
70032 +#ifdef CONFIG_PAX_REFCOUNT
70033 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
70034 +{
70035 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
70036 +
70037 + return (long)atomic64_read_unchecked(v);
70038 +}
70039 +#endif
70040 +
70041 static inline void atomic_long_set(atomic_long_t *l, long i)
70042 {
70043 atomic64_t *v = (atomic64_t *)l;
70044 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
70045 atomic64_set(v, i);
70046 }
70047
70048 +#ifdef CONFIG_PAX_REFCOUNT
70049 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
70050 +{
70051 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
70052 +
70053 + atomic64_set_unchecked(v, i);
70054 +}
70055 +#endif
70056 +
70057 static inline void atomic_long_inc(atomic_long_t *l)
70058 {
70059 atomic64_t *v = (atomic64_t *)l;
70060 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
70061 atomic64_inc(v);
70062 }
70063
70064 +#ifdef CONFIG_PAX_REFCOUNT
70065 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
70066 +{
70067 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
70068 +
70069 + atomic64_inc_unchecked(v);
70070 +}
70071 +#endif
70072 +
70073 static inline void atomic_long_dec(atomic_long_t *l)
70074 {
70075 atomic64_t *v = (atomic64_t *)l;
70076 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
70077 atomic64_dec(v);
70078 }
70079
70080 +#ifdef CONFIG_PAX_REFCOUNT
70081 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
70082 +{
70083 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
70084 +
70085 + atomic64_dec_unchecked(v);
70086 +}
70087 +#endif
70088 +
70089 static inline void atomic_long_add(long i, atomic_long_t *l)
70090 {
70091 atomic64_t *v = (atomic64_t *)l;
70092 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
70093 atomic64_add(i, v);
70094 }
70095
70096 +#ifdef CONFIG_PAX_REFCOUNT
70097 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
70098 +{
70099 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
70100 +
70101 + atomic64_add_unchecked(i, v);
70102 +}
70103 +#endif
70104 +
70105 static inline void atomic_long_sub(long i, atomic_long_t *l)
70106 {
70107 atomic64_t *v = (atomic64_t *)l;
70108 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
70109 atomic64_sub(i, v);
70110 }
70111
70112 +#ifdef CONFIG_PAX_REFCOUNT
70113 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
70114 +{
70115 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
70116 +
70117 + atomic64_sub_unchecked(i, v);
70118 +}
70119 +#endif
70120 +
70121 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
70122 {
70123 atomic64_t *v = (atomic64_t *)l;
70124 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
70125 return (long)atomic64_add_return(i, v);
70126 }
70127
70128 +#ifdef CONFIG_PAX_REFCOUNT
70129 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
70130 +{
70131 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
70132 +
70133 + return (long)atomic64_add_return_unchecked(i, v);
70134 +}
70135 +#endif
70136 +
70137 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
70138 {
70139 atomic64_t *v = (atomic64_t *)l;
70140 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
70141 return (long)atomic64_inc_return(v);
70142 }
70143
70144 +#ifdef CONFIG_PAX_REFCOUNT
70145 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
70146 +{
70147 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
70148 +
70149 + return (long)atomic64_inc_return_unchecked(v);
70150 +}
70151 +#endif
70152 +
70153 static inline long atomic_long_dec_return(atomic_long_t *l)
70154 {
70155 atomic64_t *v = (atomic64_t *)l;
70156 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
70157
70158 typedef atomic_t atomic_long_t;
70159
70160 +#ifdef CONFIG_PAX_REFCOUNT
70161 +typedef atomic_unchecked_t atomic_long_unchecked_t;
70162 +#else
70163 +typedef atomic_t atomic_long_unchecked_t;
70164 +#endif
70165 +
70166 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
70167 static inline long atomic_long_read(atomic_long_t *l)
70168 {
70169 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
70170 return (long)atomic_read(v);
70171 }
70172
70173 +#ifdef CONFIG_PAX_REFCOUNT
70174 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
70175 +{
70176 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70177 +
70178 + return (long)atomic_read_unchecked(v);
70179 +}
70180 +#endif
70181 +
70182 static inline void atomic_long_set(atomic_long_t *l, long i)
70183 {
70184 atomic_t *v = (atomic_t *)l;
70185 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
70186 atomic_set(v, i);
70187 }
70188
70189 +#ifdef CONFIG_PAX_REFCOUNT
70190 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
70191 +{
70192 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70193 +
70194 + atomic_set_unchecked(v, i);
70195 +}
70196 +#endif
70197 +
70198 static inline void atomic_long_inc(atomic_long_t *l)
70199 {
70200 atomic_t *v = (atomic_t *)l;
70201 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
70202 atomic_inc(v);
70203 }
70204
70205 +#ifdef CONFIG_PAX_REFCOUNT
70206 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
70207 +{
70208 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70209 +
70210 + atomic_inc_unchecked(v);
70211 +}
70212 +#endif
70213 +
70214 static inline void atomic_long_dec(atomic_long_t *l)
70215 {
70216 atomic_t *v = (atomic_t *)l;
70217 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
70218 atomic_dec(v);
70219 }
70220
70221 +#ifdef CONFIG_PAX_REFCOUNT
70222 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
70223 +{
70224 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70225 +
70226 + atomic_dec_unchecked(v);
70227 +}
70228 +#endif
70229 +
70230 static inline void atomic_long_add(long i, atomic_long_t *l)
70231 {
70232 atomic_t *v = (atomic_t *)l;
70233 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
70234 atomic_add(i, v);
70235 }
70236
70237 +#ifdef CONFIG_PAX_REFCOUNT
70238 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
70239 +{
70240 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70241 +
70242 + atomic_add_unchecked(i, v);
70243 +}
70244 +#endif
70245 +
70246 static inline void atomic_long_sub(long i, atomic_long_t *l)
70247 {
70248 atomic_t *v = (atomic_t *)l;
70249 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
70250 atomic_sub(i, v);
70251 }
70252
70253 +#ifdef CONFIG_PAX_REFCOUNT
70254 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
70255 +{
70256 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70257 +
70258 + atomic_sub_unchecked(i, v);
70259 +}
70260 +#endif
70261 +
70262 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
70263 {
70264 atomic_t *v = (atomic_t *)l;
70265 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
70266 return (long)atomic_add_return(i, v);
70267 }
70268
70269 +#ifdef CONFIG_PAX_REFCOUNT
70270 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
70271 +{
70272 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70273 +
70274 + return (long)atomic_add_return_unchecked(i, v);
70275 +}
70276 +
70277 +#endif
70278 +
70279 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
70280 {
70281 atomic_t *v = (atomic_t *)l;
70282 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
70283 return (long)atomic_inc_return(v);
70284 }
70285
70286 +#ifdef CONFIG_PAX_REFCOUNT
70287 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
70288 +{
70289 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70290 +
70291 + return (long)atomic_inc_return_unchecked(v);
70292 +}
70293 +#endif
70294 +
70295 static inline long atomic_long_dec_return(atomic_long_t *l)
70296 {
70297 atomic_t *v = (atomic_t *)l;
70298 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
70299
70300 #endif /* BITS_PER_LONG == 64 */
70301
70302 +#ifdef CONFIG_PAX_REFCOUNT
70303 +static inline void pax_refcount_needs_these_functions(void)
70304 +{
70305 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
70306 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
70307 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
70308 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
70309 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
70310 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
70311 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
70312 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
70313 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
70314 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
70315 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
70316 +#ifdef CONFIG_X86
70317 + atomic_clear_mask_unchecked(0, NULL);
70318 + atomic_set_mask_unchecked(0, NULL);
70319 +#endif
70320 +
70321 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
70322 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
70323 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
70324 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
70325 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
70326 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
70327 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
70328 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
70329 +}
70330 +#else
70331 +#define atomic_read_unchecked(v) atomic_read(v)
70332 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
70333 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
70334 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
70335 +#define atomic_inc_unchecked(v) atomic_inc(v)
70336 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
70337 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
70338 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
70339 +#define atomic_dec_unchecked(v) atomic_dec(v)
70340 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
70341 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
70342 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
70343 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
70344 +
70345 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
70346 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
70347 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
70348 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
70349 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
70350 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
70351 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
70352 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
70353 +#endif
70354 +
70355 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
70356 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
70357 index 33bd2de..f31bff97 100644
70358 --- a/include/asm-generic/atomic.h
70359 +++ b/include/asm-generic/atomic.h
70360 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
70361 * Atomically clears the bits set in @mask from @v
70362 */
70363 #ifndef atomic_clear_mask
70364 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
70365 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
70366 {
70367 unsigned long flags;
70368
70369 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
70370 index b18ce4f..2ee2843 100644
70371 --- a/include/asm-generic/atomic64.h
70372 +++ b/include/asm-generic/atomic64.h
70373 @@ -16,6 +16,8 @@ typedef struct {
70374 long long counter;
70375 } atomic64_t;
70376
70377 +typedef atomic64_t atomic64_unchecked_t;
70378 +
70379 #define ATOMIC64_INIT(i) { (i) }
70380
70381 extern long long atomic64_read(const atomic64_t *v);
70382 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
70383 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
70384 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
70385
70386 +#define atomic64_read_unchecked(v) atomic64_read(v)
70387 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
70388 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
70389 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
70390 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
70391 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
70392 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
70393 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
70394 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
70395 +
70396 #endif /* _ASM_GENERIC_ATOMIC64_H */
70397 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
70398 index 1bfcfe5..e04c5c9 100644
70399 --- a/include/asm-generic/cache.h
70400 +++ b/include/asm-generic/cache.h
70401 @@ -6,7 +6,7 @@
70402 * cache lines need to provide their own cache.h.
70403 */
70404
70405 -#define L1_CACHE_SHIFT 5
70406 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
70407 +#define L1_CACHE_SHIFT 5UL
70408 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
70409
70410 #endif /* __ASM_GENERIC_CACHE_H */
70411 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
70412 index 0d68a1e..b74a761 100644
70413 --- a/include/asm-generic/emergency-restart.h
70414 +++ b/include/asm-generic/emergency-restart.h
70415 @@ -1,7 +1,7 @@
70416 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
70417 #define _ASM_GENERIC_EMERGENCY_RESTART_H
70418
70419 -static inline void machine_emergency_restart(void)
70420 +static inline __noreturn void machine_emergency_restart(void)
70421 {
70422 machine_restart(NULL);
70423 }
70424 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
70425 index 90f99c7..00ce236 100644
70426 --- a/include/asm-generic/kmap_types.h
70427 +++ b/include/asm-generic/kmap_types.h
70428 @@ -2,9 +2,9 @@
70429 #define _ASM_GENERIC_KMAP_TYPES_H
70430
70431 #ifdef __WITH_KM_FENCE
70432 -# define KM_TYPE_NR 41
70433 +# define KM_TYPE_NR 42
70434 #else
70435 -# define KM_TYPE_NR 20
70436 +# define KM_TYPE_NR 21
70437 #endif
70438
70439 #endif
70440 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
70441 index 9ceb03b..62b0b8f 100644
70442 --- a/include/asm-generic/local.h
70443 +++ b/include/asm-generic/local.h
70444 @@ -23,24 +23,37 @@ typedef struct
70445 atomic_long_t a;
70446 } local_t;
70447
70448 +typedef struct {
70449 + atomic_long_unchecked_t a;
70450 +} local_unchecked_t;
70451 +
70452 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
70453
70454 #define local_read(l) atomic_long_read(&(l)->a)
70455 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
70456 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
70457 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
70458 #define local_inc(l) atomic_long_inc(&(l)->a)
70459 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
70460 #define local_dec(l) atomic_long_dec(&(l)->a)
70461 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
70462 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
70463 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
70464 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
70465 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
70466
70467 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
70468 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
70469 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
70470 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
70471 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
70472 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
70473 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
70474 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
70475 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
70476
70477 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
70478 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
70479 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
70480 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
70481 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
70482 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
70483 index 725612b..9cc513a 100644
70484 --- a/include/asm-generic/pgtable-nopmd.h
70485 +++ b/include/asm-generic/pgtable-nopmd.h
70486 @@ -1,14 +1,19 @@
70487 #ifndef _PGTABLE_NOPMD_H
70488 #define _PGTABLE_NOPMD_H
70489
70490 -#ifndef __ASSEMBLY__
70491 -
70492 #include <asm-generic/pgtable-nopud.h>
70493
70494 -struct mm_struct;
70495 -
70496 #define __PAGETABLE_PMD_FOLDED
70497
70498 +#define PMD_SHIFT PUD_SHIFT
70499 +#define PTRS_PER_PMD 1
70500 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
70501 +#define PMD_MASK (~(PMD_SIZE-1))
70502 +
70503 +#ifndef __ASSEMBLY__
70504 +
70505 +struct mm_struct;
70506 +
70507 /*
70508 * Having the pmd type consist of a pud gets the size right, and allows
70509 * us to conceptually access the pud entry that this pmd is folded into
70510 @@ -16,11 +21,6 @@ struct mm_struct;
70511 */
70512 typedef struct { pud_t pud; } pmd_t;
70513
70514 -#define PMD_SHIFT PUD_SHIFT
70515 -#define PTRS_PER_PMD 1
70516 -#define PMD_SIZE (1UL << PMD_SHIFT)
70517 -#define PMD_MASK (~(PMD_SIZE-1))
70518 -
70519 /*
70520 * The "pud_xxx()" functions here are trivial for a folded two-level
70521 * setup: the pmd is never bad, and a pmd always exists (as it's folded
70522 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
70523 index 810431d..0ec4804f 100644
70524 --- a/include/asm-generic/pgtable-nopud.h
70525 +++ b/include/asm-generic/pgtable-nopud.h
70526 @@ -1,10 +1,15 @@
70527 #ifndef _PGTABLE_NOPUD_H
70528 #define _PGTABLE_NOPUD_H
70529
70530 -#ifndef __ASSEMBLY__
70531 -
70532 #define __PAGETABLE_PUD_FOLDED
70533
70534 +#define PUD_SHIFT PGDIR_SHIFT
70535 +#define PTRS_PER_PUD 1
70536 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
70537 +#define PUD_MASK (~(PUD_SIZE-1))
70538 +
70539 +#ifndef __ASSEMBLY__
70540 +
70541 /*
70542 * Having the pud type consist of a pgd gets the size right, and allows
70543 * us to conceptually access the pgd entry that this pud is folded into
70544 @@ -12,11 +17,6 @@
70545 */
70546 typedef struct { pgd_t pgd; } pud_t;
70547
70548 -#define PUD_SHIFT PGDIR_SHIFT
70549 -#define PTRS_PER_PUD 1
70550 -#define PUD_SIZE (1UL << PUD_SHIFT)
70551 -#define PUD_MASK (~(PUD_SIZE-1))
70552 -
70553 /*
70554 * The "pgd_xxx()" functions here are trivial for a folded two-level
70555 * setup: the pud is never bad, and a pud always exists (as it's folded
70556 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
70557 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
70558
70559 #define pgd_populate(mm, pgd, pud) do { } while (0)
70560 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
70561 /*
70562 * (puds are folded into pgds so this doesn't get actually called,
70563 * but the define is needed for a generic inline function.)
70564 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
70565 index a59ff51..2594a70 100644
70566 --- a/include/asm-generic/pgtable.h
70567 +++ b/include/asm-generic/pgtable.h
70568 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
70569 }
70570 #endif /* CONFIG_NUMA_BALANCING */
70571
70572 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
70573 +static inline unsigned long pax_open_kernel(void) { return 0; }
70574 +#endif
70575 +
70576 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
70577 +static inline unsigned long pax_close_kernel(void) { return 0; }
70578 +#endif
70579 +
70580 #endif /* CONFIG_MMU */
70581
70582 #endif /* !__ASSEMBLY__ */
70583 diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
70584 index 13821c3..5672d7e 100644
70585 --- a/include/asm-generic/tlb.h
70586 +++ b/include/asm-generic/tlb.h
70587 @@ -112,7 +112,7 @@ struct mmu_gather {
70588
70589 #define HAVE_GENERIC_MMU_GATHER
70590
70591 -void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm);
70592 +void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end);
70593 void tlb_flush_mmu(struct mmu_gather *tlb);
70594 void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start,
70595 unsigned long end);
70596 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
70597 index c184aa8..d049942 100644
70598 --- a/include/asm-generic/uaccess.h
70599 +++ b/include/asm-generic/uaccess.h
70600 @@ -343,4 +343,12 @@ clear_user(void __user *to, unsigned long n)
70601 return __clear_user(to, n);
70602 }
70603
70604 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
70605 +//static inline unsigned long pax_open_userland(void) { return 0; }
70606 +#endif
70607 +
70608 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
70609 +//static inline unsigned long pax_close_userland(void) { return 0; }
70610 +#endif
70611 +
70612 #endif /* __ASM_GENERIC_UACCESS_H */
70613 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
70614 index eb58d2d..df131bf 100644
70615 --- a/include/asm-generic/vmlinux.lds.h
70616 +++ b/include/asm-generic/vmlinux.lds.h
70617 @@ -239,6 +239,7 @@
70618 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
70619 VMLINUX_SYMBOL(__start_rodata) = .; \
70620 *(.rodata) *(.rodata.*) \
70621 + *(.data..read_only) \
70622 *(__vermagic) /* Kernel version magic */ \
70623 . = ALIGN(8); \
70624 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
70625 @@ -749,17 +750,18 @@
70626 * section in the linker script will go there too. @phdr should have
70627 * a leading colon.
70628 *
70629 - * Note that this macros defines __per_cpu_load as an absolute symbol.
70630 + * Note that this macros defines per_cpu_load as an absolute symbol.
70631 * If there is no need to put the percpu section at a predetermined
70632 * address, use PERCPU_SECTION.
70633 */
70634 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
70635 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
70636 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
70637 + per_cpu_load = .; \
70638 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
70639 - LOAD_OFFSET) { \
70640 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
70641 PERCPU_INPUT(cacheline) \
70642 } phdr \
70643 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
70644 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
70645
70646 /**
70647 * PERCPU_SECTION - define output section for percpu area, simple version
70648 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
70649 index 418d270..bfd2794 100644
70650 --- a/include/crypto/algapi.h
70651 +++ b/include/crypto/algapi.h
70652 @@ -34,7 +34,7 @@ struct crypto_type {
70653 unsigned int maskclear;
70654 unsigned int maskset;
70655 unsigned int tfmsize;
70656 -};
70657 +} __do_const;
70658
70659 struct crypto_instance {
70660 struct crypto_alg alg;
70661 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
70662 index 63d17ee..716de2b 100644
70663 --- a/include/drm/drmP.h
70664 +++ b/include/drm/drmP.h
70665 @@ -72,6 +72,7 @@
70666 #include <linux/workqueue.h>
70667 #include <linux/poll.h>
70668 #include <asm/pgalloc.h>
70669 +#include <asm/local.h>
70670 #include <drm/drm.h>
70671 #include <drm/drm_sarea.h>
70672
70673 @@ -296,10 +297,12 @@ do { \
70674 * \param cmd command.
70675 * \param arg argument.
70676 */
70677 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
70678 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
70679 + struct drm_file *file_priv);
70680 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
70681 struct drm_file *file_priv);
70682
70683 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
70684 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
70685 unsigned long arg);
70686
70687 #define DRM_IOCTL_NR(n) _IOC_NR(n)
70688 @@ -314,10 +317,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
70689 struct drm_ioctl_desc {
70690 unsigned int cmd;
70691 int flags;
70692 - drm_ioctl_t *func;
70693 + drm_ioctl_t func;
70694 unsigned int cmd_drv;
70695 const char *name;
70696 -};
70697 +} __do_const;
70698
70699 /**
70700 * Creates a driver or general drm_ioctl_desc array entry for the given
70701 @@ -1015,7 +1018,7 @@ struct drm_info_list {
70702 int (*show)(struct seq_file*, void*); /** show callback */
70703 u32 driver_features; /**< Required driver features for this entry */
70704 void *data;
70705 -};
70706 +} __do_const;
70707
70708 /**
70709 * debugfs node structure. This structure represents a debugfs file.
70710 @@ -1088,7 +1091,7 @@ struct drm_device {
70711
70712 /** \name Usage Counters */
70713 /*@{ */
70714 - int open_count; /**< Outstanding files open */
70715 + local_t open_count; /**< Outstanding files open */
70716 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
70717 atomic_t vma_count; /**< Outstanding vma areas open */
70718 int buf_use; /**< Buffers in use -- cannot alloc */
70719 @@ -1099,7 +1102,7 @@ struct drm_device {
70720 /*@{ */
70721 unsigned long counters;
70722 enum drm_stat_type types[15];
70723 - atomic_t counts[15];
70724 + atomic_unchecked_t counts[15];
70725 /*@} */
70726
70727 struct list_head filelist;
70728 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
70729 index f43d556..94d9343 100644
70730 --- a/include/drm/drm_crtc_helper.h
70731 +++ b/include/drm/drm_crtc_helper.h
70732 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
70733 struct drm_connector *connector);
70734 /* disable encoder when not in use - more explicit than dpms off */
70735 void (*disable)(struct drm_encoder *encoder);
70736 -};
70737 +} __no_const;
70738
70739 /**
70740 * drm_connector_helper_funcs - helper operations for connectors
70741 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
70742 index 72dcbe8..8db58d7 100644
70743 --- a/include/drm/ttm/ttm_memory.h
70744 +++ b/include/drm/ttm/ttm_memory.h
70745 @@ -48,7 +48,7 @@
70746
70747 struct ttm_mem_shrink {
70748 int (*do_shrink) (struct ttm_mem_shrink *);
70749 -};
70750 +} __no_const;
70751
70752 /**
70753 * struct ttm_mem_global - Global memory accounting structure.
70754 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
70755 index 4b840e8..155d235 100644
70756 --- a/include/keys/asymmetric-subtype.h
70757 +++ b/include/keys/asymmetric-subtype.h
70758 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
70759 /* Verify the signature on a key of this subtype (optional) */
70760 int (*verify_signature)(const struct key *key,
70761 const struct public_key_signature *sig);
70762 -};
70763 +} __do_const;
70764
70765 /**
70766 * asymmetric_key_subtype - Get the subtype from an asymmetric key
70767 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
70768 index c1da539..1dcec55 100644
70769 --- a/include/linux/atmdev.h
70770 +++ b/include/linux/atmdev.h
70771 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
70772 #endif
70773
70774 struct k_atm_aal_stats {
70775 -#define __HANDLE_ITEM(i) atomic_t i
70776 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
70777 __AAL_STAT_ITEMS
70778 #undef __HANDLE_ITEM
70779 };
70780 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
70781 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
70782 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
70783 struct module *owner;
70784 -};
70785 +} __do_const ;
70786
70787 struct atmphy_ops {
70788 int (*start)(struct atm_dev *dev);
70789 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
70790 index 70cf138..0418ee2 100644
70791 --- a/include/linux/binfmts.h
70792 +++ b/include/linux/binfmts.h
70793 @@ -73,8 +73,10 @@ struct linux_binfmt {
70794 int (*load_binary)(struct linux_binprm *);
70795 int (*load_shlib)(struct file *);
70796 int (*core_dump)(struct coredump_params *cprm);
70797 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
70798 + void (*handle_mmap)(struct file *);
70799 unsigned long min_coredump; /* minimal dump size */
70800 -};
70801 +} __do_const;
70802
70803 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
70804
70805 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
70806 index 2fdb4a4..54aad7e 100644
70807 --- a/include/linux/blkdev.h
70808 +++ b/include/linux/blkdev.h
70809 @@ -1526,7 +1526,7 @@ struct block_device_operations {
70810 /* this callback is with swap_lock and sometimes page table lock held */
70811 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
70812 struct module *owner;
70813 -};
70814 +} __do_const;
70815
70816 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
70817 unsigned long);
70818 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
70819 index 7c2e030..b72475d 100644
70820 --- a/include/linux/blktrace_api.h
70821 +++ b/include/linux/blktrace_api.h
70822 @@ -23,7 +23,7 @@ struct blk_trace {
70823 struct dentry *dir;
70824 struct dentry *dropped_file;
70825 struct dentry *msg_file;
70826 - atomic_t dropped;
70827 + atomic_unchecked_t dropped;
70828 };
70829
70830 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
70831 diff --git a/include/linux/cache.h b/include/linux/cache.h
70832 index 4c57065..4307975 100644
70833 --- a/include/linux/cache.h
70834 +++ b/include/linux/cache.h
70835 @@ -16,6 +16,10 @@
70836 #define __read_mostly
70837 #endif
70838
70839 +#ifndef __read_only
70840 +#define __read_only __read_mostly
70841 +#endif
70842 +
70843 #ifndef ____cacheline_aligned
70844 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
70845 #endif
70846 diff --git a/include/linux/capability.h b/include/linux/capability.h
70847 index d9a4f7f4..19f77d6 100644
70848 --- a/include/linux/capability.h
70849 +++ b/include/linux/capability.h
70850 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
70851 extern bool nsown_capable(int cap);
70852 extern bool inode_capable(const struct inode *inode, int cap);
70853 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
70854 +extern bool capable_nolog(int cap);
70855 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
70856 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
70857
70858 /* audit system wants to get cap info from files as well */
70859 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
70860
70861 +extern int is_privileged_binary(const struct dentry *dentry);
70862 +
70863 #endif /* !_LINUX_CAPABILITY_H */
70864 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
70865 index 8609d57..86e4d79 100644
70866 --- a/include/linux/cdrom.h
70867 +++ b/include/linux/cdrom.h
70868 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
70869
70870 /* driver specifications */
70871 const int capability; /* capability flags */
70872 - int n_minors; /* number of active minor devices */
70873 /* handle uniform packets for scsi type devices (scsi,atapi) */
70874 int (*generic_packet) (struct cdrom_device_info *,
70875 struct packet_command *);
70876 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
70877 index 4ce9056..86caac6 100644
70878 --- a/include/linux/cleancache.h
70879 +++ b/include/linux/cleancache.h
70880 @@ -31,7 +31,7 @@ struct cleancache_ops {
70881 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
70882 void (*invalidate_inode)(int, struct cleancache_filekey);
70883 void (*invalidate_fs)(int);
70884 -};
70885 +} __no_const;
70886
70887 extern struct cleancache_ops *
70888 cleancache_register_ops(struct cleancache_ops *ops);
70889 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
70890 index 1186098..f87e53d 100644
70891 --- a/include/linux/clk-provider.h
70892 +++ b/include/linux/clk-provider.h
70893 @@ -132,6 +132,7 @@ struct clk_ops {
70894 unsigned long);
70895 void (*init)(struct clk_hw *hw);
70896 };
70897 +typedef struct clk_ops __no_const clk_ops_no_const;
70898
70899 /**
70900 * struct clk_init_data - holds init data that's common to all clocks and is
70901 diff --git a/include/linux/compat.h b/include/linux/compat.h
70902 index 7f0c1dd..206ac34 100644
70903 --- a/include/linux/compat.h
70904 +++ b/include/linux/compat.h
70905 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
70906 compat_size_t __user *len_ptr);
70907
70908 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
70909 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
70910 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
70911 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
70912 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
70913 compat_ssize_t msgsz, int msgflg);
70914 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
70915 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
70916 compat_ulong_t addr, compat_ulong_t data);
70917 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
70918 - compat_long_t addr, compat_long_t data);
70919 + compat_ulong_t addr, compat_ulong_t data);
70920
70921 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
70922 /*
70923 @@ -669,6 +669,7 @@ asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
70924
70925 int compat_restore_altstack(const compat_stack_t __user *uss);
70926 int __compat_save_altstack(compat_stack_t __user *, unsigned long);
70927 +void __compat_save_altstack_ex(compat_stack_t __user *, unsigned long);
70928
70929 asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
70930 struct compat_timespec __user *interval);
70931 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
70932 index 842de22..7f3a41f 100644
70933 --- a/include/linux/compiler-gcc4.h
70934 +++ b/include/linux/compiler-gcc4.h
70935 @@ -39,9 +39,29 @@
70936 # define __compiletime_warning(message) __attribute__((warning(message)))
70937 # define __compiletime_error(message) __attribute__((error(message)))
70938 #endif /* __CHECKER__ */
70939 +
70940 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
70941 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
70942 +#define __bos0(ptr) __bos((ptr), 0)
70943 +#define __bos1(ptr) __bos((ptr), 1)
70944 #endif /* GCC_VERSION >= 40300 */
70945
70946 #if GCC_VERSION >= 40500
70947 +
70948 +#ifdef CONSTIFY_PLUGIN
70949 +#define __no_const __attribute__((no_const))
70950 +#define __do_const __attribute__((do_const))
70951 +#endif
70952 +
70953 +#ifdef SIZE_OVERFLOW_PLUGIN
70954 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
70955 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
70956 +#endif
70957 +
70958 +#ifdef LATENT_ENTROPY_PLUGIN
70959 +#define __latent_entropy __attribute__((latent_entropy))
70960 +#endif
70961 +
70962 /*
70963 * Mark a position in code as unreachable. This can be used to
70964 * suppress control flow warnings after asm blocks that transfer
70965 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
70966 index 92669cd..1771a15 100644
70967 --- a/include/linux/compiler.h
70968 +++ b/include/linux/compiler.h
70969 @@ -5,11 +5,14 @@
70970
70971 #ifdef __CHECKER__
70972 # define __user __attribute__((noderef, address_space(1)))
70973 +# define __force_user __force __user
70974 # define __kernel __attribute__((address_space(0)))
70975 +# define __force_kernel __force __kernel
70976 # define __safe __attribute__((safe))
70977 # define __force __attribute__((force))
70978 # define __nocast __attribute__((nocast))
70979 # define __iomem __attribute__((noderef, address_space(2)))
70980 +# define __force_iomem __force __iomem
70981 # define __must_hold(x) __attribute__((context(x,1,1)))
70982 # define __acquires(x) __attribute__((context(x,0,1)))
70983 # define __releases(x) __attribute__((context(x,1,0)))
70984 @@ -17,20 +20,37 @@
70985 # define __release(x) __context__(x,-1)
70986 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
70987 # define __percpu __attribute__((noderef, address_space(3)))
70988 +# define __force_percpu __force __percpu
70989 #ifdef CONFIG_SPARSE_RCU_POINTER
70990 # define __rcu __attribute__((noderef, address_space(4)))
70991 +# define __force_rcu __force __rcu
70992 #else
70993 # define __rcu
70994 +# define __force_rcu
70995 #endif
70996 extern void __chk_user_ptr(const volatile void __user *);
70997 extern void __chk_io_ptr(const volatile void __iomem *);
70998 #else
70999 -# define __user
71000 -# define __kernel
71001 +# ifdef CHECKER_PLUGIN
71002 +//# define __user
71003 +//# define __force_user
71004 +//# define __kernel
71005 +//# define __force_kernel
71006 +# else
71007 +# ifdef STRUCTLEAK_PLUGIN
71008 +# define __user __attribute__((user))
71009 +# else
71010 +# define __user
71011 +# endif
71012 +# define __force_user
71013 +# define __kernel
71014 +# define __force_kernel
71015 +# endif
71016 # define __safe
71017 # define __force
71018 # define __nocast
71019 # define __iomem
71020 +# define __force_iomem
71021 # define __chk_user_ptr(x) (void)0
71022 # define __chk_io_ptr(x) (void)0
71023 # define __builtin_warning(x, y...) (1)
71024 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
71025 # define __release(x) (void)0
71026 # define __cond_lock(x,c) (c)
71027 # define __percpu
71028 +# define __force_percpu
71029 # define __rcu
71030 +# define __force_rcu
71031 #endif
71032
71033 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
71034 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
71035 # define __attribute_const__ /* unimplemented */
71036 #endif
71037
71038 +#ifndef __no_const
71039 +# define __no_const
71040 +#endif
71041 +
71042 +#ifndef __do_const
71043 +# define __do_const
71044 +#endif
71045 +
71046 +#ifndef __size_overflow
71047 +# define __size_overflow(...)
71048 +#endif
71049 +
71050 +#ifndef __intentional_overflow
71051 +# define __intentional_overflow(...)
71052 +#endif
71053 +
71054 +#ifndef __latent_entropy
71055 +# define __latent_entropy
71056 +#endif
71057 +
71058 /*
71059 * Tell gcc if a function is cold. The compiler will assume any path
71060 * directly leading to the call is unlikely.
71061 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
71062 #define __cold
71063 #endif
71064
71065 +#ifndef __alloc_size
71066 +#define __alloc_size(...)
71067 +#endif
71068 +
71069 +#ifndef __bos
71070 +#define __bos(ptr, arg)
71071 +#endif
71072 +
71073 +#ifndef __bos0
71074 +#define __bos0(ptr)
71075 +#endif
71076 +
71077 +#ifndef __bos1
71078 +#define __bos1(ptr)
71079 +#endif
71080 +
71081 /* Simple shorthand for a section definition */
71082 #ifndef __section
71083 # define __section(S) __attribute__ ((__section__(#S)))
71084 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
71085 * use is to mediate communication between process-level code and irq/NMI
71086 * handlers, all running on the same CPU.
71087 */
71088 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
71089 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
71090 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
71091
71092 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
71093 #ifdef CONFIG_KPROBES
71094 diff --git a/include/linux/completion.h b/include/linux/completion.h
71095 index 33f0280..35c6568 100644
71096 --- a/include/linux/completion.h
71097 +++ b/include/linux/completion.h
71098 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
71099 extern void wait_for_completion(struct completion *);
71100 extern void wait_for_completion_io(struct completion *);
71101 extern int wait_for_completion_interruptible(struct completion *x);
71102 -extern int wait_for_completion_killable(struct completion *x);
71103 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
71104 extern unsigned long wait_for_completion_timeout(struct completion *x,
71105 unsigned long timeout);
71106 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
71107 unsigned long timeout);
71108 extern long wait_for_completion_interruptible_timeout(
71109 - struct completion *x, unsigned long timeout);
71110 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
71111 extern long wait_for_completion_killable_timeout(
71112 - struct completion *x, unsigned long timeout);
71113 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
71114 extern bool try_wait_for_completion(struct completion *x);
71115 extern bool completion_done(struct completion *x);
71116
71117 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
71118 index 34025df..d94bbbc 100644
71119 --- a/include/linux/configfs.h
71120 +++ b/include/linux/configfs.h
71121 @@ -125,7 +125,7 @@ struct configfs_attribute {
71122 const char *ca_name;
71123 struct module *ca_owner;
71124 umode_t ca_mode;
71125 -};
71126 +} __do_const;
71127
71128 /*
71129 * Users often need to create attribute structures for their configurable
71130 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
71131 index 9f3c7e8..a18c7b6 100644
71132 --- a/include/linux/cpu.h
71133 +++ b/include/linux/cpu.h
71134 @@ -115,7 +115,7 @@ enum {
71135 /* Need to know about CPUs going up/down? */
71136 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
71137 #define cpu_notifier(fn, pri) { \
71138 - static struct notifier_block fn##_nb __cpuinitdata = \
71139 + static struct notifier_block fn##_nb = \
71140 { .notifier_call = fn, .priority = pri }; \
71141 register_cpu_notifier(&fn##_nb); \
71142 }
71143 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
71144 index 037d36a..ca5fe6e 100644
71145 --- a/include/linux/cpufreq.h
71146 +++ b/include/linux/cpufreq.h
71147 @@ -262,7 +262,7 @@ struct cpufreq_driver {
71148 int (*suspend) (struct cpufreq_policy *policy);
71149 int (*resume) (struct cpufreq_policy *policy);
71150 struct freq_attr **attr;
71151 -};
71152 +} __do_const;
71153
71154 /* flags */
71155
71156 @@ -321,6 +321,7 @@ struct global_attr {
71157 ssize_t (*store)(struct kobject *a, struct attribute *b,
71158 const char *c, size_t count);
71159 };
71160 +typedef struct global_attr __no_const global_attr_no_const;
71161
71162 #define define_one_global_ro(_name) \
71163 static struct global_attr _name = \
71164 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
71165 index 8f04062..900239a 100644
71166 --- a/include/linux/cpuidle.h
71167 +++ b/include/linux/cpuidle.h
71168 @@ -52,7 +52,8 @@ struct cpuidle_state {
71169 int index);
71170
71171 int (*enter_dead) (struct cpuidle_device *dev, int index);
71172 -};
71173 +} __do_const;
71174 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
71175
71176 /* Idle State Flags */
71177 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
71178 @@ -191,7 +192,7 @@ struct cpuidle_governor {
71179 void (*reflect) (struct cpuidle_device *dev, int index);
71180
71181 struct module *owner;
71182 -};
71183 +} __do_const;
71184
71185 #ifdef CONFIG_CPU_IDLE
71186
71187 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
71188 index d08e4d2..95fad61 100644
71189 --- a/include/linux/cpumask.h
71190 +++ b/include/linux/cpumask.h
71191 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
71192 }
71193
71194 /* Valid inputs for n are -1 and 0. */
71195 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
71196 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
71197 {
71198 return n+1;
71199 }
71200
71201 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
71202 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
71203 {
71204 return n+1;
71205 }
71206
71207 -static inline unsigned int cpumask_next_and(int n,
71208 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
71209 const struct cpumask *srcp,
71210 const struct cpumask *andp)
71211 {
71212 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
71213 *
71214 * Returns >= nr_cpu_ids if no further cpus set.
71215 */
71216 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
71217 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
71218 {
71219 /* -1 is a legal arg here. */
71220 if (n != -1)
71221 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
71222 *
71223 * Returns >= nr_cpu_ids if no further cpus unset.
71224 */
71225 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
71226 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
71227 {
71228 /* -1 is a legal arg here. */
71229 if (n != -1)
71230 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
71231 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
71232 }
71233
71234 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
71235 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
71236 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
71237
71238 /**
71239 diff --git a/include/linux/cred.h b/include/linux/cred.h
71240 index 04421e8..6bce4ef 100644
71241 --- a/include/linux/cred.h
71242 +++ b/include/linux/cred.h
71243 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
71244 static inline void validate_process_creds(void)
71245 {
71246 }
71247 +static inline void validate_task_creds(struct task_struct *task)
71248 +{
71249 +}
71250 #endif
71251
71252 /**
71253 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
71254 index b92eadf..b4ecdc1 100644
71255 --- a/include/linux/crypto.h
71256 +++ b/include/linux/crypto.h
71257 @@ -373,7 +373,7 @@ struct cipher_tfm {
71258 const u8 *key, unsigned int keylen);
71259 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
71260 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
71261 -};
71262 +} __no_const;
71263
71264 struct hash_tfm {
71265 int (*init)(struct hash_desc *desc);
71266 @@ -394,13 +394,13 @@ struct compress_tfm {
71267 int (*cot_decompress)(struct crypto_tfm *tfm,
71268 const u8 *src, unsigned int slen,
71269 u8 *dst, unsigned int *dlen);
71270 -};
71271 +} __no_const;
71272
71273 struct rng_tfm {
71274 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
71275 unsigned int dlen);
71276 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
71277 -};
71278 +} __no_const;
71279
71280 #define crt_ablkcipher crt_u.ablkcipher
71281 #define crt_aead crt_u.aead
71282 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
71283 index 653589e..4ef254a 100644
71284 --- a/include/linux/ctype.h
71285 +++ b/include/linux/ctype.h
71286 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
71287 * Fast implementation of tolower() for internal usage. Do not use in your
71288 * code.
71289 */
71290 -static inline char _tolower(const char c)
71291 +static inline unsigned char _tolower(const unsigned char c)
71292 {
71293 return c | 0x20;
71294 }
71295 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
71296 index 7925bf0..d5143d2 100644
71297 --- a/include/linux/decompress/mm.h
71298 +++ b/include/linux/decompress/mm.h
71299 @@ -77,7 +77,7 @@ static void free(void *where)
71300 * warnings when not needed (indeed large_malloc / large_free are not
71301 * needed by inflate */
71302
71303 -#define malloc(a) kmalloc(a, GFP_KERNEL)
71304 +#define malloc(a) kmalloc((a), GFP_KERNEL)
71305 #define free(a) kfree(a)
71306
71307 #define large_malloc(a) vmalloc(a)
71308 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
71309 index fe8c447..bdc1f33 100644
71310 --- a/include/linux/devfreq.h
71311 +++ b/include/linux/devfreq.h
71312 @@ -114,7 +114,7 @@ struct devfreq_governor {
71313 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
71314 int (*event_handler)(struct devfreq *devfreq,
71315 unsigned int event, void *data);
71316 -};
71317 +} __do_const;
71318
71319 /**
71320 * struct devfreq - Device devfreq structure
71321 diff --git a/include/linux/device.h b/include/linux/device.h
71322 index c0a1261..dba7569 100644
71323 --- a/include/linux/device.h
71324 +++ b/include/linux/device.h
71325 @@ -290,7 +290,7 @@ struct subsys_interface {
71326 struct list_head node;
71327 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
71328 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
71329 -};
71330 +} __do_const;
71331
71332 int subsys_interface_register(struct subsys_interface *sif);
71333 void subsys_interface_unregister(struct subsys_interface *sif);
71334 @@ -473,7 +473,7 @@ struct device_type {
71335 void (*release)(struct device *dev);
71336
71337 const struct dev_pm_ops *pm;
71338 -};
71339 +} __do_const;
71340
71341 /* interface for exporting device attributes */
71342 struct device_attribute {
71343 @@ -483,11 +483,12 @@ struct device_attribute {
71344 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
71345 const char *buf, size_t count);
71346 };
71347 +typedef struct device_attribute __no_const device_attribute_no_const;
71348
71349 struct dev_ext_attribute {
71350 struct device_attribute attr;
71351 void *var;
71352 -};
71353 +} __do_const;
71354
71355 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
71356 char *buf);
71357 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
71358 index 94af418..b1ca7a2 100644
71359 --- a/include/linux/dma-mapping.h
71360 +++ b/include/linux/dma-mapping.h
71361 @@ -54,7 +54,7 @@ struct dma_map_ops {
71362 u64 (*get_required_mask)(struct device *dev);
71363 #endif
71364 int is_phys;
71365 -};
71366 +} __do_const;
71367
71368 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
71369
71370 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
71371 index 96d3e4a..dc36433 100644
71372 --- a/include/linux/dmaengine.h
71373 +++ b/include/linux/dmaengine.h
71374 @@ -1035,9 +1035,9 @@ struct dma_pinned_list {
71375 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
71376 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
71377
71378 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
71379 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
71380 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
71381 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
71382 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
71383 struct dma_pinned_list *pinned_list, struct page *page,
71384 unsigned int offset, size_t len);
71385
71386 diff --git a/include/linux/efi.h b/include/linux/efi.h
71387 index 2bc0ad7..3f7b006 100644
71388 --- a/include/linux/efi.h
71389 +++ b/include/linux/efi.h
71390 @@ -745,6 +745,7 @@ struct efivar_operations {
71391 efi_set_variable_t *set_variable;
71392 efi_query_variable_store_t *query_variable_store;
71393 };
71394 +typedef struct efivar_operations __no_const efivar_operations_no_const;
71395
71396 struct efivars {
71397 /*
71398 diff --git a/include/linux/elf.h b/include/linux/elf.h
71399 index 40a3c0e..4c45a38 100644
71400 --- a/include/linux/elf.h
71401 +++ b/include/linux/elf.h
71402 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
71403 #define elf_note elf32_note
71404 #define elf_addr_t Elf32_Off
71405 #define Elf_Half Elf32_Half
71406 +#define elf_dyn Elf32_Dyn
71407
71408 #else
71409
71410 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
71411 #define elf_note elf64_note
71412 #define elf_addr_t Elf64_Off
71413 #define Elf_Half Elf64_Half
71414 +#define elf_dyn Elf64_Dyn
71415
71416 #endif
71417
71418 diff --git a/include/linux/err.h b/include/linux/err.h
71419 index f2edce2..cc2082c 100644
71420 --- a/include/linux/err.h
71421 +++ b/include/linux/err.h
71422 @@ -19,12 +19,12 @@
71423
71424 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
71425
71426 -static inline void * __must_check ERR_PTR(long error)
71427 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
71428 {
71429 return (void *) error;
71430 }
71431
71432 -static inline long __must_check PTR_ERR(const void *ptr)
71433 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
71434 {
71435 return (long) ptr;
71436 }
71437 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
71438 index fcb51c8..bdafcf6 100644
71439 --- a/include/linux/extcon.h
71440 +++ b/include/linux/extcon.h
71441 @@ -134,7 +134,7 @@ struct extcon_dev {
71442 /* /sys/class/extcon/.../mutually_exclusive/... */
71443 struct attribute_group attr_g_muex;
71444 struct attribute **attrs_muex;
71445 - struct device_attribute *d_attrs_muex;
71446 + device_attribute_no_const *d_attrs_muex;
71447 };
71448
71449 /**
71450 diff --git a/include/linux/fb.h b/include/linux/fb.h
71451 index d49c60f..2834fbe 100644
71452 --- a/include/linux/fb.h
71453 +++ b/include/linux/fb.h
71454 @@ -304,7 +304,7 @@ struct fb_ops {
71455 /* called at KDB enter and leave time to prepare the console */
71456 int (*fb_debug_enter)(struct fb_info *info);
71457 int (*fb_debug_leave)(struct fb_info *info);
71458 -};
71459 +} __do_const;
71460
71461 #ifdef CONFIG_FB_TILEBLITTING
71462 #define FB_TILE_CURSOR_NONE 0
71463 diff --git a/include/linux/filter.h b/include/linux/filter.h
71464 index f65f5a6..2f4f93a 100644
71465 --- a/include/linux/filter.h
71466 +++ b/include/linux/filter.h
71467 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
71468
71469 struct sk_buff;
71470 struct sock;
71471 +struct bpf_jit_work;
71472
71473 struct sk_filter
71474 {
71475 @@ -27,6 +28,9 @@ struct sk_filter
71476 unsigned int len; /* Number of filter blocks */
71477 unsigned int (*bpf_func)(const struct sk_buff *skb,
71478 const struct sock_filter *filter);
71479 +#ifdef CONFIG_BPF_JIT
71480 + struct bpf_jit_work *work;
71481 +#endif
71482 struct rcu_head rcu;
71483 struct sock_filter insns[0];
71484 };
71485 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
71486 index 8293262..2b3b8bd 100644
71487 --- a/include/linux/frontswap.h
71488 +++ b/include/linux/frontswap.h
71489 @@ -11,7 +11,7 @@ struct frontswap_ops {
71490 int (*load)(unsigned, pgoff_t, struct page *);
71491 void (*invalidate_page)(unsigned, pgoff_t);
71492 void (*invalidate_area)(unsigned);
71493 -};
71494 +} __no_const;
71495
71496 extern bool frontswap_enabled;
71497 extern struct frontswap_ops *
71498 diff --git a/include/linux/fs.h b/include/linux/fs.h
71499 index 65c2be2..4c53f6e 100644
71500 --- a/include/linux/fs.h
71501 +++ b/include/linux/fs.h
71502 @@ -1543,7 +1543,8 @@ struct file_operations {
71503 long (*fallocate)(struct file *file, int mode, loff_t offset,
71504 loff_t len);
71505 int (*show_fdinfo)(struct seq_file *m, struct file *f);
71506 -};
71507 +} __do_const;
71508 +typedef struct file_operations __no_const file_operations_no_const;
71509
71510 struct inode_operations {
71511 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
71512 @@ -2688,4 +2689,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
71513 inode->i_flags |= S_NOSEC;
71514 }
71515
71516 +static inline bool is_sidechannel_device(const struct inode *inode)
71517 +{
71518 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
71519 + umode_t mode = inode->i_mode;
71520 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
71521 +#else
71522 + return false;
71523 +#endif
71524 +}
71525 +
71526 #endif /* _LINUX_FS_H */
71527 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
71528 index 2b93a9a..855d94a 100644
71529 --- a/include/linux/fs_struct.h
71530 +++ b/include/linux/fs_struct.h
71531 @@ -6,7 +6,7 @@
71532 #include <linux/seqlock.h>
71533
71534 struct fs_struct {
71535 - int users;
71536 + atomic_t users;
71537 spinlock_t lock;
71538 seqcount_t seq;
71539 int umask;
71540 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
71541 index 5dfa0aa..6acf322 100644
71542 --- a/include/linux/fscache-cache.h
71543 +++ b/include/linux/fscache-cache.h
71544 @@ -112,7 +112,7 @@ struct fscache_operation {
71545 fscache_operation_release_t release;
71546 };
71547
71548 -extern atomic_t fscache_op_debug_id;
71549 +extern atomic_unchecked_t fscache_op_debug_id;
71550 extern void fscache_op_work_func(struct work_struct *work);
71551
71552 extern void fscache_enqueue_operation(struct fscache_operation *);
71553 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
71554 INIT_WORK(&op->work, fscache_op_work_func);
71555 atomic_set(&op->usage, 1);
71556 op->state = FSCACHE_OP_ST_INITIALISED;
71557 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
71558 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
71559 op->processor = processor;
71560 op->release = release;
71561 INIT_LIST_HEAD(&op->pend_link);
71562 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
71563 index 7a08623..4c07b0f 100644
71564 --- a/include/linux/fscache.h
71565 +++ b/include/linux/fscache.h
71566 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
71567 * - this is mandatory for any object that may have data
71568 */
71569 void (*now_uncached)(void *cookie_netfs_data);
71570 -};
71571 +} __do_const;
71572
71573 /*
71574 * fscache cached network filesystem type
71575 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
71576 index a78680a..87bd73e 100644
71577 --- a/include/linux/fsnotify.h
71578 +++ b/include/linux/fsnotify.h
71579 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
71580 struct inode *inode = path->dentry->d_inode;
71581 __u32 mask = FS_ACCESS;
71582
71583 + if (is_sidechannel_device(inode))
71584 + return;
71585 +
71586 if (S_ISDIR(inode->i_mode))
71587 mask |= FS_ISDIR;
71588
71589 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
71590 struct inode *inode = path->dentry->d_inode;
71591 __u32 mask = FS_MODIFY;
71592
71593 + if (is_sidechannel_device(inode))
71594 + return;
71595 +
71596 if (S_ISDIR(inode->i_mode))
71597 mask |= FS_ISDIR;
71598
71599 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
71600 */
71601 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
71602 {
71603 - return kstrdup(name, GFP_KERNEL);
71604 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
71605 }
71606
71607 /*
71608 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
71609 index 9f3c275..911b591 100644
71610 --- a/include/linux/genhd.h
71611 +++ b/include/linux/genhd.h
71612 @@ -194,7 +194,7 @@ struct gendisk {
71613 struct kobject *slave_dir;
71614
71615 struct timer_rand_state *random;
71616 - atomic_t sync_io; /* RAID */
71617 + atomic_unchecked_t sync_io; /* RAID */
71618 struct disk_events *ev;
71619 #ifdef CONFIG_BLK_DEV_INTEGRITY
71620 struct blk_integrity *integrity;
71621 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
71622 index 023bc34..b02b46a 100644
71623 --- a/include/linux/genl_magic_func.h
71624 +++ b/include/linux/genl_magic_func.h
71625 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
71626 },
71627
71628 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
71629 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
71630 +static struct genl_ops ZZZ_genl_ops[] = {
71631 #include GENL_MAGIC_INCLUDE_FILE
71632 };
71633
71634 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
71635 index 0f615eb..5c3832f 100644
71636 --- a/include/linux/gfp.h
71637 +++ b/include/linux/gfp.h
71638 @@ -35,6 +35,13 @@ struct vm_area_struct;
71639 #define ___GFP_NO_KSWAPD 0x400000u
71640 #define ___GFP_OTHER_NODE 0x800000u
71641 #define ___GFP_WRITE 0x1000000u
71642 +
71643 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71644 +#define ___GFP_USERCOPY 0x2000000u
71645 +#else
71646 +#define ___GFP_USERCOPY 0
71647 +#endif
71648 +
71649 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
71650
71651 /*
71652 @@ -92,6 +99,7 @@ struct vm_area_struct;
71653 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
71654 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
71655 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
71656 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
71657
71658 /*
71659 * This may seem redundant, but it's a way of annotating false positives vs.
71660 @@ -99,7 +107,7 @@ struct vm_area_struct;
71661 */
71662 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
71663
71664 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
71665 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
71666 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
71667
71668 /* This equals 0, but use constants in case they ever change */
71669 @@ -153,6 +161,8 @@ struct vm_area_struct;
71670 /* 4GB DMA on some platforms */
71671 #define GFP_DMA32 __GFP_DMA32
71672
71673 +#define GFP_USERCOPY __GFP_USERCOPY
71674 +
71675 /* Convert GFP flags to their corresponding migrate type */
71676 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
71677 {
71678 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
71679 new file mode 100644
71680 index 0000000..ebe6d72
71681 --- /dev/null
71682 +++ b/include/linux/gracl.h
71683 @@ -0,0 +1,319 @@
71684 +#ifndef GR_ACL_H
71685 +#define GR_ACL_H
71686 +
71687 +#include <linux/grdefs.h>
71688 +#include <linux/resource.h>
71689 +#include <linux/capability.h>
71690 +#include <linux/dcache.h>
71691 +#include <asm/resource.h>
71692 +
71693 +/* Major status information */
71694 +
71695 +#define GR_VERSION "grsecurity 2.9.1"
71696 +#define GRSECURITY_VERSION 0x2901
71697 +
71698 +enum {
71699 + GR_SHUTDOWN = 0,
71700 + GR_ENABLE = 1,
71701 + GR_SPROLE = 2,
71702 + GR_RELOAD = 3,
71703 + GR_SEGVMOD = 4,
71704 + GR_STATUS = 5,
71705 + GR_UNSPROLE = 6,
71706 + GR_PASSSET = 7,
71707 + GR_SPROLEPAM = 8,
71708 +};
71709 +
71710 +/* Password setup definitions
71711 + * kernel/grhash.c */
71712 +enum {
71713 + GR_PW_LEN = 128,
71714 + GR_SALT_LEN = 16,
71715 + GR_SHA_LEN = 32,
71716 +};
71717 +
71718 +enum {
71719 + GR_SPROLE_LEN = 64,
71720 +};
71721 +
71722 +enum {
71723 + GR_NO_GLOB = 0,
71724 + GR_REG_GLOB,
71725 + GR_CREATE_GLOB
71726 +};
71727 +
71728 +#define GR_NLIMITS 32
71729 +
71730 +/* Begin Data Structures */
71731 +
71732 +struct sprole_pw {
71733 + unsigned char *rolename;
71734 + unsigned char salt[GR_SALT_LEN];
71735 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
71736 +};
71737 +
71738 +struct name_entry {
71739 + __u32 key;
71740 + ino_t inode;
71741 + dev_t device;
71742 + char *name;
71743 + __u16 len;
71744 + __u8 deleted;
71745 + struct name_entry *prev;
71746 + struct name_entry *next;
71747 +};
71748 +
71749 +struct inodev_entry {
71750 + struct name_entry *nentry;
71751 + struct inodev_entry *prev;
71752 + struct inodev_entry *next;
71753 +};
71754 +
71755 +struct acl_role_db {
71756 + struct acl_role_label **r_hash;
71757 + __u32 r_size;
71758 +};
71759 +
71760 +struct inodev_db {
71761 + struct inodev_entry **i_hash;
71762 + __u32 i_size;
71763 +};
71764 +
71765 +struct name_db {
71766 + struct name_entry **n_hash;
71767 + __u32 n_size;
71768 +};
71769 +
71770 +struct crash_uid {
71771 + uid_t uid;
71772 + unsigned long expires;
71773 +};
71774 +
71775 +struct gr_hash_struct {
71776 + void **table;
71777 + void **nametable;
71778 + void *first;
71779 + __u32 table_size;
71780 + __u32 used_size;
71781 + int type;
71782 +};
71783 +
71784 +/* Userspace Grsecurity ACL data structures */
71785 +
71786 +struct acl_subject_label {
71787 + char *filename;
71788 + ino_t inode;
71789 + dev_t device;
71790 + __u32 mode;
71791 + kernel_cap_t cap_mask;
71792 + kernel_cap_t cap_lower;
71793 + kernel_cap_t cap_invert_audit;
71794 +
71795 + struct rlimit res[GR_NLIMITS];
71796 + __u32 resmask;
71797 +
71798 + __u8 user_trans_type;
71799 + __u8 group_trans_type;
71800 + uid_t *user_transitions;
71801 + gid_t *group_transitions;
71802 + __u16 user_trans_num;
71803 + __u16 group_trans_num;
71804 +
71805 + __u32 sock_families[2];
71806 + __u32 ip_proto[8];
71807 + __u32 ip_type;
71808 + struct acl_ip_label **ips;
71809 + __u32 ip_num;
71810 + __u32 inaddr_any_override;
71811 +
71812 + __u32 crashes;
71813 + unsigned long expires;
71814 +
71815 + struct acl_subject_label *parent_subject;
71816 + struct gr_hash_struct *hash;
71817 + struct acl_subject_label *prev;
71818 + struct acl_subject_label *next;
71819 +
71820 + struct acl_object_label **obj_hash;
71821 + __u32 obj_hash_size;
71822 + __u16 pax_flags;
71823 +};
71824 +
71825 +struct role_allowed_ip {
71826 + __u32 addr;
71827 + __u32 netmask;
71828 +
71829 + struct role_allowed_ip *prev;
71830 + struct role_allowed_ip *next;
71831 +};
71832 +
71833 +struct role_transition {
71834 + char *rolename;
71835 +
71836 + struct role_transition *prev;
71837 + struct role_transition *next;
71838 +};
71839 +
71840 +struct acl_role_label {
71841 + char *rolename;
71842 + uid_t uidgid;
71843 + __u16 roletype;
71844 +
71845 + __u16 auth_attempts;
71846 + unsigned long expires;
71847 +
71848 + struct acl_subject_label *root_label;
71849 + struct gr_hash_struct *hash;
71850 +
71851 + struct acl_role_label *prev;
71852 + struct acl_role_label *next;
71853 +
71854 + struct role_transition *transitions;
71855 + struct role_allowed_ip *allowed_ips;
71856 + uid_t *domain_children;
71857 + __u16 domain_child_num;
71858 +
71859 + umode_t umask;
71860 +
71861 + struct acl_subject_label **subj_hash;
71862 + __u32 subj_hash_size;
71863 +};
71864 +
71865 +struct user_acl_role_db {
71866 + struct acl_role_label **r_table;
71867 + __u32 num_pointers; /* Number of allocations to track */
71868 + __u32 num_roles; /* Number of roles */
71869 + __u32 num_domain_children; /* Number of domain children */
71870 + __u32 num_subjects; /* Number of subjects */
71871 + __u32 num_objects; /* Number of objects */
71872 +};
71873 +
71874 +struct acl_object_label {
71875 + char *filename;
71876 + ino_t inode;
71877 + dev_t device;
71878 + __u32 mode;
71879 +
71880 + struct acl_subject_label *nested;
71881 + struct acl_object_label *globbed;
71882 +
71883 + /* next two structures not used */
71884 +
71885 + struct acl_object_label *prev;
71886 + struct acl_object_label *next;
71887 +};
71888 +
71889 +struct acl_ip_label {
71890 + char *iface;
71891 + __u32 addr;
71892 + __u32 netmask;
71893 + __u16 low, high;
71894 + __u8 mode;
71895 + __u32 type;
71896 + __u32 proto[8];
71897 +
71898 + /* next two structures not used */
71899 +
71900 + struct acl_ip_label *prev;
71901 + struct acl_ip_label *next;
71902 +};
71903 +
71904 +struct gr_arg {
71905 + struct user_acl_role_db role_db;
71906 + unsigned char pw[GR_PW_LEN];
71907 + unsigned char salt[GR_SALT_LEN];
71908 + unsigned char sum[GR_SHA_LEN];
71909 + unsigned char sp_role[GR_SPROLE_LEN];
71910 + struct sprole_pw *sprole_pws;
71911 + dev_t segv_device;
71912 + ino_t segv_inode;
71913 + uid_t segv_uid;
71914 + __u16 num_sprole_pws;
71915 + __u16 mode;
71916 +};
71917 +
71918 +struct gr_arg_wrapper {
71919 + struct gr_arg *arg;
71920 + __u32 version;
71921 + __u32 size;
71922 +};
71923 +
71924 +struct subject_map {
71925 + struct acl_subject_label *user;
71926 + struct acl_subject_label *kernel;
71927 + struct subject_map *prev;
71928 + struct subject_map *next;
71929 +};
71930 +
71931 +struct acl_subj_map_db {
71932 + struct subject_map **s_hash;
71933 + __u32 s_size;
71934 +};
71935 +
71936 +/* End Data Structures Section */
71937 +
71938 +/* Hash functions generated by empirical testing by Brad Spengler
71939 + Makes good use of the low bits of the inode. Generally 0-1 times
71940 + in loop for successful match. 0-3 for unsuccessful match.
71941 + Shift/add algorithm with modulus of table size and an XOR*/
71942 +
71943 +static __inline__ unsigned int
71944 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
71945 +{
71946 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
71947 +}
71948 +
71949 + static __inline__ unsigned int
71950 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
71951 +{
71952 + return ((const unsigned long)userp % sz);
71953 +}
71954 +
71955 +static __inline__ unsigned int
71956 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
71957 +{
71958 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
71959 +}
71960 +
71961 +static __inline__ unsigned int
71962 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
71963 +{
71964 + return full_name_hash((const unsigned char *)name, len) % sz;
71965 +}
71966 +
71967 +#define FOR_EACH_ROLE_START(role) \
71968 + role = role_list; \
71969 + while (role) {
71970 +
71971 +#define FOR_EACH_ROLE_END(role) \
71972 + role = role->prev; \
71973 + }
71974 +
71975 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
71976 + subj = NULL; \
71977 + iter = 0; \
71978 + while (iter < role->subj_hash_size) { \
71979 + if (subj == NULL) \
71980 + subj = role->subj_hash[iter]; \
71981 + if (subj == NULL) { \
71982 + iter++; \
71983 + continue; \
71984 + }
71985 +
71986 +#define FOR_EACH_SUBJECT_END(subj,iter) \
71987 + subj = subj->next; \
71988 + if (subj == NULL) \
71989 + iter++; \
71990 + }
71991 +
71992 +
71993 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
71994 + subj = role->hash->first; \
71995 + while (subj != NULL) {
71996 +
71997 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
71998 + subj = subj->next; \
71999 + }
72000 +
72001 +#endif
72002 +
72003 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
72004 new file mode 100644
72005 index 0000000..33ebd1f
72006 --- /dev/null
72007 +++ b/include/linux/gracl_compat.h
72008 @@ -0,0 +1,156 @@
72009 +#ifndef GR_ACL_COMPAT_H
72010 +#define GR_ACL_COMPAT_H
72011 +
72012 +#include <linux/resource.h>
72013 +#include <asm/resource.h>
72014 +
72015 +struct sprole_pw_compat {
72016 + compat_uptr_t rolename;
72017 + unsigned char salt[GR_SALT_LEN];
72018 + unsigned char sum[GR_SHA_LEN];
72019 +};
72020 +
72021 +struct gr_hash_struct_compat {
72022 + compat_uptr_t table;
72023 + compat_uptr_t nametable;
72024 + compat_uptr_t first;
72025 + __u32 table_size;
72026 + __u32 used_size;
72027 + int type;
72028 +};
72029 +
72030 +struct acl_subject_label_compat {
72031 + compat_uptr_t filename;
72032 + compat_ino_t inode;
72033 + __u32 device;
72034 + __u32 mode;
72035 + kernel_cap_t cap_mask;
72036 + kernel_cap_t cap_lower;
72037 + kernel_cap_t cap_invert_audit;
72038 +
72039 + struct compat_rlimit res[GR_NLIMITS];
72040 + __u32 resmask;
72041 +
72042 + __u8 user_trans_type;
72043 + __u8 group_trans_type;
72044 + compat_uptr_t user_transitions;
72045 + compat_uptr_t group_transitions;
72046 + __u16 user_trans_num;
72047 + __u16 group_trans_num;
72048 +
72049 + __u32 sock_families[2];
72050 + __u32 ip_proto[8];
72051 + __u32 ip_type;
72052 + compat_uptr_t ips;
72053 + __u32 ip_num;
72054 + __u32 inaddr_any_override;
72055 +
72056 + __u32 crashes;
72057 + compat_ulong_t expires;
72058 +
72059 + compat_uptr_t parent_subject;
72060 + compat_uptr_t hash;
72061 + compat_uptr_t prev;
72062 + compat_uptr_t next;
72063 +
72064 + compat_uptr_t obj_hash;
72065 + __u32 obj_hash_size;
72066 + __u16 pax_flags;
72067 +};
72068 +
72069 +struct role_allowed_ip_compat {
72070 + __u32 addr;
72071 + __u32 netmask;
72072 +
72073 + compat_uptr_t prev;
72074 + compat_uptr_t next;
72075 +};
72076 +
72077 +struct role_transition_compat {
72078 + compat_uptr_t rolename;
72079 +
72080 + compat_uptr_t prev;
72081 + compat_uptr_t next;
72082 +};
72083 +
72084 +struct acl_role_label_compat {
72085 + compat_uptr_t rolename;
72086 + uid_t uidgid;
72087 + __u16 roletype;
72088 +
72089 + __u16 auth_attempts;
72090 + compat_ulong_t expires;
72091 +
72092 + compat_uptr_t root_label;
72093 + compat_uptr_t hash;
72094 +
72095 + compat_uptr_t prev;
72096 + compat_uptr_t next;
72097 +
72098 + compat_uptr_t transitions;
72099 + compat_uptr_t allowed_ips;
72100 + compat_uptr_t domain_children;
72101 + __u16 domain_child_num;
72102 +
72103 + umode_t umask;
72104 +
72105 + compat_uptr_t subj_hash;
72106 + __u32 subj_hash_size;
72107 +};
72108 +
72109 +struct user_acl_role_db_compat {
72110 + compat_uptr_t r_table;
72111 + __u32 num_pointers;
72112 + __u32 num_roles;
72113 + __u32 num_domain_children;
72114 + __u32 num_subjects;
72115 + __u32 num_objects;
72116 +};
72117 +
72118 +struct acl_object_label_compat {
72119 + compat_uptr_t filename;
72120 + compat_ino_t inode;
72121 + __u32 device;
72122 + __u32 mode;
72123 +
72124 + compat_uptr_t nested;
72125 + compat_uptr_t globbed;
72126 +
72127 + compat_uptr_t prev;
72128 + compat_uptr_t next;
72129 +};
72130 +
72131 +struct acl_ip_label_compat {
72132 + compat_uptr_t iface;
72133 + __u32 addr;
72134 + __u32 netmask;
72135 + __u16 low, high;
72136 + __u8 mode;
72137 + __u32 type;
72138 + __u32 proto[8];
72139 +
72140 + compat_uptr_t prev;
72141 + compat_uptr_t next;
72142 +};
72143 +
72144 +struct gr_arg_compat {
72145 + struct user_acl_role_db_compat role_db;
72146 + unsigned char pw[GR_PW_LEN];
72147 + unsigned char salt[GR_SALT_LEN];
72148 + unsigned char sum[GR_SHA_LEN];
72149 + unsigned char sp_role[GR_SPROLE_LEN];
72150 + compat_uptr_t sprole_pws;
72151 + __u32 segv_device;
72152 + compat_ino_t segv_inode;
72153 + uid_t segv_uid;
72154 + __u16 num_sprole_pws;
72155 + __u16 mode;
72156 +};
72157 +
72158 +struct gr_arg_wrapper_compat {
72159 + compat_uptr_t arg;
72160 + __u32 version;
72161 + __u32 size;
72162 +};
72163 +
72164 +#endif
72165 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
72166 new file mode 100644
72167 index 0000000..323ecf2
72168 --- /dev/null
72169 +++ b/include/linux/gralloc.h
72170 @@ -0,0 +1,9 @@
72171 +#ifndef __GRALLOC_H
72172 +#define __GRALLOC_H
72173 +
72174 +void acl_free_all(void);
72175 +int acl_alloc_stack_init(unsigned long size);
72176 +void *acl_alloc(unsigned long len);
72177 +void *acl_alloc_num(unsigned long num, unsigned long len);
72178 +
72179 +#endif
72180 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
72181 new file mode 100644
72182 index 0000000..be66033
72183 --- /dev/null
72184 +++ b/include/linux/grdefs.h
72185 @@ -0,0 +1,140 @@
72186 +#ifndef GRDEFS_H
72187 +#define GRDEFS_H
72188 +
72189 +/* Begin grsecurity status declarations */
72190 +
72191 +enum {
72192 + GR_READY = 0x01,
72193 + GR_STATUS_INIT = 0x00 // disabled state
72194 +};
72195 +
72196 +/* Begin ACL declarations */
72197 +
72198 +/* Role flags */
72199 +
72200 +enum {
72201 + GR_ROLE_USER = 0x0001,
72202 + GR_ROLE_GROUP = 0x0002,
72203 + GR_ROLE_DEFAULT = 0x0004,
72204 + GR_ROLE_SPECIAL = 0x0008,
72205 + GR_ROLE_AUTH = 0x0010,
72206 + GR_ROLE_NOPW = 0x0020,
72207 + GR_ROLE_GOD = 0x0040,
72208 + GR_ROLE_LEARN = 0x0080,
72209 + GR_ROLE_TPE = 0x0100,
72210 + GR_ROLE_DOMAIN = 0x0200,
72211 + GR_ROLE_PAM = 0x0400,
72212 + GR_ROLE_PERSIST = 0x0800
72213 +};
72214 +
72215 +/* ACL Subject and Object mode flags */
72216 +enum {
72217 + GR_DELETED = 0x80000000
72218 +};
72219 +
72220 +/* ACL Object-only mode flags */
72221 +enum {
72222 + GR_READ = 0x00000001,
72223 + GR_APPEND = 0x00000002,
72224 + GR_WRITE = 0x00000004,
72225 + GR_EXEC = 0x00000008,
72226 + GR_FIND = 0x00000010,
72227 + GR_INHERIT = 0x00000020,
72228 + GR_SETID = 0x00000040,
72229 + GR_CREATE = 0x00000080,
72230 + GR_DELETE = 0x00000100,
72231 + GR_LINK = 0x00000200,
72232 + GR_AUDIT_READ = 0x00000400,
72233 + GR_AUDIT_APPEND = 0x00000800,
72234 + GR_AUDIT_WRITE = 0x00001000,
72235 + GR_AUDIT_EXEC = 0x00002000,
72236 + GR_AUDIT_FIND = 0x00004000,
72237 + GR_AUDIT_INHERIT= 0x00008000,
72238 + GR_AUDIT_SETID = 0x00010000,
72239 + GR_AUDIT_CREATE = 0x00020000,
72240 + GR_AUDIT_DELETE = 0x00040000,
72241 + GR_AUDIT_LINK = 0x00080000,
72242 + GR_PTRACERD = 0x00100000,
72243 + GR_NOPTRACE = 0x00200000,
72244 + GR_SUPPRESS = 0x00400000,
72245 + GR_NOLEARN = 0x00800000,
72246 + GR_INIT_TRANSFER= 0x01000000
72247 +};
72248 +
72249 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
72250 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
72251 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
72252 +
72253 +/* ACL subject-only mode flags */
72254 +enum {
72255 + GR_KILL = 0x00000001,
72256 + GR_VIEW = 0x00000002,
72257 + GR_PROTECTED = 0x00000004,
72258 + GR_LEARN = 0x00000008,
72259 + GR_OVERRIDE = 0x00000010,
72260 + /* just a placeholder, this mode is only used in userspace */
72261 + GR_DUMMY = 0x00000020,
72262 + GR_PROTSHM = 0x00000040,
72263 + GR_KILLPROC = 0x00000080,
72264 + GR_KILLIPPROC = 0x00000100,
72265 + /* just a placeholder, this mode is only used in userspace */
72266 + GR_NOTROJAN = 0x00000200,
72267 + GR_PROTPROCFD = 0x00000400,
72268 + GR_PROCACCT = 0x00000800,
72269 + GR_RELAXPTRACE = 0x00001000,
72270 + //GR_NESTED = 0x00002000,
72271 + GR_INHERITLEARN = 0x00004000,
72272 + GR_PROCFIND = 0x00008000,
72273 + GR_POVERRIDE = 0x00010000,
72274 + GR_KERNELAUTH = 0x00020000,
72275 + GR_ATSECURE = 0x00040000,
72276 + GR_SHMEXEC = 0x00080000
72277 +};
72278 +
72279 +enum {
72280 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
72281 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
72282 + GR_PAX_ENABLE_MPROTECT = 0x0004,
72283 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
72284 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
72285 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
72286 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
72287 + GR_PAX_DISABLE_MPROTECT = 0x0400,
72288 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
72289 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
72290 +};
72291 +
72292 +enum {
72293 + GR_ID_USER = 0x01,
72294 + GR_ID_GROUP = 0x02,
72295 +};
72296 +
72297 +enum {
72298 + GR_ID_ALLOW = 0x01,
72299 + GR_ID_DENY = 0x02,
72300 +};
72301 +
72302 +#define GR_CRASH_RES 31
72303 +#define GR_UIDTABLE_MAX 500
72304 +
72305 +/* begin resource learning section */
72306 +enum {
72307 + GR_RLIM_CPU_BUMP = 60,
72308 + GR_RLIM_FSIZE_BUMP = 50000,
72309 + GR_RLIM_DATA_BUMP = 10000,
72310 + GR_RLIM_STACK_BUMP = 1000,
72311 + GR_RLIM_CORE_BUMP = 10000,
72312 + GR_RLIM_RSS_BUMP = 500000,
72313 + GR_RLIM_NPROC_BUMP = 1,
72314 + GR_RLIM_NOFILE_BUMP = 5,
72315 + GR_RLIM_MEMLOCK_BUMP = 50000,
72316 + GR_RLIM_AS_BUMP = 500000,
72317 + GR_RLIM_LOCKS_BUMP = 2,
72318 + GR_RLIM_SIGPENDING_BUMP = 5,
72319 + GR_RLIM_MSGQUEUE_BUMP = 10000,
72320 + GR_RLIM_NICE_BUMP = 1,
72321 + GR_RLIM_RTPRIO_BUMP = 1,
72322 + GR_RLIM_RTTIME_BUMP = 1000000
72323 +};
72324 +
72325 +#endif
72326 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
72327 new file mode 100644
72328 index 0000000..fd8598b
72329 --- /dev/null
72330 +++ b/include/linux/grinternal.h
72331 @@ -0,0 +1,228 @@
72332 +#ifndef __GRINTERNAL_H
72333 +#define __GRINTERNAL_H
72334 +
72335 +#ifdef CONFIG_GRKERNSEC
72336 +
72337 +#include <linux/fs.h>
72338 +#include <linux/mnt_namespace.h>
72339 +#include <linux/nsproxy.h>
72340 +#include <linux/gracl.h>
72341 +#include <linux/grdefs.h>
72342 +#include <linux/grmsg.h>
72343 +
72344 +void gr_add_learn_entry(const char *fmt, ...)
72345 + __attribute__ ((format (printf, 1, 2)));
72346 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
72347 + const struct vfsmount *mnt);
72348 +__u32 gr_check_create(const struct dentry *new_dentry,
72349 + const struct dentry *parent,
72350 + const struct vfsmount *mnt, const __u32 mode);
72351 +int gr_check_protected_task(const struct task_struct *task);
72352 +__u32 to_gr_audit(const __u32 reqmode);
72353 +int gr_set_acls(const int type);
72354 +int gr_apply_subject_to_task(struct task_struct *task);
72355 +int gr_acl_is_enabled(void);
72356 +char gr_roletype_to_char(void);
72357 +
72358 +void gr_handle_alertkill(struct task_struct *task);
72359 +char *gr_to_filename(const struct dentry *dentry,
72360 + const struct vfsmount *mnt);
72361 +char *gr_to_filename1(const struct dentry *dentry,
72362 + const struct vfsmount *mnt);
72363 +char *gr_to_filename2(const struct dentry *dentry,
72364 + const struct vfsmount *mnt);
72365 +char *gr_to_filename3(const struct dentry *dentry,
72366 + const struct vfsmount *mnt);
72367 +
72368 +extern int grsec_enable_ptrace_readexec;
72369 +extern int grsec_enable_harden_ptrace;
72370 +extern int grsec_enable_link;
72371 +extern int grsec_enable_fifo;
72372 +extern int grsec_enable_execve;
72373 +extern int grsec_enable_shm;
72374 +extern int grsec_enable_execlog;
72375 +extern int grsec_enable_signal;
72376 +extern int grsec_enable_audit_ptrace;
72377 +extern int grsec_enable_forkfail;
72378 +extern int grsec_enable_time;
72379 +extern int grsec_enable_rofs;
72380 +extern int grsec_enable_chroot_shmat;
72381 +extern int grsec_enable_chroot_mount;
72382 +extern int grsec_enable_chroot_double;
72383 +extern int grsec_enable_chroot_pivot;
72384 +extern int grsec_enable_chroot_chdir;
72385 +extern int grsec_enable_chroot_chmod;
72386 +extern int grsec_enable_chroot_mknod;
72387 +extern int grsec_enable_chroot_fchdir;
72388 +extern int grsec_enable_chroot_nice;
72389 +extern int grsec_enable_chroot_execlog;
72390 +extern int grsec_enable_chroot_caps;
72391 +extern int grsec_enable_chroot_sysctl;
72392 +extern int grsec_enable_chroot_unix;
72393 +extern int grsec_enable_symlinkown;
72394 +extern kgid_t grsec_symlinkown_gid;
72395 +extern int grsec_enable_tpe;
72396 +extern kgid_t grsec_tpe_gid;
72397 +extern int grsec_enable_tpe_all;
72398 +extern int grsec_enable_tpe_invert;
72399 +extern int grsec_enable_socket_all;
72400 +extern kgid_t grsec_socket_all_gid;
72401 +extern int grsec_enable_socket_client;
72402 +extern kgid_t grsec_socket_client_gid;
72403 +extern int grsec_enable_socket_server;
72404 +extern kgid_t grsec_socket_server_gid;
72405 +extern kgid_t grsec_audit_gid;
72406 +extern int grsec_enable_group;
72407 +extern int grsec_enable_log_rwxmaps;
72408 +extern int grsec_enable_mount;
72409 +extern int grsec_enable_chdir;
72410 +extern int grsec_resource_logging;
72411 +extern int grsec_enable_blackhole;
72412 +extern int grsec_lastack_retries;
72413 +extern int grsec_enable_brute;
72414 +extern int grsec_lock;
72415 +
72416 +extern spinlock_t grsec_alert_lock;
72417 +extern unsigned long grsec_alert_wtime;
72418 +extern unsigned long grsec_alert_fyet;
72419 +
72420 +extern spinlock_t grsec_audit_lock;
72421 +
72422 +extern rwlock_t grsec_exec_file_lock;
72423 +
72424 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
72425 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
72426 + (tsk)->exec_file->f_path.mnt) : "/")
72427 +
72428 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
72429 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
72430 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
72431 +
72432 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
72433 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
72434 + (tsk)->exec_file->f_path.mnt) : "/")
72435 +
72436 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
72437 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
72438 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
72439 +
72440 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
72441 +
72442 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
72443 +
72444 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
72445 +{
72446 + if (file1 && file2) {
72447 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
72448 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
72449 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
72450 + return true;
72451 + }
72452 +
72453 + return false;
72454 +}
72455 +
72456 +#define GR_CHROOT_CAPS {{ \
72457 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
72458 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
72459 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
72460 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
72461 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
72462 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
72463 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
72464 +
72465 +#define security_learn(normal_msg,args...) \
72466 +({ \
72467 + read_lock(&grsec_exec_file_lock); \
72468 + gr_add_learn_entry(normal_msg "\n", ## args); \
72469 + read_unlock(&grsec_exec_file_lock); \
72470 +})
72471 +
72472 +enum {
72473 + GR_DO_AUDIT,
72474 + GR_DONT_AUDIT,
72475 + /* used for non-audit messages that we shouldn't kill the task on */
72476 + GR_DONT_AUDIT_GOOD
72477 +};
72478 +
72479 +enum {
72480 + GR_TTYSNIFF,
72481 + GR_RBAC,
72482 + GR_RBAC_STR,
72483 + GR_STR_RBAC,
72484 + GR_RBAC_MODE2,
72485 + GR_RBAC_MODE3,
72486 + GR_FILENAME,
72487 + GR_SYSCTL_HIDDEN,
72488 + GR_NOARGS,
72489 + GR_ONE_INT,
72490 + GR_ONE_INT_TWO_STR,
72491 + GR_ONE_STR,
72492 + GR_STR_INT,
72493 + GR_TWO_STR_INT,
72494 + GR_TWO_INT,
72495 + GR_TWO_U64,
72496 + GR_THREE_INT,
72497 + GR_FIVE_INT_TWO_STR,
72498 + GR_TWO_STR,
72499 + GR_THREE_STR,
72500 + GR_FOUR_STR,
72501 + GR_STR_FILENAME,
72502 + GR_FILENAME_STR,
72503 + GR_FILENAME_TWO_INT,
72504 + GR_FILENAME_TWO_INT_STR,
72505 + GR_TEXTREL,
72506 + GR_PTRACE,
72507 + GR_RESOURCE,
72508 + GR_CAP,
72509 + GR_SIG,
72510 + GR_SIG2,
72511 + GR_CRASH1,
72512 + GR_CRASH2,
72513 + GR_PSACCT,
72514 + GR_RWXMAP,
72515 + GR_RWXMAPVMA
72516 +};
72517 +
72518 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
72519 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
72520 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
72521 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
72522 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
72523 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
72524 +#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)
72525 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
72526 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
72527 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
72528 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
72529 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
72530 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
72531 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
72532 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
72533 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
72534 +#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)
72535 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
72536 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
72537 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
72538 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
72539 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
72540 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
72541 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
72542 +#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)
72543 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
72544 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
72545 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
72546 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
72547 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
72548 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
72549 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
72550 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
72551 +#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)
72552 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
72553 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
72554 +
72555 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
72556 +
72557 +#endif
72558 +
72559 +#endif
72560 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
72561 new file mode 100644
72562 index 0000000..a4396b5
72563 --- /dev/null
72564 +++ b/include/linux/grmsg.h
72565 @@ -0,0 +1,113 @@
72566 +#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"
72567 +#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"
72568 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
72569 +#define GR_STOPMOD_MSG "denied modification of module state by "
72570 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
72571 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
72572 +#define GR_IOPERM_MSG "denied use of ioperm() by "
72573 +#define GR_IOPL_MSG "denied use of iopl() by "
72574 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
72575 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
72576 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
72577 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
72578 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
72579 +#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"
72580 +#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"
72581 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
72582 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
72583 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
72584 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
72585 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
72586 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
72587 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
72588 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
72589 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
72590 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
72591 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
72592 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
72593 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
72594 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
72595 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
72596 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
72597 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
72598 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
72599 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
72600 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
72601 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
72602 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
72603 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
72604 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
72605 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
72606 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
72607 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
72608 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
72609 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
72610 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
72611 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
72612 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
72613 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
72614 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
72615 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
72616 +#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"
72617 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
72618 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
72619 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
72620 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
72621 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
72622 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
72623 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
72624 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
72625 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
72626 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
72627 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
72628 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
72629 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
72630 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
72631 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
72632 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
72633 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
72634 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
72635 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
72636 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
72637 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
72638 +#define GR_NICE_CHROOT_MSG "denied priority change by "
72639 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
72640 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
72641 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
72642 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
72643 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
72644 +#define GR_TIME_MSG "time set by "
72645 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
72646 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
72647 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
72648 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
72649 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
72650 +#define GR_BIND_MSG "denied bind() by "
72651 +#define GR_CONNECT_MSG "denied connect() by "
72652 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
72653 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
72654 +#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"
72655 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
72656 +#define GR_CAP_ACL_MSG "use of %s denied for "
72657 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
72658 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
72659 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
72660 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
72661 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
72662 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
72663 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
72664 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
72665 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
72666 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
72667 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
72668 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
72669 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
72670 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
72671 +#define GR_VM86_MSG "denied use of vm86 by "
72672 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
72673 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
72674 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
72675 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
72676 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
72677 +#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 "
72678 +#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 "
72679 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
72680 new file mode 100644
72681 index 0000000..3676b0b
72682 --- /dev/null
72683 +++ b/include/linux/grsecurity.h
72684 @@ -0,0 +1,242 @@
72685 +#ifndef GR_SECURITY_H
72686 +#define GR_SECURITY_H
72687 +#include <linux/fs.h>
72688 +#include <linux/fs_struct.h>
72689 +#include <linux/binfmts.h>
72690 +#include <linux/gracl.h>
72691 +
72692 +/* notify of brain-dead configs */
72693 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
72694 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
72695 +#endif
72696 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
72697 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
72698 +#endif
72699 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
72700 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
72701 +#endif
72702 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
72703 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
72704 +#endif
72705 +
72706 +void gr_handle_brute_attach(unsigned long mm_flags);
72707 +void gr_handle_brute_check(void);
72708 +void gr_handle_kernel_exploit(void);
72709 +
72710 +char gr_roletype_to_char(void);
72711 +
72712 +int gr_acl_enable_at_secure(void);
72713 +
72714 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
72715 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
72716 +
72717 +void gr_del_task_from_ip_table(struct task_struct *p);
72718 +
72719 +int gr_pid_is_chrooted(struct task_struct *p);
72720 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
72721 +int gr_handle_chroot_nice(void);
72722 +int gr_handle_chroot_sysctl(const int op);
72723 +int gr_handle_chroot_setpriority(struct task_struct *p,
72724 + const int niceval);
72725 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
72726 +int gr_handle_chroot_chroot(const struct dentry *dentry,
72727 + const struct vfsmount *mnt);
72728 +void gr_handle_chroot_chdir(const struct path *path);
72729 +int gr_handle_chroot_chmod(const struct dentry *dentry,
72730 + const struct vfsmount *mnt, const int mode);
72731 +int gr_handle_chroot_mknod(const struct dentry *dentry,
72732 + const struct vfsmount *mnt, const int mode);
72733 +int gr_handle_chroot_mount(const struct dentry *dentry,
72734 + const struct vfsmount *mnt,
72735 + const char *dev_name);
72736 +int gr_handle_chroot_pivot(void);
72737 +int gr_handle_chroot_unix(const pid_t pid);
72738 +
72739 +int gr_handle_rawio(const struct inode *inode);
72740 +
72741 +void gr_handle_ioperm(void);
72742 +void gr_handle_iopl(void);
72743 +
72744 +umode_t gr_acl_umask(void);
72745 +
72746 +int gr_tpe_allow(const struct file *file);
72747 +
72748 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
72749 +void gr_clear_chroot_entries(struct task_struct *task);
72750 +
72751 +void gr_log_forkfail(const int retval);
72752 +void gr_log_timechange(void);
72753 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
72754 +void gr_log_chdir(const struct dentry *dentry,
72755 + const struct vfsmount *mnt);
72756 +void gr_log_chroot_exec(const struct dentry *dentry,
72757 + const struct vfsmount *mnt);
72758 +void gr_log_remount(const char *devname, const int retval);
72759 +void gr_log_unmount(const char *devname, const int retval);
72760 +void gr_log_mount(const char *from, const char *to, const int retval);
72761 +void gr_log_textrel(struct vm_area_struct *vma);
72762 +void gr_log_ptgnustack(struct file *file);
72763 +void gr_log_rwxmmap(struct file *file);
72764 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
72765 +
72766 +int gr_handle_follow_link(const struct inode *parent,
72767 + const struct inode *inode,
72768 + const struct dentry *dentry,
72769 + const struct vfsmount *mnt);
72770 +int gr_handle_fifo(const struct dentry *dentry,
72771 + const struct vfsmount *mnt,
72772 + const struct dentry *dir, const int flag,
72773 + const int acc_mode);
72774 +int gr_handle_hardlink(const struct dentry *dentry,
72775 + const struct vfsmount *mnt,
72776 + struct inode *inode,
72777 + const int mode, const struct filename *to);
72778 +
72779 +int gr_is_capable(const int cap);
72780 +int gr_is_capable_nolog(const int cap);
72781 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
72782 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
72783 +
72784 +void gr_copy_label(struct task_struct *tsk);
72785 +void gr_handle_crash(struct task_struct *task, const int sig);
72786 +int gr_handle_signal(const struct task_struct *p, const int sig);
72787 +int gr_check_crash_uid(const kuid_t uid);
72788 +int gr_check_protected_task(const struct task_struct *task);
72789 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
72790 +int gr_acl_handle_mmap(const struct file *file,
72791 + const unsigned long prot);
72792 +int gr_acl_handle_mprotect(const struct file *file,
72793 + const unsigned long prot);
72794 +int gr_check_hidden_task(const struct task_struct *tsk);
72795 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
72796 + const struct vfsmount *mnt);
72797 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
72798 + const struct vfsmount *mnt);
72799 +__u32 gr_acl_handle_access(const struct dentry *dentry,
72800 + const struct vfsmount *mnt, const int fmode);
72801 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
72802 + const struct vfsmount *mnt, umode_t *mode);
72803 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
72804 + const struct vfsmount *mnt);
72805 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
72806 + const struct vfsmount *mnt);
72807 +int gr_handle_ptrace(struct task_struct *task, const long request);
72808 +int gr_handle_proc_ptrace(struct task_struct *task);
72809 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
72810 + const struct vfsmount *mnt);
72811 +int gr_check_crash_exec(const struct file *filp);
72812 +int gr_acl_is_enabled(void);
72813 +void gr_set_kernel_label(struct task_struct *task);
72814 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
72815 + const kgid_t gid);
72816 +int gr_set_proc_label(const struct dentry *dentry,
72817 + const struct vfsmount *mnt,
72818 + const int unsafe_flags);
72819 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
72820 + const struct vfsmount *mnt);
72821 +__u32 gr_acl_handle_open(const struct dentry *dentry,
72822 + const struct vfsmount *mnt, int acc_mode);
72823 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
72824 + const struct dentry *p_dentry,
72825 + const struct vfsmount *p_mnt,
72826 + int open_flags, int acc_mode, const int imode);
72827 +void gr_handle_create(const struct dentry *dentry,
72828 + const struct vfsmount *mnt);
72829 +void gr_handle_proc_create(const struct dentry *dentry,
72830 + const struct inode *inode);
72831 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
72832 + const struct dentry *parent_dentry,
72833 + const struct vfsmount *parent_mnt,
72834 + const int mode);
72835 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
72836 + const struct dentry *parent_dentry,
72837 + const struct vfsmount *parent_mnt);
72838 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
72839 + const struct vfsmount *mnt);
72840 +void gr_handle_delete(const ino_t ino, const dev_t dev);
72841 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
72842 + const struct vfsmount *mnt);
72843 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
72844 + const struct dentry *parent_dentry,
72845 + const struct vfsmount *parent_mnt,
72846 + const struct filename *from);
72847 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
72848 + const struct dentry *parent_dentry,
72849 + const struct vfsmount *parent_mnt,
72850 + const struct dentry *old_dentry,
72851 + const struct vfsmount *old_mnt, const struct filename *to);
72852 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
72853 +int gr_acl_handle_rename(struct dentry *new_dentry,
72854 + struct dentry *parent_dentry,
72855 + const struct vfsmount *parent_mnt,
72856 + struct dentry *old_dentry,
72857 + struct inode *old_parent_inode,
72858 + struct vfsmount *old_mnt, const struct filename *newname);
72859 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
72860 + struct dentry *old_dentry,
72861 + struct dentry *new_dentry,
72862 + struct vfsmount *mnt, const __u8 replace);
72863 +__u32 gr_check_link(const struct dentry *new_dentry,
72864 + const struct dentry *parent_dentry,
72865 + const struct vfsmount *parent_mnt,
72866 + const struct dentry *old_dentry,
72867 + const struct vfsmount *old_mnt);
72868 +int gr_acl_handle_filldir(const struct file *file, const char *name,
72869 + const unsigned int namelen, const ino_t ino);
72870 +
72871 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
72872 + const struct vfsmount *mnt);
72873 +void gr_acl_handle_exit(void);
72874 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
72875 +int gr_acl_handle_procpidmem(const struct task_struct *task);
72876 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
72877 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
72878 +void gr_audit_ptrace(struct task_struct *task);
72879 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
72880 +void gr_put_exec_file(struct task_struct *task);
72881 +
72882 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
72883 +
72884 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
72885 +extern void gr_learn_resource(const struct task_struct *task, const int res,
72886 + const unsigned long wanted, const int gt);
72887 +#else
72888 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
72889 + const unsigned long wanted, const int gt)
72890 +{
72891 +}
72892 +#endif
72893 +
72894 +#ifdef CONFIG_GRKERNSEC_RESLOG
72895 +extern void gr_log_resource(const struct task_struct *task, const int res,
72896 + const unsigned long wanted, const int gt);
72897 +#else
72898 +static inline void gr_log_resource(const struct task_struct *task, const int res,
72899 + const unsigned long wanted, const int gt)
72900 +{
72901 +}
72902 +#endif
72903 +
72904 +#ifdef CONFIG_GRKERNSEC
72905 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
72906 +void gr_handle_vm86(void);
72907 +void gr_handle_mem_readwrite(u64 from, u64 to);
72908 +
72909 +void gr_log_badprocpid(const char *entry);
72910 +
72911 +extern int grsec_enable_dmesg;
72912 +extern int grsec_disable_privio;
72913 +
72914 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
72915 +extern kgid_t grsec_proc_gid;
72916 +#endif
72917 +
72918 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
72919 +extern int grsec_enable_chroot_findtask;
72920 +#endif
72921 +#ifdef CONFIG_GRKERNSEC_SETXID
72922 +extern int grsec_enable_setxid;
72923 +#endif
72924 +#endif
72925 +
72926 +#endif
72927 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
72928 new file mode 100644
72929 index 0000000..e7ffaaf
72930 --- /dev/null
72931 +++ b/include/linux/grsock.h
72932 @@ -0,0 +1,19 @@
72933 +#ifndef __GRSOCK_H
72934 +#define __GRSOCK_H
72935 +
72936 +extern void gr_attach_curr_ip(const struct sock *sk);
72937 +extern int gr_handle_sock_all(const int family, const int type,
72938 + const int protocol);
72939 +extern int gr_handle_sock_server(const struct sockaddr *sck);
72940 +extern int gr_handle_sock_server_other(const struct sock *sck);
72941 +extern int gr_handle_sock_client(const struct sockaddr *sck);
72942 +extern int gr_search_connect(struct socket * sock,
72943 + struct sockaddr_in * addr);
72944 +extern int gr_search_bind(struct socket * sock,
72945 + struct sockaddr_in * addr);
72946 +extern int gr_search_listen(struct socket * sock);
72947 +extern int gr_search_accept(struct socket * sock);
72948 +extern int gr_search_socket(const int domain, const int type,
72949 + const int protocol);
72950 +
72951 +#endif
72952 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
72953 index 7fb31da..08b5114 100644
72954 --- a/include/linux/highmem.h
72955 +++ b/include/linux/highmem.h
72956 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
72957 kunmap_atomic(kaddr);
72958 }
72959
72960 +static inline void sanitize_highpage(struct page *page)
72961 +{
72962 + void *kaddr;
72963 + unsigned long flags;
72964 +
72965 + local_irq_save(flags);
72966 + kaddr = kmap_atomic(page);
72967 + clear_page(kaddr);
72968 + kunmap_atomic(kaddr);
72969 + local_irq_restore(flags);
72970 +}
72971 +
72972 static inline void zero_user_segments(struct page *page,
72973 unsigned start1, unsigned end1,
72974 unsigned start2, unsigned end2)
72975 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
72976 index 1c7b89a..7f52502 100644
72977 --- a/include/linux/hwmon-sysfs.h
72978 +++ b/include/linux/hwmon-sysfs.h
72979 @@ -25,7 +25,8 @@
72980 struct sensor_device_attribute{
72981 struct device_attribute dev_attr;
72982 int index;
72983 -};
72984 +} __do_const;
72985 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
72986 #define to_sensor_dev_attr(_dev_attr) \
72987 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
72988
72989 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
72990 struct device_attribute dev_attr;
72991 u8 index;
72992 u8 nr;
72993 -};
72994 +} __do_const;
72995 #define to_sensor_dev_attr_2(_dev_attr) \
72996 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
72997
72998 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
72999 index e988fa9..ff9f17e 100644
73000 --- a/include/linux/i2c.h
73001 +++ b/include/linux/i2c.h
73002 @@ -366,6 +366,7 @@ struct i2c_algorithm {
73003 /* To determine what the adapter supports */
73004 u32 (*functionality) (struct i2c_adapter *);
73005 };
73006 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
73007
73008 /**
73009 * struct i2c_bus_recovery_info - I2C bus recovery information
73010 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
73011 index d23c3c2..eb63c81 100644
73012 --- a/include/linux/i2o.h
73013 +++ b/include/linux/i2o.h
73014 @@ -565,7 +565,7 @@ struct i2o_controller {
73015 struct i2o_device *exec; /* Executive */
73016 #if BITS_PER_LONG == 64
73017 spinlock_t context_list_lock; /* lock for context_list */
73018 - atomic_t context_list_counter; /* needed for unique contexts */
73019 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
73020 struct list_head context_list; /* list of context id's
73021 and pointers */
73022 #endif
73023 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
73024 index aff7ad8..3942bbd 100644
73025 --- a/include/linux/if_pppox.h
73026 +++ b/include/linux/if_pppox.h
73027 @@ -76,7 +76,7 @@ struct pppox_proto {
73028 int (*ioctl)(struct socket *sock, unsigned int cmd,
73029 unsigned long arg);
73030 struct module *owner;
73031 -};
73032 +} __do_const;
73033
73034 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
73035 extern void unregister_pppox_proto(int proto_num);
73036 diff --git a/include/linux/init.h b/include/linux/init.h
73037 index 8618147..0821126 100644
73038 --- a/include/linux/init.h
73039 +++ b/include/linux/init.h
73040 @@ -39,9 +39,36 @@
73041 * Also note, that this data cannot be "const".
73042 */
73043
73044 +#ifdef MODULE
73045 +#define add_init_latent_entropy
73046 +#define add_devinit_latent_entropy
73047 +#define add_cpuinit_latent_entropy
73048 +#define add_meminit_latent_entropy
73049 +#else
73050 +#define add_init_latent_entropy __latent_entropy
73051 +
73052 +#ifdef CONFIG_HOTPLUG
73053 +#define add_devinit_latent_entropy
73054 +#else
73055 +#define add_devinit_latent_entropy __latent_entropy
73056 +#endif
73057 +
73058 +#ifdef CONFIG_HOTPLUG_CPU
73059 +#define add_cpuinit_latent_entropy
73060 +#else
73061 +#define add_cpuinit_latent_entropy __latent_entropy
73062 +#endif
73063 +
73064 +#ifdef CONFIG_MEMORY_HOTPLUG
73065 +#define add_meminit_latent_entropy
73066 +#else
73067 +#define add_meminit_latent_entropy __latent_entropy
73068 +#endif
73069 +#endif
73070 +
73071 /* These are for everybody (although not all archs will actually
73072 discard it in modules) */
73073 -#define __init __section(.init.text) __cold notrace
73074 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
73075 #define __initdata __section(.init.data)
73076 #define __initconst __constsection(.init.rodata)
73077 #define __exitdata __section(.exit.data)
73078 @@ -94,7 +121,7 @@
73079 #define __exit __section(.exit.text) __exitused __cold notrace
73080
73081 /* Used for HOTPLUG_CPU */
73082 -#define __cpuinit __section(.cpuinit.text) __cold notrace
73083 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
73084 #define __cpuinitdata __section(.cpuinit.data)
73085 #define __cpuinitconst __constsection(.cpuinit.rodata)
73086 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
73087 @@ -102,7 +129,7 @@
73088 #define __cpuexitconst __constsection(.cpuexit.rodata)
73089
73090 /* Used for MEMORY_HOTPLUG */
73091 -#define __meminit __section(.meminit.text) __cold notrace
73092 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
73093 #define __meminitdata __section(.meminit.data)
73094 #define __meminitconst __constsection(.meminit.rodata)
73095 #define __memexit __section(.memexit.text) __exitused __cold notrace
73096 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
73097 index 5cd0f09..c9f67cc 100644
73098 --- a/include/linux/init_task.h
73099 +++ b/include/linux/init_task.h
73100 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
73101
73102 #define INIT_TASK_COMM "swapper"
73103
73104 +#ifdef CONFIG_X86
73105 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
73106 +#else
73107 +#define INIT_TASK_THREAD_INFO
73108 +#endif
73109 +
73110 /*
73111 * INIT_TASK is used to set up the first task table, touch at
73112 * your own risk!. Base=0, limit=0x1fffff (=2MB)
73113 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
73114 RCU_POINTER_INITIALIZER(cred, &init_cred), \
73115 .comm = INIT_TASK_COMM, \
73116 .thread = INIT_THREAD, \
73117 + INIT_TASK_THREAD_INFO \
73118 .fs = &init_fs, \
73119 .files = &init_files, \
73120 .signal = &init_signals, \
73121 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
73122 index 5fa5afe..ac55b25 100644
73123 --- a/include/linux/interrupt.h
73124 +++ b/include/linux/interrupt.h
73125 @@ -430,7 +430,7 @@ enum
73126 /* map softirq index to softirq name. update 'softirq_to_name' in
73127 * kernel/softirq.c when adding a new softirq.
73128 */
73129 -extern char *softirq_to_name[NR_SOFTIRQS];
73130 +extern const char * const softirq_to_name[NR_SOFTIRQS];
73131
73132 /* softirq mask and active fields moved to irq_cpustat_t in
73133 * asm/hardirq.h to get better cache usage. KAO
73134 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
73135
73136 struct softirq_action
73137 {
73138 - void (*action)(struct softirq_action *);
73139 -};
73140 + void (*action)(void);
73141 +} __no_const;
73142
73143 asmlinkage void do_softirq(void);
73144 asmlinkage void __do_softirq(void);
73145 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
73146 +extern void open_softirq(int nr, void (*action)(void));
73147 extern void softirq_init(void);
73148 extern void __raise_softirq_irqoff(unsigned int nr);
73149
73150 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
73151 index 3aeb730..2177f39 100644
73152 --- a/include/linux/iommu.h
73153 +++ b/include/linux/iommu.h
73154 @@ -113,7 +113,7 @@ struct iommu_ops {
73155 u32 (*domain_get_windows)(struct iommu_domain *domain);
73156
73157 unsigned long pgsize_bitmap;
73158 -};
73159 +} __do_const;
73160
73161 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
73162 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
73163 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
73164 index 89b7c24..382af74 100644
73165 --- a/include/linux/ioport.h
73166 +++ b/include/linux/ioport.h
73167 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
73168 int adjust_resource(struct resource *res, resource_size_t start,
73169 resource_size_t size);
73170 resource_size_t resource_alignment(struct resource *res);
73171 -static inline resource_size_t resource_size(const struct resource *res)
73172 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
73173 {
73174 return res->end - res->start + 1;
73175 }
73176 diff --git a/include/linux/irq.h b/include/linux/irq.h
73177 index bc4e066..50468a9 100644
73178 --- a/include/linux/irq.h
73179 +++ b/include/linux/irq.h
73180 @@ -328,7 +328,8 @@ struct irq_chip {
73181 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
73182
73183 unsigned long flags;
73184 -};
73185 +} __do_const;
73186 +typedef struct irq_chip __no_const irq_chip_no_const;
73187
73188 /*
73189 * irq_chip specific flags
73190 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
73191 index 3e203eb..3fe68d0 100644
73192 --- a/include/linux/irqchip/arm-gic.h
73193 +++ b/include/linux/irqchip/arm-gic.h
73194 @@ -59,9 +59,11 @@
73195
73196 #ifndef __ASSEMBLY__
73197
73198 +#include <linux/irq.h>
73199 +
73200 struct device_node;
73201
73202 -extern struct irq_chip gic_arch_extn;
73203 +extern irq_chip_no_const gic_arch_extn;
73204
73205 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
73206 u32 offset, struct device_node *);
73207 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
73208 index 6883e19..e854fcb 100644
73209 --- a/include/linux/kallsyms.h
73210 +++ b/include/linux/kallsyms.h
73211 @@ -15,7 +15,8 @@
73212
73213 struct module;
73214
73215 -#ifdef CONFIG_KALLSYMS
73216 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
73217 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
73218 /* Lookup the address for a symbol. Returns 0 if not found. */
73219 unsigned long kallsyms_lookup_name(const char *name);
73220
73221 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
73222 /* Stupid that this does nothing, but I didn't create this mess. */
73223 #define __print_symbol(fmt, addr)
73224 #endif /*CONFIG_KALLSYMS*/
73225 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
73226 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
73227 +extern unsigned long kallsyms_lookup_name(const char *name);
73228 +extern void __print_symbol(const char *fmt, unsigned long address);
73229 +extern int sprint_backtrace(char *buffer, unsigned long address);
73230 +extern int sprint_symbol(char *buffer, unsigned long address);
73231 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
73232 +const char *kallsyms_lookup(unsigned long addr,
73233 + unsigned long *symbolsize,
73234 + unsigned long *offset,
73235 + char **modname, char *namebuf);
73236 +extern int kallsyms_lookup_size_offset(unsigned long addr,
73237 + unsigned long *symbolsize,
73238 + unsigned long *offset);
73239 +#endif
73240
73241 /* This macro allows us to keep printk typechecking */
73242 static __printf(1, 2)
73243 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
73244 index 518a53a..5e28358 100644
73245 --- a/include/linux/key-type.h
73246 +++ b/include/linux/key-type.h
73247 @@ -125,7 +125,7 @@ struct key_type {
73248 /* internal fields */
73249 struct list_head link; /* link in types list */
73250 struct lock_class_key lock_class; /* key->sem lock class */
73251 -};
73252 +} __do_const;
73253
73254 extern struct key_type key_type_keyring;
73255
73256 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
73257 index c6e091b..a940adf 100644
73258 --- a/include/linux/kgdb.h
73259 +++ b/include/linux/kgdb.h
73260 @@ -52,7 +52,7 @@ extern int kgdb_connected;
73261 extern int kgdb_io_module_registered;
73262
73263 extern atomic_t kgdb_setting_breakpoint;
73264 -extern atomic_t kgdb_cpu_doing_single_step;
73265 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
73266
73267 extern struct task_struct *kgdb_usethread;
73268 extern struct task_struct *kgdb_contthread;
73269 @@ -254,7 +254,7 @@ struct kgdb_arch {
73270 void (*correct_hw_break)(void);
73271
73272 void (*enable_nmi)(bool on);
73273 -};
73274 +} __do_const;
73275
73276 /**
73277 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
73278 @@ -279,7 +279,7 @@ struct kgdb_io {
73279 void (*pre_exception) (void);
73280 void (*post_exception) (void);
73281 int is_console;
73282 -};
73283 +} __do_const;
73284
73285 extern struct kgdb_arch arch_kgdb_ops;
73286
73287 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
73288 index 0555cc6..b16a7a4 100644
73289 --- a/include/linux/kmod.h
73290 +++ b/include/linux/kmod.h
73291 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
73292 * usually useless though. */
73293 extern __printf(2, 3)
73294 int __request_module(bool wait, const char *name, ...);
73295 +extern __printf(3, 4)
73296 +int ___request_module(bool wait, char *param_name, const char *name, ...);
73297 #define request_module(mod...) __request_module(true, mod)
73298 #define request_module_nowait(mod...) __request_module(false, mod)
73299 #define try_then_request_module(x, mod...) \
73300 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
73301 index 939b112..ed6ed51 100644
73302 --- a/include/linux/kobject.h
73303 +++ b/include/linux/kobject.h
73304 @@ -111,7 +111,7 @@ struct kobj_type {
73305 struct attribute **default_attrs;
73306 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
73307 const void *(*namespace)(struct kobject *kobj);
73308 -};
73309 +} __do_const;
73310
73311 struct kobj_uevent_env {
73312 char *envp[UEVENT_NUM_ENVP];
73313 @@ -134,6 +134,7 @@ struct kobj_attribute {
73314 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
73315 const char *buf, size_t count);
73316 };
73317 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
73318
73319 extern const struct sysfs_ops kobj_sysfs_ops;
73320
73321 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
73322 index f66b065..c2c29b4 100644
73323 --- a/include/linux/kobject_ns.h
73324 +++ b/include/linux/kobject_ns.h
73325 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
73326 const void *(*netlink_ns)(struct sock *sk);
73327 const void *(*initial_ns)(void);
73328 void (*drop_ns)(void *);
73329 -};
73330 +} __do_const;
73331
73332 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
73333 int kobj_ns_type_registered(enum kobj_ns_type type);
73334 diff --git a/include/linux/kref.h b/include/linux/kref.h
73335 index 484604d..0f6c5b6 100644
73336 --- a/include/linux/kref.h
73337 +++ b/include/linux/kref.h
73338 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
73339 static inline int kref_sub(struct kref *kref, unsigned int count,
73340 void (*release)(struct kref *kref))
73341 {
73342 - WARN_ON(release == NULL);
73343 + BUG_ON(release == NULL);
73344
73345 if (atomic_sub_and_test((int) count, &kref->refcount)) {
73346 release(kref);
73347 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
73348 index 8db53cf..c21121d 100644
73349 --- a/include/linux/kvm_host.h
73350 +++ b/include/linux/kvm_host.h
73351 @@ -444,7 +444,7 @@ static inline void kvm_irqfd_exit(void)
73352 {
73353 }
73354 #endif
73355 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
73356 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
73357 struct module *module);
73358 void kvm_exit(void);
73359
73360 @@ -616,7 +616,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
73361 struct kvm_guest_debug *dbg);
73362 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
73363
73364 -int kvm_arch_init(void *opaque);
73365 +int kvm_arch_init(const void *opaque);
73366 void kvm_arch_exit(void);
73367
73368 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
73369 diff --git a/include/linux/libata.h b/include/linux/libata.h
73370 index eae7a05..2cdd875 100644
73371 --- a/include/linux/libata.h
73372 +++ b/include/linux/libata.h
73373 @@ -919,7 +919,7 @@ struct ata_port_operations {
73374 * fields must be pointers.
73375 */
73376 const struct ata_port_operations *inherits;
73377 -};
73378 +} __do_const;
73379
73380 struct ata_port_info {
73381 unsigned long flags;
73382 diff --git a/include/linux/list.h b/include/linux/list.h
73383 index b83e565..baa6c1d 100644
73384 --- a/include/linux/list.h
73385 +++ b/include/linux/list.h
73386 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
73387 extern void list_del(struct list_head *entry);
73388 #endif
73389
73390 +extern void __pax_list_add(struct list_head *new,
73391 + struct list_head *prev,
73392 + struct list_head *next);
73393 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
73394 +{
73395 + __pax_list_add(new, head, head->next);
73396 +}
73397 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
73398 +{
73399 + __pax_list_add(new, head->prev, head);
73400 +}
73401 +extern void pax_list_del(struct list_head *entry);
73402 +
73403 /**
73404 * list_replace - replace old entry by new one
73405 * @old : the element to be replaced
73406 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
73407 INIT_LIST_HEAD(entry);
73408 }
73409
73410 +extern void pax_list_del_init(struct list_head *entry);
73411 +
73412 /**
73413 * list_move - delete from one list and add as another's head
73414 * @list: the entry to move
73415 diff --git a/include/linux/math64.h b/include/linux/math64.h
73416 index 2913b86..8dcbb1e 100644
73417 --- a/include/linux/math64.h
73418 +++ b/include/linux/math64.h
73419 @@ -15,7 +15,7 @@
73420 * This is commonly provided by 32bit archs to provide an optimized 64bit
73421 * divide.
73422 */
73423 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
73424 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
73425 {
73426 *remainder = dividend % divisor;
73427 return dividend / divisor;
73428 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
73429 /**
73430 * div64_u64 - unsigned 64bit divide with 64bit divisor
73431 */
73432 -static inline u64 div64_u64(u64 dividend, u64 divisor)
73433 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
73434 {
73435 return dividend / divisor;
73436 }
73437 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
73438 #define div64_ul(x, y) div_u64((x), (y))
73439
73440 #ifndef div_u64_rem
73441 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
73442 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
73443 {
73444 *remainder = do_div(dividend, divisor);
73445 return dividend;
73446 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
73447 * divide.
73448 */
73449 #ifndef div_u64
73450 -static inline u64 div_u64(u64 dividend, u32 divisor)
73451 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
73452 {
73453 u32 remainder;
73454 return div_u64_rem(dividend, divisor, &remainder);
73455 diff --git a/include/linux/mm.h b/include/linux/mm.h
73456 index e0c8528..bcf0c29 100644
73457 --- a/include/linux/mm.h
73458 +++ b/include/linux/mm.h
73459 @@ -104,6 +104,11 @@ extern unsigned int kobjsize(const void *objp);
73460 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
73461 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
73462 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
73463 +
73464 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
73465 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
73466 +#endif
73467 +
73468 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
73469
73470 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
73471 @@ -205,8 +210,8 @@ struct vm_operations_struct {
73472 /* called by access_process_vm when get_user_pages() fails, typically
73473 * for use by special VMAs that can switch between memory and hardware
73474 */
73475 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
73476 - void *buf, int len, int write);
73477 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
73478 + void *buf, size_t len, int write);
73479 #ifdef CONFIG_NUMA
73480 /*
73481 * set_policy() op must add a reference to any non-NULL @new mempolicy
73482 @@ -236,6 +241,7 @@ struct vm_operations_struct {
73483 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
73484 unsigned long size, pgoff_t pgoff);
73485 };
73486 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
73487
73488 struct mmu_gather;
73489 struct inode;
73490 @@ -980,8 +986,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
73491 unsigned long *pfn);
73492 int follow_phys(struct vm_area_struct *vma, unsigned long address,
73493 unsigned int flags, unsigned long *prot, resource_size_t *phys);
73494 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
73495 - void *buf, int len, int write);
73496 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
73497 + void *buf, size_t len, int write);
73498
73499 static inline void unmap_shared_mapping_range(struct address_space *mapping,
73500 loff_t const holebegin, loff_t const holelen)
73501 @@ -1020,9 +1026,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
73502 }
73503 #endif
73504
73505 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
73506 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
73507 - void *buf, int len, int write);
73508 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
73509 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
73510 + void *buf, size_t len, int write);
73511
73512 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
73513 unsigned long start, unsigned long nr_pages,
73514 @@ -1053,34 +1059,6 @@ int set_page_dirty(struct page *page);
73515 int set_page_dirty_lock(struct page *page);
73516 int clear_page_dirty_for_io(struct page *page);
73517
73518 -/* Is the vma a continuation of the stack vma above it? */
73519 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
73520 -{
73521 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
73522 -}
73523 -
73524 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
73525 - unsigned long addr)
73526 -{
73527 - return (vma->vm_flags & VM_GROWSDOWN) &&
73528 - (vma->vm_start == addr) &&
73529 - !vma_growsdown(vma->vm_prev, addr);
73530 -}
73531 -
73532 -/* Is the vma a continuation of the stack vma below it? */
73533 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
73534 -{
73535 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
73536 -}
73537 -
73538 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
73539 - unsigned long addr)
73540 -{
73541 - return (vma->vm_flags & VM_GROWSUP) &&
73542 - (vma->vm_end == addr) &&
73543 - !vma_growsup(vma->vm_next, addr);
73544 -}
73545 -
73546 extern pid_t
73547 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
73548
73549 @@ -1180,6 +1158,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
73550 }
73551 #endif
73552
73553 +#ifdef CONFIG_MMU
73554 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
73555 +#else
73556 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
73557 +{
73558 + return __pgprot(0);
73559 +}
73560 +#endif
73561 +
73562 int vma_wants_writenotify(struct vm_area_struct *vma);
73563
73564 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
73565 @@ -1198,8 +1185,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
73566 {
73567 return 0;
73568 }
73569 +
73570 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
73571 + unsigned long address)
73572 +{
73573 + return 0;
73574 +}
73575 #else
73576 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
73577 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
73578 #endif
73579
73580 #ifdef __PAGETABLE_PMD_FOLDED
73581 @@ -1208,8 +1202,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
73582 {
73583 return 0;
73584 }
73585 +
73586 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
73587 + unsigned long address)
73588 +{
73589 + return 0;
73590 +}
73591 #else
73592 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
73593 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
73594 #endif
73595
73596 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
73597 @@ -1227,11 +1228,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
73598 NULL: pud_offset(pgd, address);
73599 }
73600
73601 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
73602 +{
73603 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
73604 + NULL: pud_offset(pgd, address);
73605 +}
73606 +
73607 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
73608 {
73609 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
73610 NULL: pmd_offset(pud, address);
73611 }
73612 +
73613 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
73614 +{
73615 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
73616 + NULL: pmd_offset(pud, address);
73617 +}
73618 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
73619
73620 #if USE_SPLIT_PTLOCKS
73621 @@ -1517,6 +1530,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
73622 unsigned long len, unsigned long prot, unsigned long flags,
73623 unsigned long pgoff, unsigned long *populate);
73624 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
73625 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
73626
73627 #ifdef CONFIG_MMU
73628 extern int __mm_populate(unsigned long addr, unsigned long len,
73629 @@ -1545,10 +1559,11 @@ struct vm_unmapped_area_info {
73630 unsigned long high_limit;
73631 unsigned long align_mask;
73632 unsigned long align_offset;
73633 + unsigned long threadstack_offset;
73634 };
73635
73636 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
73637 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
73638 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
73639 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
73640
73641 /*
73642 * Search for an unmapped address range.
73643 @@ -1560,7 +1575,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
73644 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
73645 */
73646 static inline unsigned long
73647 -vm_unmapped_area(struct vm_unmapped_area_info *info)
73648 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
73649 {
73650 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
73651 return unmapped_area(info);
73652 @@ -1623,6 +1638,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
73653 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
73654 struct vm_area_struct **pprev);
73655
73656 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
73657 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
73658 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
73659 +
73660 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
73661 NULL if none. Assume start_addr < end_addr. */
73662 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
73663 @@ -1651,15 +1670,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
73664 return vma;
73665 }
73666
73667 -#ifdef CONFIG_MMU
73668 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
73669 -#else
73670 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
73671 -{
73672 - return __pgprot(0);
73673 -}
73674 -#endif
73675 -
73676 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
73677 unsigned long change_prot_numa(struct vm_area_struct *vma,
73678 unsigned long start, unsigned long end);
73679 @@ -1711,6 +1721,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
73680 static inline void vm_stat_account(struct mm_struct *mm,
73681 unsigned long flags, struct file *file, long pages)
73682 {
73683 +
73684 +#ifdef CONFIG_PAX_RANDMMAP
73685 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
73686 +#endif
73687 +
73688 mm->total_vm += pages;
73689 }
73690 #endif /* CONFIG_PROC_FS */
73691 @@ -1791,7 +1806,7 @@ extern int unpoison_memory(unsigned long pfn);
73692 extern int sysctl_memory_failure_early_kill;
73693 extern int sysctl_memory_failure_recovery;
73694 extern void shake_page(struct page *p, int access);
73695 -extern atomic_long_t num_poisoned_pages;
73696 +extern atomic_long_unchecked_t num_poisoned_pages;
73697 extern int soft_offline_page(struct page *page, int flags);
73698
73699 extern void dump_page(struct page *page);
73700 @@ -1828,5 +1843,11 @@ void __init setup_nr_node_ids(void);
73701 static inline void setup_nr_node_ids(void) {}
73702 #endif
73703
73704 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
73705 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
73706 +#else
73707 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
73708 +#endif
73709 +
73710 #endif /* __KERNEL__ */
73711 #endif /* _LINUX_MM_H */
73712 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
73713 index ace9a5f..81bdb59 100644
73714 --- a/include/linux/mm_types.h
73715 +++ b/include/linux/mm_types.h
73716 @@ -289,6 +289,8 @@ struct vm_area_struct {
73717 #ifdef CONFIG_NUMA
73718 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
73719 #endif
73720 +
73721 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
73722 };
73723
73724 struct core_thread {
73725 @@ -437,6 +439,24 @@ struct mm_struct {
73726 int first_nid;
73727 #endif
73728 struct uprobes_state uprobes_state;
73729 +
73730 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
73731 + unsigned long pax_flags;
73732 +#endif
73733 +
73734 +#ifdef CONFIG_PAX_DLRESOLVE
73735 + unsigned long call_dl_resolve;
73736 +#endif
73737 +
73738 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
73739 + unsigned long call_syscall;
73740 +#endif
73741 +
73742 +#ifdef CONFIG_PAX_ASLR
73743 + unsigned long delta_mmap; /* randomized offset */
73744 + unsigned long delta_stack; /* randomized offset */
73745 +#endif
73746 +
73747 };
73748
73749 /* first nid will either be a valid NID or one of these values */
73750 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
73751 index c5d5278..f0b68c8 100644
73752 --- a/include/linux/mmiotrace.h
73753 +++ b/include/linux/mmiotrace.h
73754 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
73755 /* Called from ioremap.c */
73756 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
73757 void __iomem *addr);
73758 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
73759 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
73760
73761 /* For anyone to insert markers. Remember trailing newline. */
73762 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
73763 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
73764 {
73765 }
73766
73767 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
73768 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
73769 {
73770 }
73771
73772 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
73773 index 5c76737..61f518e 100644
73774 --- a/include/linux/mmzone.h
73775 +++ b/include/linux/mmzone.h
73776 @@ -396,7 +396,7 @@ struct zone {
73777 unsigned long flags; /* zone flags, see below */
73778
73779 /* Zone statistics */
73780 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
73781 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
73782
73783 /*
73784 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
73785 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
73786 index b508016..237cfe5 100644
73787 --- a/include/linux/mod_devicetable.h
73788 +++ b/include/linux/mod_devicetable.h
73789 @@ -13,7 +13,7 @@
73790 typedef unsigned long kernel_ulong_t;
73791 #endif
73792
73793 -#define PCI_ANY_ID (~0)
73794 +#define PCI_ANY_ID ((__u16)~0)
73795
73796 struct pci_device_id {
73797 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
73798 @@ -139,7 +139,7 @@ struct usb_device_id {
73799 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
73800 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
73801
73802 -#define HID_ANY_ID (~0)
73803 +#define HID_ANY_ID (~0U)
73804 #define HID_BUS_ANY 0xffff
73805 #define HID_GROUP_ANY 0x0000
73806
73807 @@ -465,7 +465,7 @@ struct dmi_system_id {
73808 const char *ident;
73809 struct dmi_strmatch matches[4];
73810 void *driver_data;
73811 -};
73812 +} __do_const;
73813 /*
73814 * struct dmi_device_id appears during expansion of
73815 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
73816 diff --git a/include/linux/module.h b/include/linux/module.h
73817 index 46f1ea0..a34ca37 100644
73818 --- a/include/linux/module.h
73819 +++ b/include/linux/module.h
73820 @@ -17,9 +17,11 @@
73821 #include <linux/moduleparam.h>
73822 #include <linux/tracepoint.h>
73823 #include <linux/export.h>
73824 +#include <linux/fs.h>
73825
73826 #include <linux/percpu.h>
73827 #include <asm/module.h>
73828 +#include <asm/pgtable.h>
73829
73830 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
73831 #define MODULE_SIG_STRING "~Module signature appended~\n"
73832 @@ -54,12 +56,13 @@ struct module_attribute {
73833 int (*test)(struct module *);
73834 void (*free)(struct module *);
73835 };
73836 +typedef struct module_attribute __no_const module_attribute_no_const;
73837
73838 struct module_version_attribute {
73839 struct module_attribute mattr;
73840 const char *module_name;
73841 const char *version;
73842 -} __attribute__ ((__aligned__(sizeof(void *))));
73843 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
73844
73845 extern ssize_t __modver_version_show(struct module_attribute *,
73846 struct module_kobject *, char *);
73847 @@ -232,7 +235,7 @@ struct module
73848
73849 /* Sysfs stuff. */
73850 struct module_kobject mkobj;
73851 - struct module_attribute *modinfo_attrs;
73852 + module_attribute_no_const *modinfo_attrs;
73853 const char *version;
73854 const char *srcversion;
73855 struct kobject *holders_dir;
73856 @@ -281,19 +284,16 @@ struct module
73857 int (*init)(void);
73858
73859 /* If this is non-NULL, vfree after init() returns */
73860 - void *module_init;
73861 + void *module_init_rx, *module_init_rw;
73862
73863 /* Here is the actual code + data, vfree'd on unload. */
73864 - void *module_core;
73865 + void *module_core_rx, *module_core_rw;
73866
73867 /* Here are the sizes of the init and core sections */
73868 - unsigned int init_size, core_size;
73869 + unsigned int init_size_rw, core_size_rw;
73870
73871 /* The size of the executable code in each section. */
73872 - unsigned int init_text_size, core_text_size;
73873 -
73874 - /* Size of RO sections of the module (text+rodata) */
73875 - unsigned int init_ro_size, core_ro_size;
73876 + unsigned int init_size_rx, core_size_rx;
73877
73878 /* Arch-specific module values */
73879 struct mod_arch_specific arch;
73880 @@ -349,6 +349,10 @@ struct module
73881 #ifdef CONFIG_EVENT_TRACING
73882 struct ftrace_event_call **trace_events;
73883 unsigned int num_trace_events;
73884 + struct file_operations trace_id;
73885 + struct file_operations trace_enable;
73886 + struct file_operations trace_format;
73887 + struct file_operations trace_filter;
73888 #endif
73889 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
73890 unsigned int num_ftrace_callsites;
73891 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
73892 bool is_module_percpu_address(unsigned long addr);
73893 bool is_module_text_address(unsigned long addr);
73894
73895 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
73896 +{
73897 +
73898 +#ifdef CONFIG_PAX_KERNEXEC
73899 + if (ktla_ktva(addr) >= (unsigned long)start &&
73900 + ktla_ktva(addr) < (unsigned long)start + size)
73901 + return 1;
73902 +#endif
73903 +
73904 + return ((void *)addr >= start && (void *)addr < start + size);
73905 +}
73906 +
73907 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
73908 +{
73909 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
73910 +}
73911 +
73912 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
73913 +{
73914 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
73915 +}
73916 +
73917 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
73918 +{
73919 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
73920 +}
73921 +
73922 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
73923 +{
73924 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
73925 +}
73926 +
73927 static inline int within_module_core(unsigned long addr, const struct module *mod)
73928 {
73929 - return (unsigned long)mod->module_core <= addr &&
73930 - addr < (unsigned long)mod->module_core + mod->core_size;
73931 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
73932 }
73933
73934 static inline int within_module_init(unsigned long addr, const struct module *mod)
73935 {
73936 - return (unsigned long)mod->module_init <= addr &&
73937 - addr < (unsigned long)mod->module_init + mod->init_size;
73938 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
73939 }
73940
73941 /* Search for module by name: must hold module_mutex. */
73942 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
73943 index 560ca53..ef621ef 100644
73944 --- a/include/linux/moduleloader.h
73945 +++ b/include/linux/moduleloader.h
73946 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
73947 sections. Returns NULL on failure. */
73948 void *module_alloc(unsigned long size);
73949
73950 +#ifdef CONFIG_PAX_KERNEXEC
73951 +void *module_alloc_exec(unsigned long size);
73952 +#else
73953 +#define module_alloc_exec(x) module_alloc(x)
73954 +#endif
73955 +
73956 /* Free memory returned from module_alloc. */
73957 void module_free(struct module *mod, void *module_region);
73958
73959 +#ifdef CONFIG_PAX_KERNEXEC
73960 +void module_free_exec(struct module *mod, void *module_region);
73961 +#else
73962 +#define module_free_exec(x, y) module_free((x), (y))
73963 +#endif
73964 +
73965 /*
73966 * Apply the given relocation to the (simplified) ELF. Return -error
73967 * or 0.
73968 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
73969 unsigned int relsec,
73970 struct module *me)
73971 {
73972 +#ifdef CONFIG_MODULES
73973 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
73974 +#endif
73975 return -ENOEXEC;
73976 }
73977 #endif
73978 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
73979 unsigned int relsec,
73980 struct module *me)
73981 {
73982 +#ifdef CONFIG_MODULES
73983 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
73984 +#endif
73985 return -ENOEXEC;
73986 }
73987 #endif
73988 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
73989 index 137b419..fe663ec 100644
73990 --- a/include/linux/moduleparam.h
73991 +++ b/include/linux/moduleparam.h
73992 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
73993 * @len is usually just sizeof(string).
73994 */
73995 #define module_param_string(name, string, len, perm) \
73996 - static const struct kparam_string __param_string_##name \
73997 + static const struct kparam_string __param_string_##name __used \
73998 = { len, string }; \
73999 __module_param_call(MODULE_PARAM_PREFIX, name, \
74000 &param_ops_string, \
74001 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
74002 */
74003 #define module_param_array_named(name, array, type, nump, perm) \
74004 param_check_##type(name, &(array)[0]); \
74005 - static const struct kparam_array __param_arr_##name \
74006 + static const struct kparam_array __param_arr_##name __used \
74007 = { .max = ARRAY_SIZE(array), .num = nump, \
74008 .ops = &param_ops_##type, \
74009 .elemsize = sizeof(array[0]), .elem = array }; \
74010 diff --git a/include/linux/namei.h b/include/linux/namei.h
74011 index 5a5ff57..5ae5070 100644
74012 --- a/include/linux/namei.h
74013 +++ b/include/linux/namei.h
74014 @@ -19,7 +19,7 @@ struct nameidata {
74015 unsigned seq;
74016 int last_type;
74017 unsigned depth;
74018 - char *saved_names[MAX_NESTED_LINKS + 1];
74019 + const char *saved_names[MAX_NESTED_LINKS + 1];
74020 };
74021
74022 /*
74023 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
74024
74025 extern void nd_jump_link(struct nameidata *nd, struct path *path);
74026
74027 -static inline void nd_set_link(struct nameidata *nd, char *path)
74028 +static inline void nd_set_link(struct nameidata *nd, const char *path)
74029 {
74030 nd->saved_names[nd->depth] = path;
74031 }
74032
74033 -static inline char *nd_get_link(struct nameidata *nd)
74034 +static inline const char *nd_get_link(const struct nameidata *nd)
74035 {
74036 return nd->saved_names[nd->depth];
74037 }
74038 diff --git a/include/linux/net.h b/include/linux/net.h
74039 index 99c9f0c..e1cf296 100644
74040 --- a/include/linux/net.h
74041 +++ b/include/linux/net.h
74042 @@ -183,7 +183,7 @@ struct net_proto_family {
74043 int (*create)(struct net *net, struct socket *sock,
74044 int protocol, int kern);
74045 struct module *owner;
74046 -};
74047 +} __do_const;
74048
74049 struct iovec;
74050 struct kvec;
74051 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
74052 index 96e4c21..9cc8278 100644
74053 --- a/include/linux/netdevice.h
74054 +++ b/include/linux/netdevice.h
74055 @@ -1026,6 +1026,7 @@ struct net_device_ops {
74056 int (*ndo_change_carrier)(struct net_device *dev,
74057 bool new_carrier);
74058 };
74059 +typedef struct net_device_ops __no_const net_device_ops_no_const;
74060
74061 /*
74062 * The DEVICE structure.
74063 @@ -1094,7 +1095,7 @@ struct net_device {
74064 int iflink;
74065
74066 struct net_device_stats stats;
74067 - atomic_long_t rx_dropped; /* dropped packets by core network
74068 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
74069 * Do not use this in drivers.
74070 */
74071
74072 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
74073 index 0060fde..481c6ae 100644
74074 --- a/include/linux/netfilter.h
74075 +++ b/include/linux/netfilter.h
74076 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
74077 #endif
74078 /* Use the module struct to lock set/get code in place */
74079 struct module *owner;
74080 -};
74081 +} __do_const;
74082
74083 /* Function to register/unregister hook points. */
74084 int nf_register_hook(struct nf_hook_ops *reg);
74085 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
74086 index d80e275..c3510b8 100644
74087 --- a/include/linux/netfilter/ipset/ip_set.h
74088 +++ b/include/linux/netfilter/ipset/ip_set.h
74089 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
74090 /* Return true if "b" set is the same as "a"
74091 * according to the create set parameters */
74092 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
74093 -};
74094 +} __do_const;
74095
74096 /* The core set type structure */
74097 struct ip_set_type {
74098 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
74099 index cadb740..d7c37c0 100644
74100 --- a/include/linux/netfilter/nfnetlink.h
74101 +++ b/include/linux/netfilter/nfnetlink.h
74102 @@ -16,7 +16,7 @@ struct nfnl_callback {
74103 const struct nlattr * const cda[]);
74104 const struct nla_policy *policy; /* netlink attribute policy */
74105 const u_int16_t attr_count; /* number of nlattr's */
74106 -};
74107 +} __do_const;
74108
74109 struct nfnetlink_subsystem {
74110 const char *name;
74111 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
74112 new file mode 100644
74113 index 0000000..33f4af8
74114 --- /dev/null
74115 +++ b/include/linux/netfilter/xt_gradm.h
74116 @@ -0,0 +1,9 @@
74117 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
74118 +#define _LINUX_NETFILTER_XT_GRADM_H 1
74119 +
74120 +struct xt_gradm_mtinfo {
74121 + __u16 flags;
74122 + __u16 invflags;
74123 +};
74124 +
74125 +#endif
74126 diff --git a/include/linux/nls.h b/include/linux/nls.h
74127 index 5dc635f..35f5e11 100644
74128 --- a/include/linux/nls.h
74129 +++ b/include/linux/nls.h
74130 @@ -31,7 +31,7 @@ struct nls_table {
74131 const unsigned char *charset2upper;
74132 struct module *owner;
74133 struct nls_table *next;
74134 -};
74135 +} __do_const;
74136
74137 /* this value hold the maximum octet of charset */
74138 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
74139 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
74140 index d14a4c3..a078786 100644
74141 --- a/include/linux/notifier.h
74142 +++ b/include/linux/notifier.h
74143 @@ -54,7 +54,8 @@ struct notifier_block {
74144 notifier_fn_t notifier_call;
74145 struct notifier_block __rcu *next;
74146 int priority;
74147 -};
74148 +} __do_const;
74149 +typedef struct notifier_block __no_const notifier_block_no_const;
74150
74151 struct atomic_notifier_head {
74152 spinlock_t lock;
74153 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
74154 index a4c5624..79d6d88 100644
74155 --- a/include/linux/oprofile.h
74156 +++ b/include/linux/oprofile.h
74157 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
74158 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
74159 char const * name, ulong * val);
74160
74161 -/** Create a file for read-only access to an atomic_t. */
74162 +/** Create a file for read-only access to an atomic_unchecked_t. */
74163 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
74164 - char const * name, atomic_t * val);
74165 + char const * name, atomic_unchecked_t * val);
74166
74167 /** create a directory */
74168 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
74169 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
74170 index 8db71dc..a76bf2c 100644
74171 --- a/include/linux/pci_hotplug.h
74172 +++ b/include/linux/pci_hotplug.h
74173 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
74174 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
74175 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
74176 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
74177 -};
74178 +} __do_const;
74179 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
74180
74181 /**
74182 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
74183 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
74184 index c5b6dbf..b124155 100644
74185 --- a/include/linux/perf_event.h
74186 +++ b/include/linux/perf_event.h
74187 @@ -318,8 +318,8 @@ struct perf_event {
74188
74189 enum perf_event_active_state state;
74190 unsigned int attach_state;
74191 - local64_t count;
74192 - atomic64_t child_count;
74193 + local64_t count; /* PaX: fix it one day */
74194 + atomic64_unchecked_t child_count;
74195
74196 /*
74197 * These are the total time in nanoseconds that the event
74198 @@ -370,8 +370,8 @@ struct perf_event {
74199 * These accumulate total time (in nanoseconds) that children
74200 * events have been enabled and running, respectively.
74201 */
74202 - atomic64_t child_total_time_enabled;
74203 - atomic64_t child_total_time_running;
74204 + atomic64_unchecked_t child_total_time_enabled;
74205 + atomic64_unchecked_t child_total_time_running;
74206
74207 /*
74208 * Protect attach/detach and child_list:
74209 @@ -692,7 +692,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
74210 entry->ip[entry->nr++] = ip;
74211 }
74212
74213 -extern int sysctl_perf_event_paranoid;
74214 +extern int sysctl_perf_event_legitimately_concerned;
74215 extern int sysctl_perf_event_mlock;
74216 extern int sysctl_perf_event_sample_rate;
74217
74218 @@ -700,19 +700,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
74219 void __user *buffer, size_t *lenp,
74220 loff_t *ppos);
74221
74222 +static inline bool perf_paranoid_any(void)
74223 +{
74224 + return sysctl_perf_event_legitimately_concerned > 2;
74225 +}
74226 +
74227 static inline bool perf_paranoid_tracepoint_raw(void)
74228 {
74229 - return sysctl_perf_event_paranoid > -1;
74230 + return sysctl_perf_event_legitimately_concerned > -1;
74231 }
74232
74233 static inline bool perf_paranoid_cpu(void)
74234 {
74235 - return sysctl_perf_event_paranoid > 0;
74236 + return sysctl_perf_event_legitimately_concerned > 0;
74237 }
74238
74239 static inline bool perf_paranoid_kernel(void)
74240 {
74241 - return sysctl_perf_event_paranoid > 1;
74242 + return sysctl_perf_event_legitimately_concerned > 1;
74243 }
74244
74245 extern void perf_event_init(void);
74246 @@ -806,7 +811,7 @@ static inline void perf_restore_debug_store(void) { }
74247 */
74248 #define perf_cpu_notifier(fn) \
74249 do { \
74250 - static struct notifier_block fn##_nb __cpuinitdata = \
74251 + static struct notifier_block fn##_nb = \
74252 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
74253 unsigned long cpu = smp_processor_id(); \
74254 unsigned long flags; \
74255 @@ -826,7 +831,7 @@ struct perf_pmu_events_attr {
74256 struct device_attribute attr;
74257 u64 id;
74258 const char *event_str;
74259 -};
74260 +} __do_const;
74261
74262 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
74263 static struct perf_pmu_events_attr _var = { \
74264 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
74265 index b8809fe..ae4ccd0 100644
74266 --- a/include/linux/pipe_fs_i.h
74267 +++ b/include/linux/pipe_fs_i.h
74268 @@ -47,10 +47,10 @@ struct pipe_inode_info {
74269 struct mutex mutex;
74270 wait_queue_head_t wait;
74271 unsigned int nrbufs, curbuf, buffers;
74272 - unsigned int readers;
74273 - unsigned int writers;
74274 - unsigned int files;
74275 - unsigned int waiting_writers;
74276 + atomic_t readers;
74277 + atomic_t writers;
74278 + atomic_t files;
74279 + atomic_t waiting_writers;
74280 unsigned int r_counter;
74281 unsigned int w_counter;
74282 struct page *tmp_page;
74283 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
74284 index 5f28cae..3d23723 100644
74285 --- a/include/linux/platform_data/usb-ehci-s5p.h
74286 +++ b/include/linux/platform_data/usb-ehci-s5p.h
74287 @@ -14,7 +14,7 @@
74288 struct s5p_ehci_platdata {
74289 int (*phy_init)(struct platform_device *pdev, int type);
74290 int (*phy_exit)(struct platform_device *pdev, int type);
74291 -};
74292 +} __no_const;
74293
74294 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
74295
74296 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
74297 index c256c59..8ea94c7 100644
74298 --- a/include/linux/platform_data/usb-ohci-exynos.h
74299 +++ b/include/linux/platform_data/usb-ohci-exynos.h
74300 @@ -14,7 +14,7 @@
74301 struct exynos4_ohci_platdata {
74302 int (*phy_init)(struct platform_device *pdev, int type);
74303 int (*phy_exit)(struct platform_device *pdev, int type);
74304 -};
74305 +} __no_const;
74306
74307 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
74308
74309 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
74310 index 7c1d252..c5c773e 100644
74311 --- a/include/linux/pm_domain.h
74312 +++ b/include/linux/pm_domain.h
74313 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
74314
74315 struct gpd_cpu_data {
74316 unsigned int saved_exit_latency;
74317 - struct cpuidle_state *idle_state;
74318 + cpuidle_state_no_const *idle_state;
74319 };
74320
74321 struct generic_pm_domain {
74322 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
74323 index 7d7e09e..8671ef8 100644
74324 --- a/include/linux/pm_runtime.h
74325 +++ b/include/linux/pm_runtime.h
74326 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
74327
74328 static inline void pm_runtime_mark_last_busy(struct device *dev)
74329 {
74330 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
74331 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
74332 }
74333
74334 #else /* !CONFIG_PM_RUNTIME */
74335 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
74336 index 195aafc..49a7bc2 100644
74337 --- a/include/linux/pnp.h
74338 +++ b/include/linux/pnp.h
74339 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
74340 struct pnp_fixup {
74341 char id[7];
74342 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
74343 -};
74344 +} __do_const;
74345
74346 /* config parameters */
74347 #define PNP_CONFIG_NORMAL 0x0001
74348 diff --git a/include/linux/poison.h b/include/linux/poison.h
74349 index 2110a81..13a11bb 100644
74350 --- a/include/linux/poison.h
74351 +++ b/include/linux/poison.h
74352 @@ -19,8 +19,8 @@
74353 * under normal circumstances, used to verify that nobody uses
74354 * non-initialized list entries.
74355 */
74356 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
74357 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
74358 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
74359 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
74360
74361 /********** include/linux/timer.h **********/
74362 /*
74363 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
74364 index c0f44c2..1572583 100644
74365 --- a/include/linux/power/smartreflex.h
74366 +++ b/include/linux/power/smartreflex.h
74367 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
74368 int (*notify)(struct omap_sr *sr, u32 status);
74369 u8 notify_flags;
74370 u8 class_type;
74371 -};
74372 +} __do_const;
74373
74374 /**
74375 * struct omap_sr_nvalue_table - Smartreflex n-target value info
74376 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
74377 index 4ea1d37..80f4b33 100644
74378 --- a/include/linux/ppp-comp.h
74379 +++ b/include/linux/ppp-comp.h
74380 @@ -84,7 +84,7 @@ struct compressor {
74381 struct module *owner;
74382 /* Extra skb space needed by the compressor algorithm */
74383 unsigned int comp_extra;
74384 -};
74385 +} __do_const;
74386
74387 /*
74388 * The return value from decompress routine is the length of the
74389 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
74390 index f5d4723..a6ea2fa 100644
74391 --- a/include/linux/preempt.h
74392 +++ b/include/linux/preempt.h
74393 @@ -18,8 +18,13 @@
74394 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
74395 #endif
74396
74397 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
74398 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
74399 +
74400 #define inc_preempt_count() add_preempt_count(1)
74401 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
74402 #define dec_preempt_count() sub_preempt_count(1)
74403 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
74404
74405 #define preempt_count() (current_thread_info()->preempt_count)
74406
74407 @@ -64,6 +69,12 @@ do { \
74408 barrier(); \
74409 } while (0)
74410
74411 +#define raw_preempt_disable() \
74412 +do { \
74413 + raw_inc_preempt_count(); \
74414 + barrier(); \
74415 +} while (0)
74416 +
74417 #define sched_preempt_enable_no_resched() \
74418 do { \
74419 barrier(); \
74420 @@ -72,6 +83,12 @@ do { \
74421
74422 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
74423
74424 +#define raw_preempt_enable_no_resched() \
74425 +do { \
74426 + barrier(); \
74427 + raw_dec_preempt_count(); \
74428 +} while (0)
74429 +
74430 #define preempt_enable() \
74431 do { \
74432 preempt_enable_no_resched(); \
74433 @@ -116,8 +133,10 @@ do { \
74434 * region.
74435 */
74436 #define preempt_disable() barrier()
74437 +#define raw_preempt_disable() barrier()
74438 #define sched_preempt_enable_no_resched() barrier()
74439 #define preempt_enable_no_resched() barrier()
74440 +#define raw_preempt_enable_no_resched() barrier()
74441 #define preempt_enable() barrier()
74442
74443 #define preempt_disable_notrace() barrier()
74444 diff --git a/include/linux/printk.h b/include/linux/printk.h
74445 index 22c7052..ad3fa0a 100644
74446 --- a/include/linux/printk.h
74447 +++ b/include/linux/printk.h
74448 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
74449 void early_printk(const char *s, ...) { }
74450 #endif
74451
74452 +extern int kptr_restrict;
74453 +
74454 #ifdef CONFIG_PRINTK
74455 asmlinkage __printf(5, 0)
74456 int vprintk_emit(int facility, int level,
74457 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
74458
74459 extern int printk_delay_msec;
74460 extern int dmesg_restrict;
74461 -extern int kptr_restrict;
74462
74463 extern void wake_up_klogd(void);
74464
74465 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
74466 index 608e60a..c26f864 100644
74467 --- a/include/linux/proc_fs.h
74468 +++ b/include/linux/proc_fs.h
74469 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
74470 return proc_create_data(name, mode, parent, proc_fops, NULL);
74471 }
74472
74473 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
74474 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
74475 +{
74476 +#ifdef CONFIG_GRKERNSEC_PROC_USER
74477 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
74478 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74479 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
74480 +#else
74481 + return proc_create_data(name, mode, parent, proc_fops, NULL);
74482 +#endif
74483 +}
74484 +
74485 +
74486 extern void proc_set_size(struct proc_dir_entry *, loff_t);
74487 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
74488 extern void *PDE_DATA(const struct inode *);
74489 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
74490 index 34a1e10..03a6d03 100644
74491 --- a/include/linux/proc_ns.h
74492 +++ b/include/linux/proc_ns.h
74493 @@ -14,7 +14,7 @@ struct proc_ns_operations {
74494 void (*put)(void *ns);
74495 int (*install)(struct nsproxy *nsproxy, void *ns);
74496 unsigned int (*inum)(void *ns);
74497 -};
74498 +} __do_const;
74499
74500 struct proc_ns {
74501 void *ns;
74502 diff --git a/include/linux/random.h b/include/linux/random.h
74503 index 3b9377d..61b506a 100644
74504 --- a/include/linux/random.h
74505 +++ b/include/linux/random.h
74506 @@ -32,6 +32,11 @@ void prandom_seed(u32 seed);
74507 u32 prandom_u32_state(struct rnd_state *);
74508 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
74509
74510 +static inline unsigned long pax_get_random_long(void)
74511 +{
74512 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
74513 +}
74514 +
74515 /*
74516 * Handle minimum values for seeds
74517 */
74518 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
74519 index f4b1001..8ddb2b6 100644
74520 --- a/include/linux/rculist.h
74521 +++ b/include/linux/rculist.h
74522 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
74523 struct list_head *prev, struct list_head *next);
74524 #endif
74525
74526 +extern void __pax_list_add_rcu(struct list_head *new,
74527 + struct list_head *prev, struct list_head *next);
74528 +
74529 /**
74530 * list_add_rcu - add a new entry to rcu-protected list
74531 * @new: new entry to be added
74532 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
74533 __list_add_rcu(new, head, head->next);
74534 }
74535
74536 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
74537 +{
74538 + __pax_list_add_rcu(new, head, head->next);
74539 +}
74540 +
74541 /**
74542 * list_add_tail_rcu - add a new entry to rcu-protected list
74543 * @new: new entry to be added
74544 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
74545 __list_add_rcu(new, head->prev, head);
74546 }
74547
74548 +static inline void pax_list_add_tail_rcu(struct list_head *new,
74549 + struct list_head *head)
74550 +{
74551 + __pax_list_add_rcu(new, head->prev, head);
74552 +}
74553 +
74554 /**
74555 * list_del_rcu - deletes entry from list without re-initialization
74556 * @entry: the element to delete from the list.
74557 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
74558 entry->prev = LIST_POISON2;
74559 }
74560
74561 +extern void pax_list_del_rcu(struct list_head *entry);
74562 +
74563 /**
74564 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
74565 * @n: the element to delete from the hash list.
74566 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
74567 index 23b3630..e1bc12b 100644
74568 --- a/include/linux/reboot.h
74569 +++ b/include/linux/reboot.h
74570 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
74571 * Architecture-specific implementations of sys_reboot commands.
74572 */
74573
74574 -extern void machine_restart(char *cmd);
74575 -extern void machine_halt(void);
74576 -extern void machine_power_off(void);
74577 +extern void machine_restart(char *cmd) __noreturn;
74578 +extern void machine_halt(void) __noreturn;
74579 +extern void machine_power_off(void) __noreturn;
74580
74581 extern void machine_shutdown(void);
74582 struct pt_regs;
74583 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
74584 */
74585
74586 extern void kernel_restart_prepare(char *cmd);
74587 -extern void kernel_restart(char *cmd);
74588 -extern void kernel_halt(void);
74589 -extern void kernel_power_off(void);
74590 +extern void kernel_restart(char *cmd) __noreturn;
74591 +extern void kernel_halt(void) __noreturn;
74592 +extern void kernel_power_off(void) __noreturn;
74593
74594 extern int C_A_D; /* for sysctl */
74595 void ctrl_alt_del(void);
74596 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
74597 * Emergency restart, callable from an interrupt handler.
74598 */
74599
74600 -extern void emergency_restart(void);
74601 +extern void emergency_restart(void) __noreturn;
74602 #include <asm/emergency-restart.h>
74603
74604 #endif /* _LINUX_REBOOT_H */
74605 diff --git a/include/linux/regset.h b/include/linux/regset.h
74606 index 8e0c9fe..ac4d221 100644
74607 --- a/include/linux/regset.h
74608 +++ b/include/linux/regset.h
74609 @@ -161,7 +161,8 @@ struct user_regset {
74610 unsigned int align;
74611 unsigned int bias;
74612 unsigned int core_note_type;
74613 -};
74614 +} __do_const;
74615 +typedef struct user_regset __no_const user_regset_no_const;
74616
74617 /**
74618 * struct user_regset_view - available regsets
74619 diff --git a/include/linux/relay.h b/include/linux/relay.h
74620 index d7c8359..818daf5 100644
74621 --- a/include/linux/relay.h
74622 +++ b/include/linux/relay.h
74623 @@ -157,7 +157,7 @@ struct rchan_callbacks
74624 * The callback should return 0 if successful, negative if not.
74625 */
74626 int (*remove_buf_file)(struct dentry *dentry);
74627 -};
74628 +} __no_const;
74629
74630 /*
74631 * CONFIG_RELAY kernel API, kernel/relay.c
74632 diff --git a/include/linux/rio.h b/include/linux/rio.h
74633 index 18e0993..8ab5b21 100644
74634 --- a/include/linux/rio.h
74635 +++ b/include/linux/rio.h
74636 @@ -345,7 +345,7 @@ struct rio_ops {
74637 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
74638 u64 rstart, u32 size, u32 flags);
74639 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
74640 -};
74641 +} __no_const;
74642
74643 #define RIO_RESOURCE_MEM 0x00000100
74644 #define RIO_RESOURCE_DOORBELL 0x00000200
74645 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
74646 index 6dacb93..6174423 100644
74647 --- a/include/linux/rmap.h
74648 +++ b/include/linux/rmap.h
74649 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
74650 void anon_vma_init(void); /* create anon_vma_cachep */
74651 int anon_vma_prepare(struct vm_area_struct *);
74652 void unlink_anon_vmas(struct vm_area_struct *);
74653 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
74654 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
74655 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
74656 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
74657
74658 static inline void anon_vma_merge(struct vm_area_struct *vma,
74659 struct vm_area_struct *next)
74660 diff --git a/include/linux/sched.h b/include/linux/sched.h
74661 index 178a8d9..450bf11 100644
74662 --- a/include/linux/sched.h
74663 +++ b/include/linux/sched.h
74664 @@ -62,6 +62,7 @@ struct bio_list;
74665 struct fs_struct;
74666 struct perf_event_context;
74667 struct blk_plug;
74668 +struct linux_binprm;
74669
74670 /*
74671 * List of flags we want to share for kernel threads,
74672 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
74673 extern int in_sched_functions(unsigned long addr);
74674
74675 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
74676 -extern signed long schedule_timeout(signed long timeout);
74677 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
74678 extern signed long schedule_timeout_interruptible(signed long timeout);
74679 extern signed long schedule_timeout_killable(signed long timeout);
74680 extern signed long schedule_timeout_uninterruptible(signed long timeout);
74681 @@ -314,6 +315,19 @@ struct nsproxy;
74682 struct user_namespace;
74683
74684 #ifdef CONFIG_MMU
74685 +
74686 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
74687 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
74688 +#else
74689 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
74690 +{
74691 + return 0;
74692 +}
74693 +#endif
74694 +
74695 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
74696 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
74697 +
74698 extern void arch_pick_mmap_layout(struct mm_struct *mm);
74699 extern unsigned long
74700 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
74701 @@ -591,6 +605,17 @@ struct signal_struct {
74702 #ifdef CONFIG_TASKSTATS
74703 struct taskstats *stats;
74704 #endif
74705 +
74706 +#ifdef CONFIG_GRKERNSEC
74707 + u32 curr_ip;
74708 + u32 saved_ip;
74709 + u32 gr_saddr;
74710 + u32 gr_daddr;
74711 + u16 gr_sport;
74712 + u16 gr_dport;
74713 + u8 used_accept:1;
74714 +#endif
74715 +
74716 #ifdef CONFIG_AUDIT
74717 unsigned audit_tty;
74718 unsigned audit_tty_log_passwd;
74719 @@ -671,6 +696,14 @@ struct user_struct {
74720 struct key *session_keyring; /* UID's default session keyring */
74721 #endif
74722
74723 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
74724 + unsigned char kernel_banned;
74725 +#endif
74726 +#ifdef CONFIG_GRKERNSEC_BRUTE
74727 + unsigned char suid_banned;
74728 + unsigned long suid_ban_expires;
74729 +#endif
74730 +
74731 /* Hash table maintenance information */
74732 struct hlist_node uidhash_node;
74733 kuid_t uid;
74734 @@ -1158,8 +1191,8 @@ struct task_struct {
74735 struct list_head thread_group;
74736
74737 struct completion *vfork_done; /* for vfork() */
74738 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
74739 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
74740 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
74741 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
74742
74743 cputime_t utime, stime, utimescaled, stimescaled;
74744 cputime_t gtime;
74745 @@ -1184,11 +1217,6 @@ struct task_struct {
74746 struct task_cputime cputime_expires;
74747 struct list_head cpu_timers[3];
74748
74749 -/* process credentials */
74750 - const struct cred __rcu *real_cred; /* objective and real subjective task
74751 - * credentials (COW) */
74752 - const struct cred __rcu *cred; /* effective (overridable) subjective task
74753 - * credentials (COW) */
74754 char comm[TASK_COMM_LEN]; /* executable name excluding path
74755 - access with [gs]et_task_comm (which lock
74756 it with task_lock())
74757 @@ -1205,6 +1233,10 @@ struct task_struct {
74758 #endif
74759 /* CPU-specific state of this task */
74760 struct thread_struct thread;
74761 +/* thread_info moved to task_struct */
74762 +#ifdef CONFIG_X86
74763 + struct thread_info tinfo;
74764 +#endif
74765 /* filesystem information */
74766 struct fs_struct *fs;
74767 /* open file information */
74768 @@ -1278,6 +1310,10 @@ struct task_struct {
74769 gfp_t lockdep_reclaim_gfp;
74770 #endif
74771
74772 +/* process credentials */
74773 + const struct cred __rcu *real_cred; /* objective and real subjective task
74774 + * credentials (COW) */
74775 +
74776 /* journalling filesystem info */
74777 void *journal_info;
74778
74779 @@ -1316,6 +1352,10 @@ struct task_struct {
74780 /* cg_list protected by css_set_lock and tsk->alloc_lock */
74781 struct list_head cg_list;
74782 #endif
74783 +
74784 + const struct cred __rcu *cred; /* effective (overridable) subjective task
74785 + * credentials (COW) */
74786 +
74787 #ifdef CONFIG_FUTEX
74788 struct robust_list_head __user *robust_list;
74789 #ifdef CONFIG_COMPAT
74790 @@ -1416,8 +1456,76 @@ struct task_struct {
74791 unsigned int sequential_io;
74792 unsigned int sequential_io_avg;
74793 #endif
74794 +
74795 +#ifdef CONFIG_GRKERNSEC
74796 + /* grsecurity */
74797 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
74798 + u64 exec_id;
74799 +#endif
74800 +#ifdef CONFIG_GRKERNSEC_SETXID
74801 + const struct cred *delayed_cred;
74802 +#endif
74803 + struct dentry *gr_chroot_dentry;
74804 + struct acl_subject_label *acl;
74805 + struct acl_role_label *role;
74806 + struct file *exec_file;
74807 + unsigned long brute_expires;
74808 + u16 acl_role_id;
74809 + /* is this the task that authenticated to the special role */
74810 + u8 acl_sp_role;
74811 + u8 is_writable;
74812 + u8 brute;
74813 + u8 gr_is_chrooted;
74814 +#endif
74815 +
74816 };
74817
74818 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
74819 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
74820 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
74821 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
74822 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
74823 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
74824 +
74825 +#ifdef CONFIG_PAX_SOFTMODE
74826 +extern int pax_softmode;
74827 +#endif
74828 +
74829 +extern int pax_check_flags(unsigned long *);
74830 +
74831 +/* if tsk != current then task_lock must be held on it */
74832 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74833 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
74834 +{
74835 + if (likely(tsk->mm))
74836 + return tsk->mm->pax_flags;
74837 + else
74838 + return 0UL;
74839 +}
74840 +
74841 +/* if tsk != current then task_lock must be held on it */
74842 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
74843 +{
74844 + if (likely(tsk->mm)) {
74845 + tsk->mm->pax_flags = flags;
74846 + return 0;
74847 + }
74848 + return -EINVAL;
74849 +}
74850 +#endif
74851 +
74852 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
74853 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
74854 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
74855 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
74856 +#endif
74857 +
74858 +struct path;
74859 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
74860 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
74861 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
74862 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
74863 +
74864 /* Future-safe accessor for struct task_struct's cpus_allowed. */
74865 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
74866
74867 @@ -1476,7 +1584,7 @@ struct pid_namespace;
74868 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
74869 struct pid_namespace *ns);
74870
74871 -static inline pid_t task_pid_nr(struct task_struct *tsk)
74872 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
74873 {
74874 return tsk->pid;
74875 }
74876 @@ -1919,7 +2027,9 @@ void yield(void);
74877 extern struct exec_domain default_exec_domain;
74878
74879 union thread_union {
74880 +#ifndef CONFIG_X86
74881 struct thread_info thread_info;
74882 +#endif
74883 unsigned long stack[THREAD_SIZE/sizeof(long)];
74884 };
74885
74886 @@ -1952,6 +2062,7 @@ extern struct pid_namespace init_pid_ns;
74887 */
74888
74889 extern struct task_struct *find_task_by_vpid(pid_t nr);
74890 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
74891 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
74892 struct pid_namespace *ns);
74893
74894 @@ -2118,7 +2229,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
74895 extern void exit_itimers(struct signal_struct *);
74896 extern void flush_itimer_signals(void);
74897
74898 -extern void do_group_exit(int);
74899 +extern __noreturn void do_group_exit(int);
74900
74901 extern int allow_signal(int);
74902 extern int disallow_signal(int);
74903 @@ -2309,9 +2420,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
74904
74905 #endif
74906
74907 -static inline int object_is_on_stack(void *obj)
74908 +static inline int object_starts_on_stack(void *obj)
74909 {
74910 - void *stack = task_stack_page(current);
74911 + const void *stack = task_stack_page(current);
74912
74913 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
74914 }
74915 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
74916 index bf8086b..962b035 100644
74917 --- a/include/linux/sched/sysctl.h
74918 +++ b/include/linux/sched/sysctl.h
74919 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
74920 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
74921
74922 extern int sysctl_max_map_count;
74923 +extern unsigned long sysctl_heap_stack_gap;
74924
74925 extern unsigned int sysctl_sched_latency;
74926 extern unsigned int sysctl_sched_min_granularity;
74927 diff --git a/include/linux/security.h b/include/linux/security.h
74928 index 4686491..2bd210e 100644
74929 --- a/include/linux/security.h
74930 +++ b/include/linux/security.h
74931 @@ -26,6 +26,7 @@
74932 #include <linux/capability.h>
74933 #include <linux/slab.h>
74934 #include <linux/err.h>
74935 +#include <linux/grsecurity.h>
74936
74937 struct linux_binprm;
74938 struct cred;
74939 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
74940 index 2da29ac..aac448ec 100644
74941 --- a/include/linux/seq_file.h
74942 +++ b/include/linux/seq_file.h
74943 @@ -26,6 +26,9 @@ struct seq_file {
74944 struct mutex lock;
74945 const struct seq_operations *op;
74946 int poll_event;
74947 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
74948 + u64 exec_id;
74949 +#endif
74950 #ifdef CONFIG_USER_NS
74951 struct user_namespace *user_ns;
74952 #endif
74953 @@ -38,6 +41,7 @@ struct seq_operations {
74954 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
74955 int (*show) (struct seq_file *m, void *v);
74956 };
74957 +typedef struct seq_operations __no_const seq_operations_no_const;
74958
74959 #define SEQ_SKIP 1
74960
74961 diff --git a/include/linux/shm.h b/include/linux/shm.h
74962 index 429c199..4d42e38 100644
74963 --- a/include/linux/shm.h
74964 +++ b/include/linux/shm.h
74965 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
74966
74967 /* The task created the shm object. NULL if the task is dead. */
74968 struct task_struct *shm_creator;
74969 +#ifdef CONFIG_GRKERNSEC
74970 + time_t shm_createtime;
74971 + pid_t shm_lapid;
74972 +#endif
74973 };
74974
74975 /* shm_mode upper byte flags */
74976 diff --git a/include/linux/signal.h b/include/linux/signal.h
74977 index d897484..323ba98 100644
74978 --- a/include/linux/signal.h
74979 +++ b/include/linux/signal.h
74980 @@ -433,6 +433,7 @@ void signals_init(void);
74981
74982 int restore_altstack(const stack_t __user *);
74983 int __save_altstack(stack_t __user *, unsigned long);
74984 +void __save_altstack_ex(stack_t __user *, unsigned long);
74985
74986 #ifdef CONFIG_PROC_FS
74987 struct seq_file;
74988 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
74989 index dec1748..112c1f9 100644
74990 --- a/include/linux/skbuff.h
74991 +++ b/include/linux/skbuff.h
74992 @@ -640,7 +640,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
74993 extern struct sk_buff *__alloc_skb(unsigned int size,
74994 gfp_t priority, int flags, int node);
74995 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
74996 -static inline struct sk_buff *alloc_skb(unsigned int size,
74997 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
74998 gfp_t priority)
74999 {
75000 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
75001 @@ -756,7 +756,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
75002 */
75003 static inline int skb_queue_empty(const struct sk_buff_head *list)
75004 {
75005 - return list->next == (struct sk_buff *)list;
75006 + return list->next == (const struct sk_buff *)list;
75007 }
75008
75009 /**
75010 @@ -769,7 +769,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
75011 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
75012 const struct sk_buff *skb)
75013 {
75014 - return skb->next == (struct sk_buff *)list;
75015 + return skb->next == (const struct sk_buff *)list;
75016 }
75017
75018 /**
75019 @@ -782,7 +782,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
75020 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
75021 const struct sk_buff *skb)
75022 {
75023 - return skb->prev == (struct sk_buff *)list;
75024 + return skb->prev == (const struct sk_buff *)list;
75025 }
75026
75027 /**
75028 @@ -1848,7 +1848,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
75029 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
75030 */
75031 #ifndef NET_SKB_PAD
75032 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
75033 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
75034 #endif
75035
75036 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
75037 @@ -2443,7 +2443,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
75038 int noblock, int *err);
75039 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
75040 struct poll_table_struct *wait);
75041 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
75042 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
75043 int offset, struct iovec *to,
75044 int size);
75045 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
75046 @@ -2733,6 +2733,9 @@ static inline void nf_reset(struct sk_buff *skb)
75047 nf_bridge_put(skb->nf_bridge);
75048 skb->nf_bridge = NULL;
75049 #endif
75050 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
75051 + skb->nf_trace = 0;
75052 +#endif
75053 }
75054
75055 static inline void nf_reset_trace(struct sk_buff *skb)
75056 diff --git a/include/linux/slab.h b/include/linux/slab.h
75057 index 0c62175..f016ac1 100644
75058 --- a/include/linux/slab.h
75059 +++ b/include/linux/slab.h
75060 @@ -12,15 +12,29 @@
75061 #include <linux/gfp.h>
75062 #include <linux/types.h>
75063 #include <linux/workqueue.h>
75064 -
75065 +#include <linux/err.h>
75066
75067 /*
75068 * Flags to pass to kmem_cache_create().
75069 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
75070 */
75071 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
75072 +
75073 +#ifdef CONFIG_PAX_USERCOPY_SLABS
75074 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
75075 +#else
75076 +#define SLAB_USERCOPY 0x00000000UL
75077 +#endif
75078 +
75079 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
75080 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
75081 +
75082 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
75083 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
75084 +#else
75085 +#define SLAB_NO_SANITIZE 0x00000000UL
75086 +#endif
75087 +
75088 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
75089 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
75090 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
75091 @@ -89,10 +103,13 @@
75092 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
75093 * Both make kfree a no-op.
75094 */
75095 -#define ZERO_SIZE_PTR ((void *)16)
75096 +#define ZERO_SIZE_PTR \
75097 +({ \
75098 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
75099 + (void *)(-MAX_ERRNO-1L); \
75100 +})
75101
75102 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
75103 - (unsigned long)ZERO_SIZE_PTR)
75104 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
75105
75106
75107 struct mem_cgroup;
75108 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
75109 void kfree(const void *);
75110 void kzfree(const void *);
75111 size_t ksize(const void *);
75112 +const char *check_heap_object(const void *ptr, unsigned long n);
75113 +bool is_usercopy_object(const void *ptr);
75114
75115 /*
75116 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
75117 @@ -164,7 +183,7 @@ struct kmem_cache {
75118 unsigned int align; /* Alignment as calculated */
75119 unsigned long flags; /* Active flags on the slab */
75120 const char *name; /* Slab name for sysfs */
75121 - int refcount; /* Use counter */
75122 + atomic_t refcount; /* Use counter */
75123 void (*ctor)(void *); /* Called on object slot creation */
75124 struct list_head list; /* List of all slab caches on the system */
75125 };
75126 @@ -226,6 +245,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
75127 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
75128 #endif
75129
75130 +#ifdef CONFIG_PAX_USERCOPY_SLABS
75131 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
75132 +#endif
75133 +
75134 /*
75135 * Figure out which kmalloc slab an allocation of a certain size
75136 * belongs to.
75137 @@ -234,7 +257,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
75138 * 2 = 120 .. 192 bytes
75139 * n = 2^(n-1) .. 2^n -1
75140 */
75141 -static __always_inline int kmalloc_index(size_t size)
75142 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
75143 {
75144 if (!size)
75145 return 0;
75146 @@ -406,6 +429,7 @@ void print_slabinfo_header(struct seq_file *m);
75147 * for general use, and so are not documented here. For a full list of
75148 * potential flags, always refer to linux/gfp.h.
75149 */
75150 +
75151 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
75152 {
75153 if (size != 0 && n > SIZE_MAX / size)
75154 @@ -465,7 +489,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
75155 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
75156 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
75157 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
75158 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
75159 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
75160 #define kmalloc_track_caller(size, flags) \
75161 __kmalloc_track_caller(size, flags, _RET_IP_)
75162 #else
75163 @@ -485,7 +509,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
75164 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
75165 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
75166 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
75167 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
75168 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
75169 #define kmalloc_node_track_caller(size, flags, node) \
75170 __kmalloc_node_track_caller(size, flags, node, \
75171 _RET_IP_)
75172 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
75173 index cd40158..4e2f7af 100644
75174 --- a/include/linux/slab_def.h
75175 +++ b/include/linux/slab_def.h
75176 @@ -50,7 +50,7 @@ struct kmem_cache {
75177 /* 4) cache creation/removal */
75178 const char *name;
75179 struct list_head list;
75180 - int refcount;
75181 + atomic_t refcount;
75182 int object_size;
75183 int align;
75184
75185 @@ -66,10 +66,14 @@ struct kmem_cache {
75186 unsigned long node_allocs;
75187 unsigned long node_frees;
75188 unsigned long node_overflow;
75189 - atomic_t allochit;
75190 - atomic_t allocmiss;
75191 - atomic_t freehit;
75192 - atomic_t freemiss;
75193 + atomic_unchecked_t allochit;
75194 + atomic_unchecked_t allocmiss;
75195 + atomic_unchecked_t freehit;
75196 + atomic_unchecked_t freemiss;
75197 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
75198 + atomic_unchecked_t sanitized;
75199 + atomic_unchecked_t not_sanitized;
75200 +#endif
75201
75202 /*
75203 * If debugging is enabled, then the allocator can add additional
75204 @@ -103,7 +107,7 @@ struct kmem_cache {
75205 };
75206
75207 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
75208 -void *__kmalloc(size_t size, gfp_t flags);
75209 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
75210
75211 #ifdef CONFIG_TRACING
75212 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
75213 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
75214 cachep = kmalloc_dma_caches[i];
75215 else
75216 #endif
75217 +
75218 +#ifdef CONFIG_PAX_USERCOPY_SLABS
75219 + if (flags & GFP_USERCOPY)
75220 + cachep = kmalloc_usercopy_caches[i];
75221 + else
75222 +#endif
75223 +
75224 cachep = kmalloc_caches[i];
75225
75226 ret = kmem_cache_alloc_trace(cachep, flags, size);
75227 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
75228 }
75229
75230 #ifdef CONFIG_NUMA
75231 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
75232 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
75233 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
75234
75235 #ifdef CONFIG_TRACING
75236 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
75237 cachep = kmalloc_dma_caches[i];
75238 else
75239 #endif
75240 +
75241 +#ifdef CONFIG_PAX_USERCOPY_SLABS
75242 + if (flags & GFP_USERCOPY)
75243 + cachep = kmalloc_usercopy_caches[i];
75244 + else
75245 +#endif
75246 +
75247 cachep = kmalloc_caches[i];
75248
75249 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
75250 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
75251 index f28e14a..7831211 100644
75252 --- a/include/linux/slob_def.h
75253 +++ b/include/linux/slob_def.h
75254 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
75255 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
75256 }
75257
75258 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
75259 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
75260
75261 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
75262 {
75263 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
75264 return __kmalloc_node(size, flags, NUMA_NO_NODE);
75265 }
75266
75267 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
75268 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
75269 {
75270 return kmalloc(size, flags);
75271 }
75272 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
75273 index 027276f..092bfe8 100644
75274 --- a/include/linux/slub_def.h
75275 +++ b/include/linux/slub_def.h
75276 @@ -80,7 +80,7 @@ struct kmem_cache {
75277 struct kmem_cache_order_objects max;
75278 struct kmem_cache_order_objects min;
75279 gfp_t allocflags; /* gfp flags to use on each alloc */
75280 - int refcount; /* Refcount for slab cache destroy */
75281 + atomic_t refcount; /* Refcount for slab cache destroy */
75282 void (*ctor)(void *);
75283 int inuse; /* Offset to metadata */
75284 int align; /* Alignment */
75285 @@ -105,7 +105,7 @@ struct kmem_cache {
75286 };
75287
75288 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
75289 -void *__kmalloc(size_t size, gfp_t flags);
75290 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
75291
75292 static __always_inline void *
75293 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
75294 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
75295 }
75296 #endif
75297
75298 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
75299 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
75300 {
75301 unsigned int order = get_order(size);
75302 return kmalloc_order_trace(size, flags, order);
75303 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
75304 }
75305
75306 #ifdef CONFIG_NUMA
75307 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
75308 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
75309 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
75310
75311 #ifdef CONFIG_TRACING
75312 diff --git a/include/linux/smp.h b/include/linux/smp.h
75313 index c848876..11e8a84 100644
75314 --- a/include/linux/smp.h
75315 +++ b/include/linux/smp.h
75316 @@ -221,7 +221,9 @@ static inline void kick_all_cpus_sync(void) { }
75317 #endif
75318
75319 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
75320 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
75321 #define put_cpu() preempt_enable()
75322 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
75323
75324 /*
75325 * Callback to arch code if there's nosmp or maxcpus=0 on the
75326 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
75327 index 54f91d3..be2c379 100644
75328 --- a/include/linux/sock_diag.h
75329 +++ b/include/linux/sock_diag.h
75330 @@ -11,7 +11,7 @@ struct sock;
75331 struct sock_diag_handler {
75332 __u8 family;
75333 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
75334 -};
75335 +} __do_const;
75336
75337 int sock_diag_register(const struct sock_diag_handler *h);
75338 void sock_diag_unregister(const struct sock_diag_handler *h);
75339 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
75340 index 680f9a3..f13aeb0 100644
75341 --- a/include/linux/sonet.h
75342 +++ b/include/linux/sonet.h
75343 @@ -7,7 +7,7 @@
75344 #include <uapi/linux/sonet.h>
75345
75346 struct k_sonet_stats {
75347 -#define __HANDLE_ITEM(i) atomic_t i
75348 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
75349 __SONET_ITEMS
75350 #undef __HANDLE_ITEM
75351 };
75352 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
75353 index 07d8e53..dc934c9 100644
75354 --- a/include/linux/sunrpc/addr.h
75355 +++ b/include/linux/sunrpc/addr.h
75356 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
75357 {
75358 switch (sap->sa_family) {
75359 case AF_INET:
75360 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
75361 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
75362 case AF_INET6:
75363 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
75364 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
75365 }
75366 return 0;
75367 }
75368 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
75369 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
75370 const struct sockaddr *src)
75371 {
75372 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
75373 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
75374 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
75375
75376 dsin->sin_family = ssin->sin_family;
75377 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
75378 if (sa->sa_family != AF_INET6)
75379 return 0;
75380
75381 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
75382 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
75383 }
75384
75385 #endif /* _LINUX_SUNRPC_ADDR_H */
75386 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
75387 index bfe11be..12bc8c4 100644
75388 --- a/include/linux/sunrpc/clnt.h
75389 +++ b/include/linux/sunrpc/clnt.h
75390 @@ -96,7 +96,7 @@ struct rpc_procinfo {
75391 unsigned int p_timer; /* Which RTT timer to use */
75392 u32 p_statidx; /* Which procedure to account */
75393 const char * p_name; /* name of procedure */
75394 -};
75395 +} __do_const;
75396
75397 #ifdef __KERNEL__
75398
75399 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
75400 index 1f0216b..6a4fa50 100644
75401 --- a/include/linux/sunrpc/svc.h
75402 +++ b/include/linux/sunrpc/svc.h
75403 @@ -411,7 +411,7 @@ struct svc_procedure {
75404 unsigned int pc_count; /* call count */
75405 unsigned int pc_cachetype; /* cache info (NFS) */
75406 unsigned int pc_xdrressize; /* maximum size of XDR reply */
75407 -};
75408 +} __do_const;
75409
75410 /*
75411 * Function prototypes.
75412 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
75413 index 0b8e3e6..33e0a01 100644
75414 --- a/include/linux/sunrpc/svc_rdma.h
75415 +++ b/include/linux/sunrpc/svc_rdma.h
75416 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
75417 extern unsigned int svcrdma_max_requests;
75418 extern unsigned int svcrdma_max_req_size;
75419
75420 -extern atomic_t rdma_stat_recv;
75421 -extern atomic_t rdma_stat_read;
75422 -extern atomic_t rdma_stat_write;
75423 -extern atomic_t rdma_stat_sq_starve;
75424 -extern atomic_t rdma_stat_rq_starve;
75425 -extern atomic_t rdma_stat_rq_poll;
75426 -extern atomic_t rdma_stat_rq_prod;
75427 -extern atomic_t rdma_stat_sq_poll;
75428 -extern atomic_t rdma_stat_sq_prod;
75429 +extern atomic_unchecked_t rdma_stat_recv;
75430 +extern atomic_unchecked_t rdma_stat_read;
75431 +extern atomic_unchecked_t rdma_stat_write;
75432 +extern atomic_unchecked_t rdma_stat_sq_starve;
75433 +extern atomic_unchecked_t rdma_stat_rq_starve;
75434 +extern atomic_unchecked_t rdma_stat_rq_poll;
75435 +extern atomic_unchecked_t rdma_stat_rq_prod;
75436 +extern atomic_unchecked_t rdma_stat_sq_poll;
75437 +extern atomic_unchecked_t rdma_stat_sq_prod;
75438
75439 #define RPCRDMA_VERSION 1
75440
75441 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
75442 index ff374ab..7fd2ecb 100644
75443 --- a/include/linux/sunrpc/svcauth.h
75444 +++ b/include/linux/sunrpc/svcauth.h
75445 @@ -109,7 +109,7 @@ struct auth_ops {
75446 int (*release)(struct svc_rqst *rq);
75447 void (*domain_release)(struct auth_domain *);
75448 int (*set_client)(struct svc_rqst *rq);
75449 -};
75450 +} __do_const;
75451
75452 #define SVC_GARBAGE 1
75453 #define SVC_SYSERR 2
75454 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
75455 index a5ffd32..0935dea 100644
75456 --- a/include/linux/swiotlb.h
75457 +++ b/include/linux/swiotlb.h
75458 @@ -60,7 +60,8 @@ extern void
75459
75460 extern void
75461 swiotlb_free_coherent(struct device *hwdev, size_t size,
75462 - void *vaddr, dma_addr_t dma_handle);
75463 + void *vaddr, dma_addr_t dma_handle,
75464 + struct dma_attrs *attrs);
75465
75466 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
75467 unsigned long offset, size_t size,
75468 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
75469 index 4147d70..d356a10 100644
75470 --- a/include/linux/syscalls.h
75471 +++ b/include/linux/syscalls.h
75472 @@ -97,8 +97,12 @@ struct sigaltstack;
75473 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
75474
75475 #define __SC_DECL(t, a) t a
75476 -#define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
75477 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
75478 +#define __TYPE_IS_SL(t) (__same_type((t)0, 0L))
75479 +#define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
75480 +#define __TYPE_IS_SLL(t) (__same_type((t)0, 0LL))
75481 +#define __TYPE_IS_ULL(t) (__same_type((t)0, 0ULL))
75482 +#define __TYPE_IS_LL(t) (__TYPE_IS_SLL(t) || __TYPE_IS_ULL(t))
75483 +#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), __builtin_choose_expr(__TYPE_IS_ULL(t), 0ULL, 0LL), __builtin_choose_expr(__TYPE_IS_UL(t), 0UL, 0L))) a
75484 #define __SC_CAST(t, a) (t) a
75485 #define __SC_ARGS(t, a) a
75486 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
75487 @@ -362,11 +366,11 @@ asmlinkage long sys_sync(void);
75488 asmlinkage long sys_fsync(unsigned int fd);
75489 asmlinkage long sys_fdatasync(unsigned int fd);
75490 asmlinkage long sys_bdflush(int func, long data);
75491 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
75492 - char __user *type, unsigned long flags,
75493 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
75494 + const char __user *type, unsigned long flags,
75495 void __user *data);
75496 -asmlinkage long sys_umount(char __user *name, int flags);
75497 -asmlinkage long sys_oldumount(char __user *name);
75498 +asmlinkage long sys_umount(const char __user *name, int flags);
75499 +asmlinkage long sys_oldumount(const char __user *name);
75500 asmlinkage long sys_truncate(const char __user *path, long length);
75501 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
75502 asmlinkage long sys_stat(const char __user *filename,
75503 @@ -578,7 +582,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
75504 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
75505 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
75506 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
75507 - struct sockaddr __user *, int);
75508 + struct sockaddr __user *, int) __intentional_overflow(0);
75509 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
75510 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
75511 unsigned int vlen, unsigned flags);
75512 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
75513 index 27b3b0b..e093dd9 100644
75514 --- a/include/linux/syscore_ops.h
75515 +++ b/include/linux/syscore_ops.h
75516 @@ -16,7 +16,7 @@ struct syscore_ops {
75517 int (*suspend)(void);
75518 void (*resume)(void);
75519 void (*shutdown)(void);
75520 -};
75521 +} __do_const;
75522
75523 extern void register_syscore_ops(struct syscore_ops *ops);
75524 extern void unregister_syscore_ops(struct syscore_ops *ops);
75525 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
75526 index 14a8ff2..af52bad 100644
75527 --- a/include/linux/sysctl.h
75528 +++ b/include/linux/sysctl.h
75529 @@ -34,13 +34,13 @@ struct ctl_table_root;
75530 struct ctl_table_header;
75531 struct ctl_dir;
75532
75533 -typedef struct ctl_table ctl_table;
75534 -
75535 typedef int proc_handler (struct ctl_table *ctl, int write,
75536 void __user *buffer, size_t *lenp, loff_t *ppos);
75537
75538 extern int proc_dostring(struct ctl_table *, int,
75539 void __user *, size_t *, loff_t *);
75540 +extern int proc_dostring_modpriv(struct ctl_table *, int,
75541 + void __user *, size_t *, loff_t *);
75542 extern int proc_dointvec(struct ctl_table *, int,
75543 void __user *, size_t *, loff_t *);
75544 extern int proc_dointvec_minmax(struct ctl_table *, int,
75545 @@ -115,7 +115,9 @@ struct ctl_table
75546 struct ctl_table_poll *poll;
75547 void *extra1;
75548 void *extra2;
75549 -};
75550 +} __do_const;
75551 +typedef struct ctl_table __no_const ctl_table_no_const;
75552 +typedef struct ctl_table ctl_table;
75553
75554 struct ctl_node {
75555 struct rb_node node;
75556 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
75557 index e2cee22..3ddb921 100644
75558 --- a/include/linux/sysfs.h
75559 +++ b/include/linux/sysfs.h
75560 @@ -31,7 +31,8 @@ struct attribute {
75561 struct lock_class_key *key;
75562 struct lock_class_key skey;
75563 #endif
75564 -};
75565 +} __do_const;
75566 +typedef struct attribute __no_const attribute_no_const;
75567
75568 /**
75569 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
75570 @@ -59,8 +60,8 @@ struct attribute_group {
75571 umode_t (*is_visible)(struct kobject *,
75572 struct attribute *, int);
75573 struct attribute **attrs;
75574 -};
75575 -
75576 +} __do_const;
75577 +typedef struct attribute_group __no_const attribute_group_no_const;
75578
75579
75580 /**
75581 @@ -107,7 +108,8 @@ struct bin_attribute {
75582 char *, loff_t, size_t);
75583 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
75584 struct vm_area_struct *vma);
75585 -};
75586 +} __do_const;
75587 +typedef struct bin_attribute __no_const bin_attribute_no_const;
75588
75589 /**
75590 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
75591 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
75592 index 7faf933..9b85a0c 100644
75593 --- a/include/linux/sysrq.h
75594 +++ b/include/linux/sysrq.h
75595 @@ -16,6 +16,7 @@
75596
75597 #include <linux/errno.h>
75598 #include <linux/types.h>
75599 +#include <linux/compiler.h>
75600
75601 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
75602 #define SYSRQ_DEFAULT_ENABLE 1
75603 @@ -36,7 +37,7 @@ struct sysrq_key_op {
75604 char *help_msg;
75605 char *action_msg;
75606 int enable_mask;
75607 -};
75608 +} __do_const;
75609
75610 #ifdef CONFIG_MAGIC_SYSRQ
75611
75612 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
75613 index e7e0473..7989295 100644
75614 --- a/include/linux/thread_info.h
75615 +++ b/include/linux/thread_info.h
75616 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
75617 #error "no set_restore_sigmask() provided and default one won't work"
75618 #endif
75619
75620 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
75621 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
75622 +{
75623 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
75624 + if (!__builtin_constant_p(n))
75625 +#endif
75626 + __check_object_size(ptr, n, to_user);
75627 +}
75628 +
75629 #endif /* __KERNEL__ */
75630
75631 #endif /* _LINUX_THREAD_INFO_H */
75632 diff --git a/include/linux/tty.h b/include/linux/tty.h
75633 index 8780bd2..d1ae08b 100644
75634 --- a/include/linux/tty.h
75635 +++ b/include/linux/tty.h
75636 @@ -194,7 +194,7 @@ struct tty_port {
75637 const struct tty_port_operations *ops; /* Port operations */
75638 spinlock_t lock; /* Lock protecting tty field */
75639 int blocked_open; /* Waiting to open */
75640 - int count; /* Usage count */
75641 + atomic_t count; /* Usage count */
75642 wait_queue_head_t open_wait; /* Open waiters */
75643 wait_queue_head_t close_wait; /* Close waiters */
75644 wait_queue_head_t delta_msr_wait; /* Modem status change */
75645 @@ -550,7 +550,7 @@ extern int tty_port_open(struct tty_port *port,
75646 struct tty_struct *tty, struct file *filp);
75647 static inline int tty_port_users(struct tty_port *port)
75648 {
75649 - return port->count + port->blocked_open;
75650 + return atomic_read(&port->count) + port->blocked_open;
75651 }
75652
75653 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
75654 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
75655 index 756a609..b302dd6 100644
75656 --- a/include/linux/tty_driver.h
75657 +++ b/include/linux/tty_driver.h
75658 @@ -285,7 +285,7 @@ struct tty_operations {
75659 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
75660 #endif
75661 const struct file_operations *proc_fops;
75662 -};
75663 +} __do_const;
75664
75665 struct tty_driver {
75666 int magic; /* magic number for this structure */
75667 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
75668 index 58390c7..95e214c 100644
75669 --- a/include/linux/tty_ldisc.h
75670 +++ b/include/linux/tty_ldisc.h
75671 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
75672
75673 struct module *owner;
75674
75675 - int refcount;
75676 + atomic_t refcount;
75677 };
75678
75679 struct tty_ldisc {
75680 diff --git a/include/linux/types.h b/include/linux/types.h
75681 index 4d118ba..c3ee9bf 100644
75682 --- a/include/linux/types.h
75683 +++ b/include/linux/types.h
75684 @@ -176,10 +176,26 @@ typedef struct {
75685 int counter;
75686 } atomic_t;
75687
75688 +#ifdef CONFIG_PAX_REFCOUNT
75689 +typedef struct {
75690 + int counter;
75691 +} atomic_unchecked_t;
75692 +#else
75693 +typedef atomic_t atomic_unchecked_t;
75694 +#endif
75695 +
75696 #ifdef CONFIG_64BIT
75697 typedef struct {
75698 long counter;
75699 } atomic64_t;
75700 +
75701 +#ifdef CONFIG_PAX_REFCOUNT
75702 +typedef struct {
75703 + long counter;
75704 +} atomic64_unchecked_t;
75705 +#else
75706 +typedef atomic64_t atomic64_unchecked_t;
75707 +#endif
75708 #endif
75709
75710 struct list_head {
75711 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
75712 index 5ca0951..ab496a5 100644
75713 --- a/include/linux/uaccess.h
75714 +++ b/include/linux/uaccess.h
75715 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
75716 long ret; \
75717 mm_segment_t old_fs = get_fs(); \
75718 \
75719 - set_fs(KERNEL_DS); \
75720 pagefault_disable(); \
75721 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
75722 - pagefault_enable(); \
75723 + set_fs(KERNEL_DS); \
75724 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
75725 set_fs(old_fs); \
75726 + pagefault_enable(); \
75727 ret; \
75728 })
75729
75730 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
75731 index 8e522cbc..aa8572d 100644
75732 --- a/include/linux/uidgid.h
75733 +++ b/include/linux/uidgid.h
75734 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
75735
75736 #endif /* CONFIG_USER_NS */
75737
75738 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
75739 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
75740 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
75741 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
75742 +
75743 #endif /* _LINUX_UIDGID_H */
75744 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
75745 index 99c1b4d..562e6f3 100644
75746 --- a/include/linux/unaligned/access_ok.h
75747 +++ b/include/linux/unaligned/access_ok.h
75748 @@ -4,34 +4,34 @@
75749 #include <linux/kernel.h>
75750 #include <asm/byteorder.h>
75751
75752 -static inline u16 get_unaligned_le16(const void *p)
75753 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
75754 {
75755 - return le16_to_cpup((__le16 *)p);
75756 + return le16_to_cpup((const __le16 *)p);
75757 }
75758
75759 -static inline u32 get_unaligned_le32(const void *p)
75760 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
75761 {
75762 - return le32_to_cpup((__le32 *)p);
75763 + return le32_to_cpup((const __le32 *)p);
75764 }
75765
75766 -static inline u64 get_unaligned_le64(const void *p)
75767 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
75768 {
75769 - return le64_to_cpup((__le64 *)p);
75770 + return le64_to_cpup((const __le64 *)p);
75771 }
75772
75773 -static inline u16 get_unaligned_be16(const void *p)
75774 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
75775 {
75776 - return be16_to_cpup((__be16 *)p);
75777 + return be16_to_cpup((const __be16 *)p);
75778 }
75779
75780 -static inline u32 get_unaligned_be32(const void *p)
75781 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
75782 {
75783 - return be32_to_cpup((__be32 *)p);
75784 + return be32_to_cpup((const __be32 *)p);
75785 }
75786
75787 -static inline u64 get_unaligned_be64(const void *p)
75788 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
75789 {
75790 - return be64_to_cpup((__be64 *)p);
75791 + return be64_to_cpup((const __be64 *)p);
75792 }
75793
75794 static inline void put_unaligned_le16(u16 val, void *p)
75795 diff --git a/include/linux/usb.h b/include/linux/usb.h
75796 index a0bee5a..5533a52 100644
75797 --- a/include/linux/usb.h
75798 +++ b/include/linux/usb.h
75799 @@ -552,7 +552,7 @@ struct usb_device {
75800 int maxchild;
75801
75802 u32 quirks;
75803 - atomic_t urbnum;
75804 + atomic_unchecked_t urbnum;
75805
75806 unsigned long active_duration;
75807
75808 @@ -1607,7 +1607,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
75809
75810 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
75811 __u8 request, __u8 requesttype, __u16 value, __u16 index,
75812 - void *data, __u16 size, int timeout);
75813 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
75814 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
75815 void *data, int len, int *actual_length, int timeout);
75816 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
75817 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
75818 index e452ba6..78f8e80 100644
75819 --- a/include/linux/usb/renesas_usbhs.h
75820 +++ b/include/linux/usb/renesas_usbhs.h
75821 @@ -39,7 +39,7 @@ enum {
75822 */
75823 struct renesas_usbhs_driver_callback {
75824 int (*notify_hotplug)(struct platform_device *pdev);
75825 -};
75826 +} __no_const;
75827
75828 /*
75829 * callback functions for platform
75830 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
75831 index 6f8fbcf..8259001 100644
75832 --- a/include/linux/vermagic.h
75833 +++ b/include/linux/vermagic.h
75834 @@ -25,9 +25,35 @@
75835 #define MODULE_ARCH_VERMAGIC ""
75836 #endif
75837
75838 +#ifdef CONFIG_PAX_REFCOUNT
75839 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
75840 +#else
75841 +#define MODULE_PAX_REFCOUNT ""
75842 +#endif
75843 +
75844 +#ifdef CONSTIFY_PLUGIN
75845 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
75846 +#else
75847 +#define MODULE_CONSTIFY_PLUGIN ""
75848 +#endif
75849 +
75850 +#ifdef STACKLEAK_PLUGIN
75851 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
75852 +#else
75853 +#define MODULE_STACKLEAK_PLUGIN ""
75854 +#endif
75855 +
75856 +#ifdef CONFIG_GRKERNSEC
75857 +#define MODULE_GRSEC "GRSEC "
75858 +#else
75859 +#define MODULE_GRSEC ""
75860 +#endif
75861 +
75862 #define VERMAGIC_STRING \
75863 UTS_RELEASE " " \
75864 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
75865 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
75866 - MODULE_ARCH_VERMAGIC
75867 + MODULE_ARCH_VERMAGIC \
75868 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
75869 + MODULE_GRSEC
75870
75871 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
75872 index 7d5773a..541c01c 100644
75873 --- a/include/linux/vmalloc.h
75874 +++ b/include/linux/vmalloc.h
75875 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
75876 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
75877 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
75878 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
75879 +
75880 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
75881 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
75882 +#endif
75883 +
75884 /* bits [20..32] reserved for arch specific ioremap internals */
75885
75886 /*
75887 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
75888 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
75889 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
75890 unsigned long start, unsigned long end, gfp_t gfp_mask,
75891 - pgprot_t prot, int node, const void *caller);
75892 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
75893 extern void vfree(const void *addr);
75894
75895 extern void *vmap(struct page **pages, unsigned int count,
75896 @@ -137,8 +142,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
75897 extern void free_vm_area(struct vm_struct *area);
75898
75899 /* for /dev/kmem */
75900 -extern long vread(char *buf, char *addr, unsigned long count);
75901 -extern long vwrite(char *buf, char *addr, unsigned long count);
75902 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
75903 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
75904
75905 /*
75906 * Internals. Dont't use..
75907 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
75908 index c586679..f06b389 100644
75909 --- a/include/linux/vmstat.h
75910 +++ b/include/linux/vmstat.h
75911 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
75912 /*
75913 * Zone based page accounting with per cpu differentials.
75914 */
75915 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75916 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75917
75918 static inline void zone_page_state_add(long x, struct zone *zone,
75919 enum zone_stat_item item)
75920 {
75921 - atomic_long_add(x, &zone->vm_stat[item]);
75922 - atomic_long_add(x, &vm_stat[item]);
75923 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
75924 + atomic_long_add_unchecked(x, &vm_stat[item]);
75925 }
75926
75927 static inline unsigned long global_page_state(enum zone_stat_item item)
75928 {
75929 - long x = atomic_long_read(&vm_stat[item]);
75930 + long x = atomic_long_read_unchecked(&vm_stat[item]);
75931 #ifdef CONFIG_SMP
75932 if (x < 0)
75933 x = 0;
75934 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
75935 static inline unsigned long zone_page_state(struct zone *zone,
75936 enum zone_stat_item item)
75937 {
75938 - long x = atomic_long_read(&zone->vm_stat[item]);
75939 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
75940 #ifdef CONFIG_SMP
75941 if (x < 0)
75942 x = 0;
75943 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
75944 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
75945 enum zone_stat_item item)
75946 {
75947 - long x = atomic_long_read(&zone->vm_stat[item]);
75948 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
75949
75950 #ifdef CONFIG_SMP
75951 int cpu;
75952 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
75953
75954 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
75955 {
75956 - atomic_long_inc(&zone->vm_stat[item]);
75957 - atomic_long_inc(&vm_stat[item]);
75958 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
75959 + atomic_long_inc_unchecked(&vm_stat[item]);
75960 }
75961
75962 static inline void __inc_zone_page_state(struct page *page,
75963 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
75964
75965 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
75966 {
75967 - atomic_long_dec(&zone->vm_stat[item]);
75968 - atomic_long_dec(&vm_stat[item]);
75969 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
75970 + atomic_long_dec_unchecked(&vm_stat[item]);
75971 }
75972
75973 static inline void __dec_zone_page_state(struct page *page,
75974 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
75975 index fdbafc6..49dfe4f 100644
75976 --- a/include/linux/xattr.h
75977 +++ b/include/linux/xattr.h
75978 @@ -28,7 +28,7 @@ struct xattr_handler {
75979 size_t size, int handler_flags);
75980 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
75981 size_t size, int flags, int handler_flags);
75982 -};
75983 +} __do_const;
75984
75985 struct xattr {
75986 char *name;
75987 @@ -37,6 +37,9 @@ struct xattr {
75988 };
75989
75990 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
75991 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
75992 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
75993 +#endif
75994 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
75995 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
75996 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
75997 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
75998 index 9c5a6b4..09c9438 100644
75999 --- a/include/linux/zlib.h
76000 +++ b/include/linux/zlib.h
76001 @@ -31,6 +31,7 @@
76002 #define _ZLIB_H
76003
76004 #include <linux/zconf.h>
76005 +#include <linux/compiler.h>
76006
76007 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
76008 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
76009 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
76010
76011 /* basic functions */
76012
76013 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
76014 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
76015 /*
76016 Returns the number of bytes that needs to be allocated for a per-
76017 stream workspace with the specified parameters. A pointer to this
76018 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
76019 index 95d1c91..6798cca 100644
76020 --- a/include/media/v4l2-dev.h
76021 +++ b/include/media/v4l2-dev.h
76022 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
76023 int (*mmap) (struct file *, struct vm_area_struct *);
76024 int (*open) (struct file *);
76025 int (*release) (struct file *);
76026 -};
76027 +} __do_const;
76028
76029 /*
76030 * Newer version of video_device, handled by videodev2.c
76031 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
76032 index adcbb20..62c2559 100644
76033 --- a/include/net/9p/transport.h
76034 +++ b/include/net/9p/transport.h
76035 @@ -57,7 +57,7 @@ struct p9_trans_module {
76036 int (*cancel) (struct p9_client *, struct p9_req_t *req);
76037 int (*zc_request)(struct p9_client *, struct p9_req_t *,
76038 char *, char *, int , int, int, int);
76039 -};
76040 +} __do_const;
76041
76042 void v9fs_register_trans(struct p9_trans_module *m);
76043 void v9fs_unregister_trans(struct p9_trans_module *m);
76044 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
76045 index fb94cf1..7c0c987 100644
76046 --- a/include/net/bluetooth/l2cap.h
76047 +++ b/include/net/bluetooth/l2cap.h
76048 @@ -551,7 +551,7 @@ struct l2cap_ops {
76049 void (*defer) (struct l2cap_chan *chan);
76050 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
76051 unsigned long len, int nb);
76052 -};
76053 +} __do_const;
76054
76055 struct l2cap_conn {
76056 struct hci_conn *hcon;
76057 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
76058 index f2ae33d..c457cf0 100644
76059 --- a/include/net/caif/cfctrl.h
76060 +++ b/include/net/caif/cfctrl.h
76061 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
76062 void (*radioset_rsp)(void);
76063 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
76064 struct cflayer *client_layer);
76065 -};
76066 +} __no_const;
76067
76068 /* Link Setup Parameters for CAIF-Links. */
76069 struct cfctrl_link_param {
76070 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
76071 struct cfctrl {
76072 struct cfsrvl serv;
76073 struct cfctrl_rsp res;
76074 - atomic_t req_seq_no;
76075 - atomic_t rsp_seq_no;
76076 + atomic_unchecked_t req_seq_no;
76077 + atomic_unchecked_t rsp_seq_no;
76078 struct list_head list;
76079 /* Protects from simultaneous access to first_req list */
76080 spinlock_t info_list_lock;
76081 diff --git a/include/net/flow.h b/include/net/flow.h
76082 index 628e11b..4c475df 100644
76083 --- a/include/net/flow.h
76084 +++ b/include/net/flow.h
76085 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
76086
76087 extern void flow_cache_flush(void);
76088 extern void flow_cache_flush_deferred(void);
76089 -extern atomic_t flow_cache_genid;
76090 +extern atomic_unchecked_t flow_cache_genid;
76091
76092 #endif
76093 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
76094 index 93024a4..eeb6b6e 100644
76095 --- a/include/net/genetlink.h
76096 +++ b/include/net/genetlink.h
76097 @@ -119,7 +119,7 @@ struct genl_ops {
76098 struct netlink_callback *cb);
76099 int (*done)(struct netlink_callback *cb);
76100 struct list_head ops_list;
76101 -};
76102 +} __do_const;
76103
76104 extern int genl_register_family(struct genl_family *family);
76105 extern int genl_register_family_with_ops(struct genl_family *family,
76106 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
76107 index 734d9b5..48a9a4b 100644
76108 --- a/include/net/gro_cells.h
76109 +++ b/include/net/gro_cells.h
76110 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
76111 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
76112
76113 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
76114 - atomic_long_inc(&dev->rx_dropped);
76115 + atomic_long_inc_unchecked(&dev->rx_dropped);
76116 kfree_skb(skb);
76117 return;
76118 }
76119 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
76120 index de2c785..0588a6b 100644
76121 --- a/include/net/inet_connection_sock.h
76122 +++ b/include/net/inet_connection_sock.h
76123 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
76124 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
76125 int (*bind_conflict)(const struct sock *sk,
76126 const struct inet_bind_bucket *tb, bool relax);
76127 -};
76128 +} __do_const;
76129
76130 /** inet_connection_sock - INET connection oriented sock
76131 *
76132 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
76133 index 53f464d..ba76aaa 100644
76134 --- a/include/net/inetpeer.h
76135 +++ b/include/net/inetpeer.h
76136 @@ -47,8 +47,8 @@ struct inet_peer {
76137 */
76138 union {
76139 struct {
76140 - atomic_t rid; /* Frag reception counter */
76141 - atomic_t ip_id_count; /* IP ID for the next packet */
76142 + atomic_unchecked_t rid; /* Frag reception counter */
76143 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
76144 };
76145 struct rcu_head rcu;
76146 struct inet_peer *gc_next;
76147 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
76148 more++;
76149 inet_peer_refcheck(p);
76150 do {
76151 - old = atomic_read(&p->ip_id_count);
76152 + old = atomic_read_unchecked(&p->ip_id_count);
76153 new = old + more;
76154 if (!new)
76155 new = 1;
76156 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
76157 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
76158 return new;
76159 }
76160
76161 diff --git a/include/net/ip.h b/include/net/ip.h
76162 index a68f838..74518ab 100644
76163 --- a/include/net/ip.h
76164 +++ b/include/net/ip.h
76165 @@ -202,7 +202,7 @@ extern struct local_ports {
76166 } sysctl_local_ports;
76167 extern void inet_get_local_port_range(int *low, int *high);
76168
76169 -extern unsigned long *sysctl_local_reserved_ports;
76170 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
76171 static inline int inet_is_reserved_local_port(int port)
76172 {
76173 return test_bit(port, sysctl_local_reserved_ports);
76174 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
76175 index e49db91..76a81de 100644
76176 --- a/include/net/ip_fib.h
76177 +++ b/include/net/ip_fib.h
76178 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
76179
76180 #define FIB_RES_SADDR(net, res) \
76181 ((FIB_RES_NH(res).nh_saddr_genid == \
76182 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
76183 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
76184 FIB_RES_NH(res).nh_saddr : \
76185 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
76186 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
76187 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
76188 index 4c062cc..3562c31 100644
76189 --- a/include/net/ip_vs.h
76190 +++ b/include/net/ip_vs.h
76191 @@ -612,7 +612,7 @@ struct ip_vs_conn {
76192 struct ip_vs_conn *control; /* Master control connection */
76193 atomic_t n_control; /* Number of controlled ones */
76194 struct ip_vs_dest *dest; /* real server */
76195 - atomic_t in_pkts; /* incoming packet counter */
76196 + atomic_unchecked_t in_pkts; /* incoming packet counter */
76197
76198 /* packet transmitter for different forwarding methods. If it
76199 mangles the packet, it must return NF_DROP or better NF_STOLEN,
76200 @@ -761,7 +761,7 @@ struct ip_vs_dest {
76201 __be16 port; /* port number of the server */
76202 union nf_inet_addr addr; /* IP address of the server */
76203 volatile unsigned int flags; /* dest status flags */
76204 - atomic_t conn_flags; /* flags to copy to conn */
76205 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
76206 atomic_t weight; /* server weight */
76207
76208 atomic_t refcnt; /* reference counter */
76209 @@ -1013,11 +1013,11 @@ struct netns_ipvs {
76210 /* ip_vs_lblc */
76211 int sysctl_lblc_expiration;
76212 struct ctl_table_header *lblc_ctl_header;
76213 - struct ctl_table *lblc_ctl_table;
76214 + ctl_table_no_const *lblc_ctl_table;
76215 /* ip_vs_lblcr */
76216 int sysctl_lblcr_expiration;
76217 struct ctl_table_header *lblcr_ctl_header;
76218 - struct ctl_table *lblcr_ctl_table;
76219 + ctl_table_no_const *lblcr_ctl_table;
76220 /* ip_vs_est */
76221 struct list_head est_list; /* estimator list */
76222 spinlock_t est_lock;
76223 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
76224 index 80ffde3..968b0f4 100644
76225 --- a/include/net/irda/ircomm_tty.h
76226 +++ b/include/net/irda/ircomm_tty.h
76227 @@ -35,6 +35,7 @@
76228 #include <linux/termios.h>
76229 #include <linux/timer.h>
76230 #include <linux/tty.h> /* struct tty_struct */
76231 +#include <asm/local.h>
76232
76233 #include <net/irda/irias_object.h>
76234 #include <net/irda/ircomm_core.h>
76235 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
76236 index 714cc9a..ea05f3e 100644
76237 --- a/include/net/iucv/af_iucv.h
76238 +++ b/include/net/iucv/af_iucv.h
76239 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
76240 struct iucv_sock_list {
76241 struct hlist_head head;
76242 rwlock_t lock;
76243 - atomic_t autobind_name;
76244 + atomic_unchecked_t autobind_name;
76245 };
76246
76247 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
76248 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
76249 index df83f69..9b640b8 100644
76250 --- a/include/net/llc_c_ac.h
76251 +++ b/include/net/llc_c_ac.h
76252 @@ -87,7 +87,7 @@
76253 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
76254 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
76255
76256 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
76257 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
76258
76259 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
76260 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
76261 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
76262 index 6ca3113..f8026dd 100644
76263 --- a/include/net/llc_c_ev.h
76264 +++ b/include/net/llc_c_ev.h
76265 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
76266 return (struct llc_conn_state_ev *)skb->cb;
76267 }
76268
76269 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
76270 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
76271 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
76272 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
76273
76274 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
76275 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
76276 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
76277 index 0e79cfb..f46db31 100644
76278 --- a/include/net/llc_c_st.h
76279 +++ b/include/net/llc_c_st.h
76280 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
76281 u8 next_state;
76282 llc_conn_ev_qfyr_t *ev_qualifiers;
76283 llc_conn_action_t *ev_actions;
76284 -};
76285 +} __do_const;
76286
76287 struct llc_conn_state {
76288 u8 current_state;
76289 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
76290 index 37a3bbd..55a4241 100644
76291 --- a/include/net/llc_s_ac.h
76292 +++ b/include/net/llc_s_ac.h
76293 @@ -23,7 +23,7 @@
76294 #define SAP_ACT_TEST_IND 9
76295
76296 /* All action functions must look like this */
76297 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
76298 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
76299
76300 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
76301 struct sk_buff *skb);
76302 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
76303 index 567c681..cd73ac0 100644
76304 --- a/include/net/llc_s_st.h
76305 +++ b/include/net/llc_s_st.h
76306 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
76307 llc_sap_ev_t ev;
76308 u8 next_state;
76309 llc_sap_action_t *ev_actions;
76310 -};
76311 +} __do_const;
76312
76313 struct llc_sap_state {
76314 u8 curr_state;
76315 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
76316 index 885898a..cdace34 100644
76317 --- a/include/net/mac80211.h
76318 +++ b/include/net/mac80211.h
76319 @@ -4205,7 +4205,7 @@ struct rate_control_ops {
76320 void (*add_sta_debugfs)(void *priv, void *priv_sta,
76321 struct dentry *dir);
76322 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
76323 -};
76324 +} __do_const;
76325
76326 static inline int rate_supported(struct ieee80211_sta *sta,
76327 enum ieee80211_band band,
76328 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
76329 index 7e748ad..5c6229b 100644
76330 --- a/include/net/neighbour.h
76331 +++ b/include/net/neighbour.h
76332 @@ -123,7 +123,7 @@ struct neigh_ops {
76333 void (*error_report)(struct neighbour *, struct sk_buff *);
76334 int (*output)(struct neighbour *, struct sk_buff *);
76335 int (*connected_output)(struct neighbour *, struct sk_buff *);
76336 -};
76337 +} __do_const;
76338
76339 struct pneigh_entry {
76340 struct pneigh_entry *next;
76341 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
76342 index b176978..ea169f4 100644
76343 --- a/include/net/net_namespace.h
76344 +++ b/include/net/net_namespace.h
76345 @@ -117,7 +117,7 @@ struct net {
76346 #endif
76347 struct netns_ipvs *ipvs;
76348 struct sock *diag_nlsk;
76349 - atomic_t rt_genid;
76350 + atomic_unchecked_t rt_genid;
76351 };
76352
76353 /*
76354 @@ -274,7 +274,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
76355 #define __net_init __init
76356 #define __net_exit __exit_refok
76357 #define __net_initdata __initdata
76358 +#ifdef CONSTIFY_PLUGIN
76359 #define __net_initconst __initconst
76360 +#else
76361 +#define __net_initconst __initdata
76362 +#endif
76363 #endif
76364
76365 struct pernet_operations {
76366 @@ -284,7 +288,7 @@ struct pernet_operations {
76367 void (*exit_batch)(struct list_head *net_exit_list);
76368 int *id;
76369 size_t size;
76370 -};
76371 +} __do_const;
76372
76373 /*
76374 * Use these carefully. If you implement a network device and it
76375 @@ -332,12 +336,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
76376
76377 static inline int rt_genid(struct net *net)
76378 {
76379 - return atomic_read(&net->rt_genid);
76380 + return atomic_read_unchecked(&net->rt_genid);
76381 }
76382
76383 static inline void rt_genid_bump(struct net *net)
76384 {
76385 - atomic_inc(&net->rt_genid);
76386 + atomic_inc_unchecked(&net->rt_genid);
76387 }
76388
76389 #endif /* __NET_NET_NAMESPACE_H */
76390 diff --git a/include/net/netdma.h b/include/net/netdma.h
76391 index 8ba8ce2..99b7fff 100644
76392 --- a/include/net/netdma.h
76393 +++ b/include/net/netdma.h
76394 @@ -24,7 +24,7 @@
76395 #include <linux/dmaengine.h>
76396 #include <linux/skbuff.h>
76397
76398 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
76399 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
76400 struct sk_buff *skb, int offset, struct iovec *to,
76401 size_t len, struct dma_pinned_list *pinned_list);
76402
76403 diff --git a/include/net/netlink.h b/include/net/netlink.h
76404 index 9690b0f..87aded7 100644
76405 --- a/include/net/netlink.h
76406 +++ b/include/net/netlink.h
76407 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
76408 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
76409 {
76410 if (mark)
76411 - skb_trim(skb, (unsigned char *) mark - skb->data);
76412 + skb_trim(skb, (const unsigned char *) mark - skb->data);
76413 }
76414
76415 /**
76416 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
76417 index c9c0c53..53f24c3 100644
76418 --- a/include/net/netns/conntrack.h
76419 +++ b/include/net/netns/conntrack.h
76420 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
76421 struct nf_proto_net {
76422 #ifdef CONFIG_SYSCTL
76423 struct ctl_table_header *ctl_table_header;
76424 - struct ctl_table *ctl_table;
76425 + ctl_table_no_const *ctl_table;
76426 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
76427 struct ctl_table_header *ctl_compat_header;
76428 - struct ctl_table *ctl_compat_table;
76429 + ctl_table_no_const *ctl_compat_table;
76430 #endif
76431 #endif
76432 unsigned int users;
76433 @@ -58,7 +58,7 @@ struct nf_ip_net {
76434 struct nf_icmp_net icmpv6;
76435 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
76436 struct ctl_table_header *ctl_table_header;
76437 - struct ctl_table *ctl_table;
76438 + ctl_table_no_const *ctl_table;
76439 #endif
76440 };
76441
76442 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
76443 index 2ba9de8..47bd6c7 100644
76444 --- a/include/net/netns/ipv4.h
76445 +++ b/include/net/netns/ipv4.h
76446 @@ -67,7 +67,7 @@ struct netns_ipv4 {
76447 kgid_t sysctl_ping_group_range[2];
76448 long sysctl_tcp_mem[3];
76449
76450 - atomic_t dev_addr_genid;
76451 + atomic_unchecked_t dev_addr_genid;
76452
76453 #ifdef CONFIG_IP_MROUTE
76454 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
76455 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
76456 index 005e2c2..023d340 100644
76457 --- a/include/net/netns/ipv6.h
76458 +++ b/include/net/netns/ipv6.h
76459 @@ -71,7 +71,7 @@ struct netns_ipv6 {
76460 struct fib_rules_ops *mr6_rules_ops;
76461 #endif
76462 #endif
76463 - atomic_t dev_addr_genid;
76464 + atomic_unchecked_t dev_addr_genid;
76465 };
76466
76467 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
76468 diff --git a/include/net/protocol.h b/include/net/protocol.h
76469 index 047c047..b9dad15 100644
76470 --- a/include/net/protocol.h
76471 +++ b/include/net/protocol.h
76472 @@ -44,7 +44,7 @@ struct net_protocol {
76473 void (*err_handler)(struct sk_buff *skb, u32 info);
76474 unsigned int no_policy:1,
76475 netns_ok:1;
76476 -};
76477 +} __do_const;
76478
76479 #if IS_ENABLED(CONFIG_IPV6)
76480 struct inet6_protocol {
76481 @@ -57,7 +57,7 @@ struct inet6_protocol {
76482 u8 type, u8 code, int offset,
76483 __be32 info);
76484 unsigned int flags; /* INET6_PROTO_xxx */
76485 -};
76486 +} __do_const;
76487
76488 #define INET6_PROTO_NOPOLICY 0x1
76489 #define INET6_PROTO_FINAL 0x2
76490 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
76491 index 7026648..584cc8c 100644
76492 --- a/include/net/rtnetlink.h
76493 +++ b/include/net/rtnetlink.h
76494 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
76495 const struct net_device *dev);
76496 unsigned int (*get_num_tx_queues)(void);
76497 unsigned int (*get_num_rx_queues)(void);
76498 -};
76499 +} __do_const;
76500
76501 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
76502 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
76503 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
76504 index cd89510..d67810f 100644
76505 --- a/include/net/sctp/sctp.h
76506 +++ b/include/net/sctp/sctp.h
76507 @@ -330,9 +330,9 @@ do { \
76508
76509 #else /* SCTP_DEBUG */
76510
76511 -#define SCTP_DEBUG_PRINTK(whatever...)
76512 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
76513 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
76514 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
76515 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
76516 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
76517 #define SCTP_ENABLE_DEBUG
76518 #define SCTP_DISABLE_DEBUG
76519 #define SCTP_ASSERT(expr, str, func)
76520 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
76521 index 2a82d13..62a31c2 100644
76522 --- a/include/net/sctp/sm.h
76523 +++ b/include/net/sctp/sm.h
76524 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
76525 typedef struct {
76526 sctp_state_fn_t *fn;
76527 const char *name;
76528 -} sctp_sm_table_entry_t;
76529 +} __do_const sctp_sm_table_entry_t;
76530
76531 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
76532 * currently in use.
76533 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
76534 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
76535
76536 /* Extern declarations for major data structures. */
76537 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
76538 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
76539
76540
76541 /* Get the size of a DATA chunk payload. */
76542 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
76543 index 1bd4c41..9250b5b 100644
76544 --- a/include/net/sctp/structs.h
76545 +++ b/include/net/sctp/structs.h
76546 @@ -516,7 +516,7 @@ struct sctp_pf {
76547 struct sctp_association *asoc);
76548 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
76549 struct sctp_af *af;
76550 -};
76551 +} __do_const;
76552
76553
76554 /* Structure to track chunk fragments that have been acked, but peer
76555 diff --git a/include/net/sock.h b/include/net/sock.h
76556 index 66772cf..25bc45b 100644
76557 --- a/include/net/sock.h
76558 +++ b/include/net/sock.h
76559 @@ -325,7 +325,7 @@ struct sock {
76560 #ifdef CONFIG_RPS
76561 __u32 sk_rxhash;
76562 #endif
76563 - atomic_t sk_drops;
76564 + atomic_unchecked_t sk_drops;
76565 int sk_rcvbuf;
76566
76567 struct sk_filter __rcu *sk_filter;
76568 @@ -1797,7 +1797,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
76569 }
76570
76571 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
76572 - char __user *from, char *to,
76573 + char __user *from, unsigned char *to,
76574 int copy, int offset)
76575 {
76576 if (skb->ip_summed == CHECKSUM_NONE) {
76577 @@ -2056,7 +2056,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
76578 }
76579 }
76580
76581 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
76582 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
76583
76584 /**
76585 * sk_page_frag - return an appropriate page_frag
76586 diff --git a/include/net/tcp.h b/include/net/tcp.h
76587 index 5bba80f..8520a82 100644
76588 --- a/include/net/tcp.h
76589 +++ b/include/net/tcp.h
76590 @@ -524,7 +524,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
76591 extern void tcp_xmit_retransmit_queue(struct sock *);
76592 extern void tcp_simple_retransmit(struct sock *);
76593 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
76594 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
76595 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
76596
76597 extern void tcp_send_probe0(struct sock *);
76598 extern void tcp_send_partial(struct sock *);
76599 @@ -697,8 +697,8 @@ struct tcp_skb_cb {
76600 struct inet6_skb_parm h6;
76601 #endif
76602 } header; /* For incoming frames */
76603 - __u32 seq; /* Starting sequence number */
76604 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
76605 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
76606 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
76607 __u32 when; /* used to compute rtt's */
76608 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
76609
76610 @@ -712,7 +712,7 @@ struct tcp_skb_cb {
76611
76612 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
76613 /* 1 byte hole */
76614 - __u32 ack_seq; /* Sequence number ACK'd */
76615 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
76616 };
76617
76618 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
76619 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
76620 index 94ce082..62b278d 100644
76621 --- a/include/net/xfrm.h
76622 +++ b/include/net/xfrm.h
76623 @@ -305,7 +305,7 @@ struct xfrm_policy_afinfo {
76624 struct net_device *dev,
76625 const struct flowi *fl);
76626 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
76627 -};
76628 +} __do_const;
76629
76630 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
76631 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
76632 @@ -341,7 +341,7 @@ struct xfrm_state_afinfo {
76633 struct sk_buff *skb);
76634 int (*transport_finish)(struct sk_buff *skb,
76635 int async);
76636 -};
76637 +} __do_const;
76638
76639 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
76640 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
76641 @@ -424,7 +424,7 @@ struct xfrm_mode {
76642 struct module *owner;
76643 unsigned int encap;
76644 int flags;
76645 -};
76646 +} __do_const;
76647
76648 /* Flags for xfrm_mode. */
76649 enum {
76650 @@ -521,7 +521,7 @@ struct xfrm_policy {
76651 struct timer_list timer;
76652
76653 struct flow_cache_object flo;
76654 - atomic_t genid;
76655 + atomic_unchecked_t genid;
76656 u32 priority;
76657 u32 index;
76658 struct xfrm_mark mark;
76659 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
76660 index 1a046b1..ee0bef0 100644
76661 --- a/include/rdma/iw_cm.h
76662 +++ b/include/rdma/iw_cm.h
76663 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
76664 int backlog);
76665
76666 int (*destroy_listen)(struct iw_cm_id *cm_id);
76667 -};
76668 +} __no_const;
76669
76670 /**
76671 * iw_create_cm_id - Create an IW CM identifier.
76672 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
76673 index e1379b4..67eafbe 100644
76674 --- a/include/scsi/libfc.h
76675 +++ b/include/scsi/libfc.h
76676 @@ -762,6 +762,7 @@ struct libfc_function_template {
76677 */
76678 void (*disc_stop_final) (struct fc_lport *);
76679 };
76680 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
76681
76682 /**
76683 * struct fc_disc - Discovery context
76684 @@ -866,7 +867,7 @@ struct fc_lport {
76685 struct fc_vport *vport;
76686
76687 /* Operational Information */
76688 - struct libfc_function_template tt;
76689 + libfc_function_template_no_const tt;
76690 u8 link_up;
76691 u8 qfull;
76692 enum fc_lport_state state;
76693 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
76694 index cc64587..608f523 100644
76695 --- a/include/scsi/scsi_device.h
76696 +++ b/include/scsi/scsi_device.h
76697 @@ -171,9 +171,9 @@ struct scsi_device {
76698 unsigned int max_device_blocked; /* what device_blocked counts down from */
76699 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
76700
76701 - atomic_t iorequest_cnt;
76702 - atomic_t iodone_cnt;
76703 - atomic_t ioerr_cnt;
76704 + atomic_unchecked_t iorequest_cnt;
76705 + atomic_unchecked_t iodone_cnt;
76706 + atomic_unchecked_t ioerr_cnt;
76707
76708 struct device sdev_gendev,
76709 sdev_dev;
76710 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
76711 index b797e8f..8e2c3aa 100644
76712 --- a/include/scsi/scsi_transport_fc.h
76713 +++ b/include/scsi/scsi_transport_fc.h
76714 @@ -751,7 +751,8 @@ struct fc_function_template {
76715 unsigned long show_host_system_hostname:1;
76716
76717 unsigned long disable_target_scan:1;
76718 -};
76719 +} __do_const;
76720 +typedef struct fc_function_template __no_const fc_function_template_no_const;
76721
76722
76723 /**
76724 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
76725 index 9031a26..750d592 100644
76726 --- a/include/sound/compress_driver.h
76727 +++ b/include/sound/compress_driver.h
76728 @@ -128,7 +128,7 @@ struct snd_compr_ops {
76729 struct snd_compr_caps *caps);
76730 int (*get_codec_caps) (struct snd_compr_stream *stream,
76731 struct snd_compr_codec_caps *codec);
76732 -};
76733 +} __no_const;
76734
76735 /**
76736 * struct snd_compr: Compressed device
76737 diff --git a/include/sound/soc.h b/include/sound/soc.h
76738 index 85c1522..f44bad1 100644
76739 --- a/include/sound/soc.h
76740 +++ b/include/sound/soc.h
76741 @@ -781,7 +781,7 @@ struct snd_soc_codec_driver {
76742 /* probe ordering - for components with runtime dependencies */
76743 int probe_order;
76744 int remove_order;
76745 -};
76746 +} __do_const;
76747
76748 /* SoC platform interface */
76749 struct snd_soc_platform_driver {
76750 @@ -827,7 +827,7 @@ struct snd_soc_platform_driver {
76751 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
76752 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
76753 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
76754 -};
76755 +} __do_const;
76756
76757 struct snd_soc_platform {
76758 const char *name;
76759 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
76760 index 4ea4f98..a63629b 100644
76761 --- a/include/target/target_core_base.h
76762 +++ b/include/target/target_core_base.h
76763 @@ -653,7 +653,7 @@ struct se_device {
76764 spinlock_t stats_lock;
76765 /* Active commands on this virtual SE device */
76766 atomic_t simple_cmds;
76767 - atomic_t dev_ordered_id;
76768 + atomic_unchecked_t dev_ordered_id;
76769 atomic_t dev_ordered_sync;
76770 atomic_t dev_qf_count;
76771 int export_count;
76772 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
76773 new file mode 100644
76774 index 0000000..fb634b7
76775 --- /dev/null
76776 +++ b/include/trace/events/fs.h
76777 @@ -0,0 +1,53 @@
76778 +#undef TRACE_SYSTEM
76779 +#define TRACE_SYSTEM fs
76780 +
76781 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
76782 +#define _TRACE_FS_H
76783 +
76784 +#include <linux/fs.h>
76785 +#include <linux/tracepoint.h>
76786 +
76787 +TRACE_EVENT(do_sys_open,
76788 +
76789 + TP_PROTO(const char *filename, int flags, int mode),
76790 +
76791 + TP_ARGS(filename, flags, mode),
76792 +
76793 + TP_STRUCT__entry(
76794 + __string( filename, filename )
76795 + __field( int, flags )
76796 + __field( int, mode )
76797 + ),
76798 +
76799 + TP_fast_assign(
76800 + __assign_str(filename, filename);
76801 + __entry->flags = flags;
76802 + __entry->mode = mode;
76803 + ),
76804 +
76805 + TP_printk("\"%s\" %x %o",
76806 + __get_str(filename), __entry->flags, __entry->mode)
76807 +);
76808 +
76809 +TRACE_EVENT(open_exec,
76810 +
76811 + TP_PROTO(const char *filename),
76812 +
76813 + TP_ARGS(filename),
76814 +
76815 + TP_STRUCT__entry(
76816 + __string( filename, filename )
76817 + ),
76818 +
76819 + TP_fast_assign(
76820 + __assign_str(filename, filename);
76821 + ),
76822 +
76823 + TP_printk("\"%s\"",
76824 + __get_str(filename))
76825 +);
76826 +
76827 +#endif /* _TRACE_FS_H */
76828 +
76829 +/* This part must be outside protection */
76830 +#include <trace/define_trace.h>
76831 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
76832 index 1c09820..7f5ec79 100644
76833 --- a/include/trace/events/irq.h
76834 +++ b/include/trace/events/irq.h
76835 @@ -36,7 +36,7 @@ struct softirq_action;
76836 */
76837 TRACE_EVENT(irq_handler_entry,
76838
76839 - TP_PROTO(int irq, struct irqaction *action),
76840 + TP_PROTO(int irq, const struct irqaction *action),
76841
76842 TP_ARGS(irq, action),
76843
76844 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
76845 */
76846 TRACE_EVENT(irq_handler_exit,
76847
76848 - TP_PROTO(int irq, struct irqaction *action, int ret),
76849 + TP_PROTO(int irq, const struct irqaction *action, int ret),
76850
76851 TP_ARGS(irq, action, ret),
76852
76853 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
76854 index 7caf44c..23c6f27 100644
76855 --- a/include/uapi/linux/a.out.h
76856 +++ b/include/uapi/linux/a.out.h
76857 @@ -39,6 +39,14 @@ enum machine_type {
76858 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
76859 };
76860
76861 +/* Constants for the N_FLAGS field */
76862 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
76863 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
76864 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
76865 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
76866 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
76867 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
76868 +
76869 #if !defined (N_MAGIC)
76870 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
76871 #endif
76872 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
76873 index d876736..ccce5c0 100644
76874 --- a/include/uapi/linux/byteorder/little_endian.h
76875 +++ b/include/uapi/linux/byteorder/little_endian.h
76876 @@ -42,51 +42,51 @@
76877
76878 static inline __le64 __cpu_to_le64p(const __u64 *p)
76879 {
76880 - return (__force __le64)*p;
76881 + return (__force const __le64)*p;
76882 }
76883 -static inline __u64 __le64_to_cpup(const __le64 *p)
76884 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
76885 {
76886 - return (__force __u64)*p;
76887 + return (__force const __u64)*p;
76888 }
76889 static inline __le32 __cpu_to_le32p(const __u32 *p)
76890 {
76891 - return (__force __le32)*p;
76892 + return (__force const __le32)*p;
76893 }
76894 static inline __u32 __le32_to_cpup(const __le32 *p)
76895 {
76896 - return (__force __u32)*p;
76897 + return (__force const __u32)*p;
76898 }
76899 static inline __le16 __cpu_to_le16p(const __u16 *p)
76900 {
76901 - return (__force __le16)*p;
76902 + return (__force const __le16)*p;
76903 }
76904 static inline __u16 __le16_to_cpup(const __le16 *p)
76905 {
76906 - return (__force __u16)*p;
76907 + return (__force const __u16)*p;
76908 }
76909 static inline __be64 __cpu_to_be64p(const __u64 *p)
76910 {
76911 - return (__force __be64)__swab64p(p);
76912 + return (__force const __be64)__swab64p(p);
76913 }
76914 static inline __u64 __be64_to_cpup(const __be64 *p)
76915 {
76916 - return __swab64p((__u64 *)p);
76917 + return __swab64p((const __u64 *)p);
76918 }
76919 static inline __be32 __cpu_to_be32p(const __u32 *p)
76920 {
76921 - return (__force __be32)__swab32p(p);
76922 + return (__force const __be32)__swab32p(p);
76923 }
76924 -static inline __u32 __be32_to_cpup(const __be32 *p)
76925 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
76926 {
76927 - return __swab32p((__u32 *)p);
76928 + return __swab32p((const __u32 *)p);
76929 }
76930 static inline __be16 __cpu_to_be16p(const __u16 *p)
76931 {
76932 - return (__force __be16)__swab16p(p);
76933 + return (__force const __be16)__swab16p(p);
76934 }
76935 static inline __u16 __be16_to_cpup(const __be16 *p)
76936 {
76937 - return __swab16p((__u16 *)p);
76938 + return __swab16p((const __u16 *)p);
76939 }
76940 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
76941 #define __le64_to_cpus(x) do { (void)(x); } while (0)
76942 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
76943 index ef6103b..d4e65dd 100644
76944 --- a/include/uapi/linux/elf.h
76945 +++ b/include/uapi/linux/elf.h
76946 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
76947 #define PT_GNU_EH_FRAME 0x6474e550
76948
76949 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
76950 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
76951 +
76952 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
76953 +
76954 +/* Constants for the e_flags field */
76955 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
76956 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
76957 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
76958 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
76959 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
76960 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
76961
76962 /*
76963 * Extended Numbering
76964 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
76965 #define DT_DEBUG 21
76966 #define DT_TEXTREL 22
76967 #define DT_JMPREL 23
76968 +#define DT_FLAGS 30
76969 + #define DF_TEXTREL 0x00000004
76970 #define DT_ENCODING 32
76971 #define OLD_DT_LOOS 0x60000000
76972 #define DT_LOOS 0x6000000d
76973 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
76974 #define PF_W 0x2
76975 #define PF_X 0x1
76976
76977 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
76978 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
76979 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
76980 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
76981 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
76982 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
76983 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
76984 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
76985 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
76986 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
76987 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
76988 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
76989 +
76990 typedef struct elf32_phdr{
76991 Elf32_Word p_type;
76992 Elf32_Off p_offset;
76993 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
76994 #define EI_OSABI 7
76995 #define EI_PAD 8
76996
76997 +#define EI_PAX 14
76998 +
76999 #define ELFMAG0 0x7f /* EI_MAG */
77000 #define ELFMAG1 'E'
77001 #define ELFMAG2 'L'
77002 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
77003 index aa169c4..6a2771d 100644
77004 --- a/include/uapi/linux/personality.h
77005 +++ b/include/uapi/linux/personality.h
77006 @@ -30,6 +30,7 @@ enum {
77007 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
77008 ADDR_NO_RANDOMIZE | \
77009 ADDR_COMPAT_LAYOUT | \
77010 + ADDR_LIMIT_3GB | \
77011 MMAP_PAGE_ZERO)
77012
77013 /*
77014 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
77015 index 7530e74..e714828 100644
77016 --- a/include/uapi/linux/screen_info.h
77017 +++ b/include/uapi/linux/screen_info.h
77018 @@ -43,7 +43,8 @@ struct screen_info {
77019 __u16 pages; /* 0x32 */
77020 __u16 vesa_attributes; /* 0x34 */
77021 __u32 capabilities; /* 0x36 */
77022 - __u8 _reserved[6]; /* 0x3a */
77023 + __u16 vesapm_size; /* 0x3a */
77024 + __u8 _reserved[4]; /* 0x3c */
77025 } __attribute__((packed));
77026
77027 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
77028 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
77029 index 0e011eb..82681b1 100644
77030 --- a/include/uapi/linux/swab.h
77031 +++ b/include/uapi/linux/swab.h
77032 @@ -43,7 +43,7 @@
77033 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
77034 */
77035
77036 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
77037 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
77038 {
77039 #ifdef __HAVE_BUILTIN_BSWAP16__
77040 return __builtin_bswap16(val);
77041 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
77042 #endif
77043 }
77044
77045 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
77046 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
77047 {
77048 #ifdef __HAVE_BUILTIN_BSWAP32__
77049 return __builtin_bswap32(val);
77050 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
77051 #endif
77052 }
77053
77054 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
77055 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
77056 {
77057 #ifdef __HAVE_BUILTIN_BSWAP64__
77058 return __builtin_bswap64(val);
77059 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
77060 index 6d67213..8dab561 100644
77061 --- a/include/uapi/linux/sysctl.h
77062 +++ b/include/uapi/linux/sysctl.h
77063 @@ -155,7 +155,11 @@ enum
77064 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
77065 };
77066
77067 -
77068 +#ifdef CONFIG_PAX_SOFTMODE
77069 +enum {
77070 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
77071 +};
77072 +#endif
77073
77074 /* CTL_VM names: */
77075 enum
77076 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
77077 index e4629b9..6958086 100644
77078 --- a/include/uapi/linux/xattr.h
77079 +++ b/include/uapi/linux/xattr.h
77080 @@ -63,5 +63,9 @@
77081 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
77082 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
77083
77084 +/* User namespace */
77085 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
77086 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
77087 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
77088
77089 #endif /* _UAPI_LINUX_XATTR_H */
77090 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
77091 index f9466fa..f4e2b81 100644
77092 --- a/include/video/udlfb.h
77093 +++ b/include/video/udlfb.h
77094 @@ -53,10 +53,10 @@ struct dlfb_data {
77095 u32 pseudo_palette[256];
77096 int blank_mode; /*one of FB_BLANK_ */
77097 /* blit-only rendering path metrics, exposed through sysfs */
77098 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
77099 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
77100 - atomic_t bytes_sent; /* to usb, after compression including overhead */
77101 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
77102 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
77103 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
77104 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
77105 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
77106 };
77107
77108 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
77109 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
77110 index 1a91850..28573f8 100644
77111 --- a/include/video/uvesafb.h
77112 +++ b/include/video/uvesafb.h
77113 @@ -122,6 +122,7 @@ struct uvesafb_par {
77114 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
77115 u8 pmi_setpal; /* PMI for palette changes */
77116 u16 *pmi_base; /* protected mode interface location */
77117 + u8 *pmi_code; /* protected mode code location */
77118 void *pmi_start;
77119 void *pmi_pal;
77120 u8 *vbe_state_orig; /*
77121 diff --git a/init/Kconfig b/init/Kconfig
77122 index 2d9b831..ae4c8ac 100644
77123 --- a/init/Kconfig
77124 +++ b/init/Kconfig
77125 @@ -1029,6 +1029,7 @@ endif # CGROUPS
77126
77127 config CHECKPOINT_RESTORE
77128 bool "Checkpoint/restore support" if EXPERT
77129 + depends on !GRKERNSEC
77130 default n
77131 help
77132 Enables additional kernel features in a sake of checkpoint/restore.
77133 @@ -1516,7 +1517,7 @@ config SLUB_DEBUG
77134
77135 config COMPAT_BRK
77136 bool "Disable heap randomization"
77137 - default y
77138 + default n
77139 help
77140 Randomizing heap placement makes heap exploits harder, but it
77141 also breaks ancient binaries (including anything libc5 based).
77142 @@ -1779,7 +1780,7 @@ config INIT_ALL_POSSIBLE
77143 config STOP_MACHINE
77144 bool
77145 default y
77146 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
77147 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
77148 help
77149 Need stop_machine() primitive.
77150
77151 diff --git a/init/Makefile b/init/Makefile
77152 index 7bc47ee..6da2dc7 100644
77153 --- a/init/Makefile
77154 +++ b/init/Makefile
77155 @@ -2,6 +2,9 @@
77156 # Makefile for the linux kernel.
77157 #
77158
77159 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
77160 +asflags-y := $(GCC_PLUGINS_AFLAGS)
77161 +
77162 obj-y := main.o version.o mounts.o
77163 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
77164 obj-y += noinitramfs.o
77165 diff --git a/init/do_mounts.c b/init/do_mounts.c
77166 index a2b49f2..03a0e17c 100644
77167 --- a/init/do_mounts.c
77168 +++ b/init/do_mounts.c
77169 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
77170 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
77171 {
77172 struct super_block *s;
77173 - int err = sys_mount(name, "/root", fs, flags, data);
77174 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
77175 if (err)
77176 return err;
77177
77178 - sys_chdir("/root");
77179 + sys_chdir((const char __force_user *)"/root");
77180 s = current->fs->pwd.dentry->d_sb;
77181 ROOT_DEV = s->s_dev;
77182 printk(KERN_INFO
77183 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
77184 va_start(args, fmt);
77185 vsprintf(buf, fmt, args);
77186 va_end(args);
77187 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
77188 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
77189 if (fd >= 0) {
77190 sys_ioctl(fd, FDEJECT, 0);
77191 sys_close(fd);
77192 }
77193 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
77194 - fd = sys_open("/dev/console", O_RDWR, 0);
77195 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
77196 if (fd >= 0) {
77197 sys_ioctl(fd, TCGETS, (long)&termios);
77198 termios.c_lflag &= ~ICANON;
77199 sys_ioctl(fd, TCSETSF, (long)&termios);
77200 - sys_read(fd, &c, 1);
77201 + sys_read(fd, (char __user *)&c, 1);
77202 termios.c_lflag |= ICANON;
77203 sys_ioctl(fd, TCSETSF, (long)&termios);
77204 sys_close(fd);
77205 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
77206 mount_root();
77207 out:
77208 devtmpfs_mount("dev");
77209 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
77210 - sys_chroot(".");
77211 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
77212 + sys_chroot((const char __force_user *)".");
77213 }
77214 diff --git a/init/do_mounts.h b/init/do_mounts.h
77215 index f5b978a..69dbfe8 100644
77216 --- a/init/do_mounts.h
77217 +++ b/init/do_mounts.h
77218 @@ -15,15 +15,15 @@ extern int root_mountflags;
77219
77220 static inline int create_dev(char *name, dev_t dev)
77221 {
77222 - sys_unlink(name);
77223 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
77224 + sys_unlink((char __force_user *)name);
77225 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
77226 }
77227
77228 #if BITS_PER_LONG == 32
77229 static inline u32 bstat(char *name)
77230 {
77231 struct stat64 stat;
77232 - if (sys_stat64(name, &stat) != 0)
77233 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
77234 return 0;
77235 if (!S_ISBLK(stat.st_mode))
77236 return 0;
77237 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
77238 static inline u32 bstat(char *name)
77239 {
77240 struct stat stat;
77241 - if (sys_newstat(name, &stat) != 0)
77242 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
77243 return 0;
77244 if (!S_ISBLK(stat.st_mode))
77245 return 0;
77246 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
77247 index 3e0878e..8a9d7a0 100644
77248 --- a/init/do_mounts_initrd.c
77249 +++ b/init/do_mounts_initrd.c
77250 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
77251 {
77252 sys_unshare(CLONE_FS | CLONE_FILES);
77253 /* stdin/stdout/stderr for /linuxrc */
77254 - sys_open("/dev/console", O_RDWR, 0);
77255 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
77256 sys_dup(0);
77257 sys_dup(0);
77258 /* move initrd over / and chdir/chroot in initrd root */
77259 - sys_chdir("/root");
77260 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
77261 - sys_chroot(".");
77262 + sys_chdir((const char __force_user *)"/root");
77263 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
77264 + sys_chroot((const char __force_user *)".");
77265 sys_setsid();
77266 return 0;
77267 }
77268 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
77269 create_dev("/dev/root.old", Root_RAM0);
77270 /* mount initrd on rootfs' /root */
77271 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
77272 - sys_mkdir("/old", 0700);
77273 - sys_chdir("/old");
77274 + sys_mkdir((const char __force_user *)"/old", 0700);
77275 + sys_chdir((const char __force_user *)"/old");
77276
77277 /* try loading default modules from initrd */
77278 load_default_modules();
77279 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
77280 current->flags &= ~PF_FREEZER_SKIP;
77281
77282 /* move initrd to rootfs' /old */
77283 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
77284 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
77285 /* switch root and cwd back to / of rootfs */
77286 - sys_chroot("..");
77287 + sys_chroot((const char __force_user *)"..");
77288
77289 if (new_decode_dev(real_root_dev) == Root_RAM0) {
77290 - sys_chdir("/old");
77291 + sys_chdir((const char __force_user *)"/old");
77292 return;
77293 }
77294
77295 - sys_chdir("/");
77296 + sys_chdir((const char __force_user *)"/");
77297 ROOT_DEV = new_decode_dev(real_root_dev);
77298 mount_root();
77299
77300 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
77301 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
77302 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
77303 if (!error)
77304 printk("okay\n");
77305 else {
77306 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
77307 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
77308 if (error == -ENOENT)
77309 printk("/initrd does not exist. Ignored.\n");
77310 else
77311 printk("failed\n");
77312 printk(KERN_NOTICE "Unmounting old root\n");
77313 - sys_umount("/old", MNT_DETACH);
77314 + sys_umount((char __force_user *)"/old", MNT_DETACH);
77315 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
77316 if (fd < 0) {
77317 error = fd;
77318 @@ -127,11 +127,11 @@ int __init initrd_load(void)
77319 * mounted in the normal path.
77320 */
77321 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
77322 - sys_unlink("/initrd.image");
77323 + sys_unlink((const char __force_user *)"/initrd.image");
77324 handle_initrd();
77325 return 1;
77326 }
77327 }
77328 - sys_unlink("/initrd.image");
77329 + sys_unlink((const char __force_user *)"/initrd.image");
77330 return 0;
77331 }
77332 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
77333 index 8cb6db5..d729f50 100644
77334 --- a/init/do_mounts_md.c
77335 +++ b/init/do_mounts_md.c
77336 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
77337 partitioned ? "_d" : "", minor,
77338 md_setup_args[ent].device_names);
77339
77340 - fd = sys_open(name, 0, 0);
77341 + fd = sys_open((char __force_user *)name, 0, 0);
77342 if (fd < 0) {
77343 printk(KERN_ERR "md: open failed - cannot start "
77344 "array %s\n", name);
77345 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
77346 * array without it
77347 */
77348 sys_close(fd);
77349 - fd = sys_open(name, 0, 0);
77350 + fd = sys_open((char __force_user *)name, 0, 0);
77351 sys_ioctl(fd, BLKRRPART, 0);
77352 }
77353 sys_close(fd);
77354 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
77355
77356 wait_for_device_probe();
77357
77358 - fd = sys_open("/dev/md0", 0, 0);
77359 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
77360 if (fd >= 0) {
77361 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
77362 sys_close(fd);
77363 diff --git a/init/init_task.c b/init/init_task.c
77364 index ba0a7f36..2bcf1d5 100644
77365 --- a/init/init_task.c
77366 +++ b/init/init_task.c
77367 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
77368 * Initial thread structure. Alignment of this is handled by a special
77369 * linker map entry.
77370 */
77371 +#ifdef CONFIG_X86
77372 +union thread_union init_thread_union __init_task_data;
77373 +#else
77374 union thread_union init_thread_union __init_task_data =
77375 { INIT_THREAD_INFO(init_task) };
77376 +#endif
77377 diff --git a/init/initramfs.c b/init/initramfs.c
77378 index a67ef9d..2d17ed9 100644
77379 --- a/init/initramfs.c
77380 +++ b/init/initramfs.c
77381 @@ -84,7 +84,7 @@ static void __init free_hash(void)
77382 }
77383 }
77384
77385 -static long __init do_utime(char *filename, time_t mtime)
77386 +static long __init do_utime(char __force_user *filename, time_t mtime)
77387 {
77388 struct timespec t[2];
77389
77390 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
77391 struct dir_entry *de, *tmp;
77392 list_for_each_entry_safe(de, tmp, &dir_list, list) {
77393 list_del(&de->list);
77394 - do_utime(de->name, de->mtime);
77395 + do_utime((char __force_user *)de->name, de->mtime);
77396 kfree(de->name);
77397 kfree(de);
77398 }
77399 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
77400 if (nlink >= 2) {
77401 char *old = find_link(major, minor, ino, mode, collected);
77402 if (old)
77403 - return (sys_link(old, collected) < 0) ? -1 : 1;
77404 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
77405 }
77406 return 0;
77407 }
77408 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
77409 {
77410 struct stat st;
77411
77412 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
77413 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
77414 if (S_ISDIR(st.st_mode))
77415 - sys_rmdir(path);
77416 + sys_rmdir((char __force_user *)path);
77417 else
77418 - sys_unlink(path);
77419 + sys_unlink((char __force_user *)path);
77420 }
77421 }
77422
77423 @@ -315,7 +315,7 @@ static int __init do_name(void)
77424 int openflags = O_WRONLY|O_CREAT;
77425 if (ml != 1)
77426 openflags |= O_TRUNC;
77427 - wfd = sys_open(collected, openflags, mode);
77428 + wfd = sys_open((char __force_user *)collected, openflags, mode);
77429
77430 if (wfd >= 0) {
77431 sys_fchown(wfd, uid, gid);
77432 @@ -327,17 +327,17 @@ static int __init do_name(void)
77433 }
77434 }
77435 } else if (S_ISDIR(mode)) {
77436 - sys_mkdir(collected, mode);
77437 - sys_chown(collected, uid, gid);
77438 - sys_chmod(collected, mode);
77439 + sys_mkdir((char __force_user *)collected, mode);
77440 + sys_chown((char __force_user *)collected, uid, gid);
77441 + sys_chmod((char __force_user *)collected, mode);
77442 dir_add(collected, mtime);
77443 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
77444 S_ISFIFO(mode) || S_ISSOCK(mode)) {
77445 if (maybe_link() == 0) {
77446 - sys_mknod(collected, mode, rdev);
77447 - sys_chown(collected, uid, gid);
77448 - sys_chmod(collected, mode);
77449 - do_utime(collected, mtime);
77450 + sys_mknod((char __force_user *)collected, mode, rdev);
77451 + sys_chown((char __force_user *)collected, uid, gid);
77452 + sys_chmod((char __force_user *)collected, mode);
77453 + do_utime((char __force_user *)collected, mtime);
77454 }
77455 }
77456 return 0;
77457 @@ -346,15 +346,15 @@ static int __init do_name(void)
77458 static int __init do_copy(void)
77459 {
77460 if (count >= body_len) {
77461 - sys_write(wfd, victim, body_len);
77462 + sys_write(wfd, (char __force_user *)victim, body_len);
77463 sys_close(wfd);
77464 - do_utime(vcollected, mtime);
77465 + do_utime((char __force_user *)vcollected, mtime);
77466 kfree(vcollected);
77467 eat(body_len);
77468 state = SkipIt;
77469 return 0;
77470 } else {
77471 - sys_write(wfd, victim, count);
77472 + sys_write(wfd, (char __force_user *)victim, count);
77473 body_len -= count;
77474 eat(count);
77475 return 1;
77476 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
77477 {
77478 collected[N_ALIGN(name_len) + body_len] = '\0';
77479 clean_path(collected, 0);
77480 - sys_symlink(collected + N_ALIGN(name_len), collected);
77481 - sys_lchown(collected, uid, gid);
77482 - do_utime(collected, mtime);
77483 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
77484 + sys_lchown((char __force_user *)collected, uid, gid);
77485 + do_utime((char __force_user *)collected, mtime);
77486 state = SkipIt;
77487 next_state = Reset;
77488 return 0;
77489 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
77490 {
77491 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
77492 if (err)
77493 - panic(err); /* Failed to decompress INTERNAL initramfs */
77494 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
77495 if (initrd_start) {
77496 #ifdef CONFIG_BLK_DEV_RAM
77497 int fd;
77498 diff --git a/init/main.c b/init/main.c
77499 index 9484f4b..0eac7c3 100644
77500 --- a/init/main.c
77501 +++ b/init/main.c
77502 @@ -100,6 +100,8 @@ static inline void mark_rodata_ro(void) { }
77503 extern void tc_init(void);
77504 #endif
77505
77506 +extern void grsecurity_init(void);
77507 +
77508 /*
77509 * Debug helper: via this flag we know that we are in 'early bootup code'
77510 * where only the boot processor is running with IRQ disabled. This means
77511 @@ -153,6 +155,74 @@ static int __init set_reset_devices(char *str)
77512
77513 __setup("reset_devices", set_reset_devices);
77514
77515 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
77516 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
77517 +static int __init setup_grsec_proc_gid(char *str)
77518 +{
77519 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
77520 + return 1;
77521 +}
77522 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
77523 +#endif
77524 +
77525 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
77526 +unsigned long pax_user_shadow_base __read_only;
77527 +EXPORT_SYMBOL(pax_user_shadow_base);
77528 +extern char pax_enter_kernel_user[];
77529 +extern char pax_exit_kernel_user[];
77530 +#endif
77531 +
77532 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
77533 +static int __init setup_pax_nouderef(char *str)
77534 +{
77535 +#ifdef CONFIG_X86_32
77536 + unsigned int cpu;
77537 + struct desc_struct *gdt;
77538 +
77539 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
77540 + gdt = get_cpu_gdt_table(cpu);
77541 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
77542 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
77543 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
77544 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
77545 + }
77546 + loadsegment(ds, __KERNEL_DS);
77547 + loadsegment(es, __KERNEL_DS);
77548 + loadsegment(ss, __KERNEL_DS);
77549 +#else
77550 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
77551 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
77552 + clone_pgd_mask = ~(pgdval_t)0UL;
77553 + pax_user_shadow_base = 0UL;
77554 + setup_clear_cpu_cap(X86_FEATURE_PCID);
77555 +#endif
77556 +
77557 + return 0;
77558 +}
77559 +early_param("pax_nouderef", setup_pax_nouderef);
77560 +
77561 +#ifdef CONFIG_X86_64
77562 +static int __init setup_pax_weakuderef(char *str)
77563 +{
77564 + if (clone_pgd_mask != ~(pgdval_t)0UL)
77565 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
77566 + return 1;
77567 +}
77568 +__setup("pax_weakuderef", setup_pax_weakuderef);
77569 +#endif
77570 +#endif
77571 +
77572 +#ifdef CONFIG_PAX_SOFTMODE
77573 +int pax_softmode;
77574 +
77575 +static int __init setup_pax_softmode(char *str)
77576 +{
77577 + get_option(&str, &pax_softmode);
77578 + return 1;
77579 +}
77580 +__setup("pax_softmode=", setup_pax_softmode);
77581 +#endif
77582 +
77583 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
77584 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
77585 static const char *panic_later, *panic_param;
77586 @@ -655,8 +725,6 @@ static void __init do_ctors(void)
77587 bool initcall_debug;
77588 core_param(initcall_debug, initcall_debug, bool, 0644);
77589
77590 -static char msgbuf[64];
77591 -
77592 static int __init_or_module do_one_initcall_debug(initcall_t fn)
77593 {
77594 ktime_t calltime, delta, rettime;
77595 @@ -679,23 +747,22 @@ int __init_or_module do_one_initcall(initcall_t fn)
77596 {
77597 int count = preempt_count();
77598 int ret;
77599 + const char *msg1 = "", *msg2 = "";
77600
77601 if (initcall_debug)
77602 ret = do_one_initcall_debug(fn);
77603 else
77604 ret = fn();
77605
77606 - msgbuf[0] = 0;
77607 -
77608 if (preempt_count() != count) {
77609 - sprintf(msgbuf, "preemption imbalance ");
77610 + msg1 = " preemption imbalance";
77611 preempt_count() = count;
77612 }
77613 if (irqs_disabled()) {
77614 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
77615 + msg2 = " disabled interrupts";
77616 local_irq_enable();
77617 }
77618 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
77619 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
77620
77621 return ret;
77622 }
77623 @@ -748,8 +815,14 @@ static void __init do_initcall_level(int level)
77624 level, level,
77625 &repair_env_string);
77626
77627 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
77628 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
77629 do_one_initcall(*fn);
77630 +
77631 +#ifdef LATENT_ENTROPY_PLUGIN
77632 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
77633 +#endif
77634 +
77635 + }
77636 }
77637
77638 static void __init do_initcalls(void)
77639 @@ -783,8 +856,14 @@ static void __init do_pre_smp_initcalls(void)
77640 {
77641 initcall_t *fn;
77642
77643 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
77644 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
77645 do_one_initcall(*fn);
77646 +
77647 +#ifdef LATENT_ENTROPY_PLUGIN
77648 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
77649 +#endif
77650 +
77651 + }
77652 }
77653
77654 /*
77655 @@ -802,8 +881,8 @@ static int run_init_process(const char *init_filename)
77656 {
77657 argv_init[0] = init_filename;
77658 return do_execve(init_filename,
77659 - (const char __user *const __user *)argv_init,
77660 - (const char __user *const __user *)envp_init);
77661 + (const char __user *const __force_user *)argv_init,
77662 + (const char __user *const __force_user *)envp_init);
77663 }
77664
77665 static noinline void __init kernel_init_freeable(void);
77666 @@ -880,7 +959,7 @@ static noinline void __init kernel_init_freeable(void)
77667 do_basic_setup();
77668
77669 /* Open the /dev/console on the rootfs, this should never fail */
77670 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
77671 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
77672 pr_err("Warning: unable to open an initial console.\n");
77673
77674 (void) sys_dup(0);
77675 @@ -893,11 +972,13 @@ static noinline void __init kernel_init_freeable(void)
77676 if (!ramdisk_execute_command)
77677 ramdisk_execute_command = "/init";
77678
77679 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
77680 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
77681 ramdisk_execute_command = NULL;
77682 prepare_namespace();
77683 }
77684
77685 + grsecurity_init();
77686 +
77687 /*
77688 * Ok, we have completed the initial bootup, and
77689 * we're essentially up and running. Get rid of the
77690 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
77691 index 130dfec..cc88451 100644
77692 --- a/ipc/ipc_sysctl.c
77693 +++ b/ipc/ipc_sysctl.c
77694 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
77695 static int proc_ipc_dointvec(ctl_table *table, int write,
77696 void __user *buffer, size_t *lenp, loff_t *ppos)
77697 {
77698 - struct ctl_table ipc_table;
77699 + ctl_table_no_const ipc_table;
77700
77701 memcpy(&ipc_table, table, sizeof(ipc_table));
77702 ipc_table.data = get_ipc(table);
77703 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
77704 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
77705 void __user *buffer, size_t *lenp, loff_t *ppos)
77706 {
77707 - struct ctl_table ipc_table;
77708 + ctl_table_no_const ipc_table;
77709
77710 memcpy(&ipc_table, table, sizeof(ipc_table));
77711 ipc_table.data = get_ipc(table);
77712 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
77713 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
77714 void __user *buffer, size_t *lenp, loff_t *ppos)
77715 {
77716 - struct ctl_table ipc_table;
77717 + ctl_table_no_const ipc_table;
77718 size_t lenp_bef = *lenp;
77719 int rc;
77720
77721 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
77722 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
77723 void __user *buffer, size_t *lenp, loff_t *ppos)
77724 {
77725 - struct ctl_table ipc_table;
77726 + ctl_table_no_const ipc_table;
77727 memcpy(&ipc_table, table, sizeof(ipc_table));
77728 ipc_table.data = get_ipc(table);
77729
77730 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
77731 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
77732 void __user *buffer, size_t *lenp, loff_t *ppos)
77733 {
77734 - struct ctl_table ipc_table;
77735 + ctl_table_no_const ipc_table;
77736 size_t lenp_bef = *lenp;
77737 int oldval;
77738 int rc;
77739 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
77740 index 383d638..943fdbb 100644
77741 --- a/ipc/mq_sysctl.c
77742 +++ b/ipc/mq_sysctl.c
77743 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
77744 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
77745 void __user *buffer, size_t *lenp, loff_t *ppos)
77746 {
77747 - struct ctl_table mq_table;
77748 + ctl_table_no_const mq_table;
77749 memcpy(&mq_table, table, sizeof(mq_table));
77750 mq_table.data = get_mq(table);
77751
77752 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
77753 index e4e47f6..a85e0ad 100644
77754 --- a/ipc/mqueue.c
77755 +++ b/ipc/mqueue.c
77756 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
77757 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
77758 info->attr.mq_msgsize);
77759
77760 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
77761 spin_lock(&mq_lock);
77762 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
77763 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
77764 diff --git a/ipc/msg.c b/ipc/msg.c
77765 index d0c6d96..69a893c 100644
77766 --- a/ipc/msg.c
77767 +++ b/ipc/msg.c
77768 @@ -296,18 +296,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
77769 return security_msg_queue_associate(msq, msgflg);
77770 }
77771
77772 +static struct ipc_ops msg_ops = {
77773 + .getnew = newque,
77774 + .associate = msg_security,
77775 + .more_checks = NULL
77776 +};
77777 +
77778 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
77779 {
77780 struct ipc_namespace *ns;
77781 - struct ipc_ops msg_ops;
77782 struct ipc_params msg_params;
77783
77784 ns = current->nsproxy->ipc_ns;
77785
77786 - msg_ops.getnew = newque;
77787 - msg_ops.associate = msg_security;
77788 - msg_ops.more_checks = NULL;
77789 -
77790 msg_params.key = key;
77791 msg_params.flg = msgflg;
77792
77793 diff --git a/ipc/sem.c b/ipc/sem.c
77794 index 70480a3..f4e8262 100644
77795 --- a/ipc/sem.c
77796 +++ b/ipc/sem.c
77797 @@ -460,10 +460,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
77798 return 0;
77799 }
77800
77801 +static struct ipc_ops sem_ops = {
77802 + .getnew = newary,
77803 + .associate = sem_security,
77804 + .more_checks = sem_more_checks
77805 +};
77806 +
77807 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
77808 {
77809 struct ipc_namespace *ns;
77810 - struct ipc_ops sem_ops;
77811 struct ipc_params sem_params;
77812
77813 ns = current->nsproxy->ipc_ns;
77814 @@ -471,10 +476,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
77815 if (nsems < 0 || nsems > ns->sc_semmsl)
77816 return -EINVAL;
77817
77818 - sem_ops.getnew = newary;
77819 - sem_ops.associate = sem_security;
77820 - sem_ops.more_checks = sem_more_checks;
77821 -
77822 sem_params.key = key;
77823 sem_params.flg = semflg;
77824 sem_params.u.nsems = nsems;
77825 diff --git a/ipc/shm.c b/ipc/shm.c
77826 index 7e199fa..180a1ca 100644
77827 --- a/ipc/shm.c
77828 +++ b/ipc/shm.c
77829 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
77830 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
77831 #endif
77832
77833 +#ifdef CONFIG_GRKERNSEC
77834 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
77835 + const time_t shm_createtime, const kuid_t cuid,
77836 + const int shmid);
77837 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
77838 + const time_t shm_createtime);
77839 +#endif
77840 +
77841 void shm_init_ns(struct ipc_namespace *ns)
77842 {
77843 ns->shm_ctlmax = SHMMAX;
77844 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
77845 shp->shm_lprid = 0;
77846 shp->shm_atim = shp->shm_dtim = 0;
77847 shp->shm_ctim = get_seconds();
77848 +#ifdef CONFIG_GRKERNSEC
77849 + {
77850 + struct timespec timeval;
77851 + do_posix_clock_monotonic_gettime(&timeval);
77852 +
77853 + shp->shm_createtime = timeval.tv_sec;
77854 + }
77855 +#endif
77856 shp->shm_segsz = size;
77857 shp->shm_nattch = 0;
77858 shp->shm_file = file;
77859 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
77860 return 0;
77861 }
77862
77863 +static struct ipc_ops shm_ops = {
77864 + .getnew = newseg,
77865 + .associate = shm_security,
77866 + .more_checks = shm_more_checks
77867 +};
77868 +
77869 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
77870 {
77871 struct ipc_namespace *ns;
77872 - struct ipc_ops shm_ops;
77873 struct ipc_params shm_params;
77874
77875 ns = current->nsproxy->ipc_ns;
77876
77877 - shm_ops.getnew = newseg;
77878 - shm_ops.associate = shm_security;
77879 - shm_ops.more_checks = shm_more_checks;
77880 -
77881 shm_params.key = key;
77882 shm_params.flg = shmflg;
77883 shm_params.u.size = size;
77884 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
77885 f_mode = FMODE_READ | FMODE_WRITE;
77886 }
77887 if (shmflg & SHM_EXEC) {
77888 +
77889 +#ifdef CONFIG_PAX_MPROTECT
77890 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
77891 + goto out;
77892 +#endif
77893 +
77894 prot |= PROT_EXEC;
77895 acc_mode |= S_IXUGO;
77896 }
77897 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
77898 if (err)
77899 goto out_unlock;
77900
77901 +#ifdef CONFIG_GRKERNSEC
77902 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
77903 + shp->shm_perm.cuid, shmid) ||
77904 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
77905 + err = -EACCES;
77906 + goto out_unlock;
77907 + }
77908 +#endif
77909 +
77910 path = shp->shm_file->f_path;
77911 path_get(&path);
77912 shp->shm_nattch++;
77913 +#ifdef CONFIG_GRKERNSEC
77914 + shp->shm_lapid = current->pid;
77915 +#endif
77916 size = i_size_read(path.dentry->d_inode);
77917 shm_unlock(shp);
77918
77919 diff --git a/kernel/acct.c b/kernel/acct.c
77920 index 8d6e145..33e0b1e 100644
77921 --- a/kernel/acct.c
77922 +++ b/kernel/acct.c
77923 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
77924 */
77925 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
77926 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
77927 - file->f_op->write(file, (char *)&ac,
77928 + file->f_op->write(file, (char __force_user *)&ac,
77929 sizeof(acct_t), &file->f_pos);
77930 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
77931 set_fs(fs);
77932 diff --git a/kernel/audit.c b/kernel/audit.c
77933 index 91e53d0..d9e3ec4 100644
77934 --- a/kernel/audit.c
77935 +++ b/kernel/audit.c
77936 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
77937 3) suppressed due to audit_rate_limit
77938 4) suppressed due to audit_backlog_limit
77939 */
77940 -static atomic_t audit_lost = ATOMIC_INIT(0);
77941 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
77942
77943 /* The netlink socket. */
77944 static struct sock *audit_sock;
77945 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
77946 unsigned long now;
77947 int print;
77948
77949 - atomic_inc(&audit_lost);
77950 + atomic_inc_unchecked(&audit_lost);
77951
77952 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
77953
77954 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
77955 printk(KERN_WARNING
77956 "audit: audit_lost=%d audit_rate_limit=%d "
77957 "audit_backlog_limit=%d\n",
77958 - atomic_read(&audit_lost),
77959 + atomic_read_unchecked(&audit_lost),
77960 audit_rate_limit,
77961 audit_backlog_limit);
77962 audit_panic(message);
77963 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
77964 status_set.pid = audit_pid;
77965 status_set.rate_limit = audit_rate_limit;
77966 status_set.backlog_limit = audit_backlog_limit;
77967 - status_set.lost = atomic_read(&audit_lost);
77968 + status_set.lost = atomic_read_unchecked(&audit_lost);
77969 status_set.backlog = skb_queue_len(&audit_skb_queue);
77970 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
77971 &status_set, sizeof(status_set));
77972 diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
77973 index 6bd4a90..0ee9eff 100644
77974 --- a/kernel/auditfilter.c
77975 +++ b/kernel/auditfilter.c
77976 @@ -423,7 +423,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
77977 f->lsm_rule = NULL;
77978
77979 /* Support legacy tests for a valid loginuid */
77980 - if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295)) {
77981 + if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295U)) {
77982 f->type = AUDIT_LOGINUID_SET;
77983 f->val = 0;
77984 }
77985 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
77986 index 3c8a601..3a416f6 100644
77987 --- a/kernel/auditsc.c
77988 +++ b/kernel/auditsc.c
77989 @@ -1956,7 +1956,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
77990 }
77991
77992 /* global counter which is incremented every time something logs in */
77993 -static atomic_t session_id = ATOMIC_INIT(0);
77994 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
77995
77996 /**
77997 * audit_set_loginuid - set current task's audit_context loginuid
77998 @@ -1980,7 +1980,7 @@ int audit_set_loginuid(kuid_t loginuid)
77999 return -EPERM;
78000 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
78001
78002 - sessionid = atomic_inc_return(&session_id);
78003 + sessionid = atomic_inc_return_unchecked(&session_id);
78004 if (context && context->in_syscall) {
78005 struct audit_buffer *ab;
78006
78007 diff --git a/kernel/capability.c b/kernel/capability.c
78008 index f6c2ce5..982c0f9 100644
78009 --- a/kernel/capability.c
78010 +++ b/kernel/capability.c
78011 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
78012 * before modification is attempted and the application
78013 * fails.
78014 */
78015 + if (tocopy > ARRAY_SIZE(kdata))
78016 + return -EFAULT;
78017 +
78018 if (copy_to_user(dataptr, kdata, tocopy
78019 * sizeof(struct __user_cap_data_struct))) {
78020 return -EFAULT;
78021 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
78022 int ret;
78023
78024 rcu_read_lock();
78025 - ret = security_capable(__task_cred(t), ns, cap);
78026 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
78027 + gr_task_is_capable(t, __task_cred(t), cap);
78028 rcu_read_unlock();
78029
78030 - return (ret == 0);
78031 + return ret;
78032 }
78033
78034 /**
78035 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
78036 int ret;
78037
78038 rcu_read_lock();
78039 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
78040 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
78041 rcu_read_unlock();
78042
78043 - return (ret == 0);
78044 + return ret;
78045 }
78046
78047 /**
78048 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
78049 BUG();
78050 }
78051
78052 - if (security_capable(current_cred(), ns, cap) == 0) {
78053 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
78054 current->flags |= PF_SUPERPRIV;
78055 return true;
78056 }
78057 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
78058 }
78059 EXPORT_SYMBOL(ns_capable);
78060
78061 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
78062 +{
78063 + if (unlikely(!cap_valid(cap))) {
78064 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
78065 + BUG();
78066 + }
78067 +
78068 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
78069 + current->flags |= PF_SUPERPRIV;
78070 + return true;
78071 + }
78072 + return false;
78073 +}
78074 +EXPORT_SYMBOL(ns_capable_nolog);
78075 +
78076 /**
78077 * file_ns_capable - Determine if the file's opener had a capability in effect
78078 * @file: The file we want to check
78079 @@ -432,6 +451,12 @@ bool capable(int cap)
78080 }
78081 EXPORT_SYMBOL(capable);
78082
78083 +bool capable_nolog(int cap)
78084 +{
78085 + return ns_capable_nolog(&init_user_ns, cap);
78086 +}
78087 +EXPORT_SYMBOL(capable_nolog);
78088 +
78089 /**
78090 * nsown_capable - Check superior capability to one's own user_ns
78091 * @cap: The capability in question
78092 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
78093
78094 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
78095 }
78096 +
78097 +bool inode_capable_nolog(const struct inode *inode, int cap)
78098 +{
78099 + struct user_namespace *ns = current_user_ns();
78100 +
78101 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
78102 +}
78103 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
78104 index 2e9b387..61817b1 100644
78105 --- a/kernel/cgroup.c
78106 +++ b/kernel/cgroup.c
78107 @@ -5398,7 +5398,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
78108 struct css_set *cg = link->cg;
78109 struct task_struct *task;
78110 int count = 0;
78111 - seq_printf(seq, "css_set %p\n", cg);
78112 + seq_printf(seq, "css_set %pK\n", cg);
78113 list_for_each_entry(task, &cg->tasks, cg_list) {
78114 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
78115 seq_puts(seq, " ...\n");
78116 diff --git a/kernel/compat.c b/kernel/compat.c
78117 index 0a09e48..f44f3f0 100644
78118 --- a/kernel/compat.c
78119 +++ b/kernel/compat.c
78120 @@ -13,6 +13,7 @@
78121
78122 #include <linux/linkage.h>
78123 #include <linux/compat.h>
78124 +#include <linux/module.h>
78125 #include <linux/errno.h>
78126 #include <linux/time.h>
78127 #include <linux/signal.h>
78128 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
78129 mm_segment_t oldfs;
78130 long ret;
78131
78132 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
78133 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
78134 oldfs = get_fs();
78135 set_fs(KERNEL_DS);
78136 ret = hrtimer_nanosleep_restart(restart);
78137 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
78138 oldfs = get_fs();
78139 set_fs(KERNEL_DS);
78140 ret = hrtimer_nanosleep(&tu,
78141 - rmtp ? (struct timespec __user *)&rmt : NULL,
78142 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
78143 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
78144 set_fs(oldfs);
78145
78146 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
78147 mm_segment_t old_fs = get_fs();
78148
78149 set_fs(KERNEL_DS);
78150 - ret = sys_sigpending((old_sigset_t __user *) &s);
78151 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
78152 set_fs(old_fs);
78153 if (ret == 0)
78154 ret = put_user(s, set);
78155 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
78156 mm_segment_t old_fs = get_fs();
78157
78158 set_fs(KERNEL_DS);
78159 - ret = sys_old_getrlimit(resource, &r);
78160 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
78161 set_fs(old_fs);
78162
78163 if (!ret) {
78164 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
78165 set_fs (KERNEL_DS);
78166 ret = sys_wait4(pid,
78167 (stat_addr ?
78168 - (unsigned int __user *) &status : NULL),
78169 - options, (struct rusage __user *) &r);
78170 + (unsigned int __force_user *) &status : NULL),
78171 + options, (struct rusage __force_user *) &r);
78172 set_fs (old_fs);
78173
78174 if (ret > 0) {
78175 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
78176 memset(&info, 0, sizeof(info));
78177
78178 set_fs(KERNEL_DS);
78179 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
78180 - uru ? (struct rusage __user *)&ru : NULL);
78181 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
78182 + uru ? (struct rusage __force_user *)&ru : NULL);
78183 set_fs(old_fs);
78184
78185 if ((ret < 0) || (info.si_signo == 0))
78186 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
78187 oldfs = get_fs();
78188 set_fs(KERNEL_DS);
78189 err = sys_timer_settime(timer_id, flags,
78190 - (struct itimerspec __user *) &newts,
78191 - (struct itimerspec __user *) &oldts);
78192 + (struct itimerspec __force_user *) &newts,
78193 + (struct itimerspec __force_user *) &oldts);
78194 set_fs(oldfs);
78195 if (!err && old && put_compat_itimerspec(old, &oldts))
78196 return -EFAULT;
78197 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
78198 oldfs = get_fs();
78199 set_fs(KERNEL_DS);
78200 err = sys_timer_gettime(timer_id,
78201 - (struct itimerspec __user *) &ts);
78202 + (struct itimerspec __force_user *) &ts);
78203 set_fs(oldfs);
78204 if (!err && put_compat_itimerspec(setting, &ts))
78205 return -EFAULT;
78206 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
78207 oldfs = get_fs();
78208 set_fs(KERNEL_DS);
78209 err = sys_clock_settime(which_clock,
78210 - (struct timespec __user *) &ts);
78211 + (struct timespec __force_user *) &ts);
78212 set_fs(oldfs);
78213 return err;
78214 }
78215 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
78216 oldfs = get_fs();
78217 set_fs(KERNEL_DS);
78218 err = sys_clock_gettime(which_clock,
78219 - (struct timespec __user *) &ts);
78220 + (struct timespec __force_user *) &ts);
78221 set_fs(oldfs);
78222 if (!err && put_compat_timespec(&ts, tp))
78223 return -EFAULT;
78224 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
78225
78226 oldfs = get_fs();
78227 set_fs(KERNEL_DS);
78228 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
78229 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
78230 set_fs(oldfs);
78231
78232 err = compat_put_timex(utp, &txc);
78233 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
78234 oldfs = get_fs();
78235 set_fs(KERNEL_DS);
78236 err = sys_clock_getres(which_clock,
78237 - (struct timespec __user *) &ts);
78238 + (struct timespec __force_user *) &ts);
78239 set_fs(oldfs);
78240 if (!err && tp && put_compat_timespec(&ts, tp))
78241 return -EFAULT;
78242 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
78243 long err;
78244 mm_segment_t oldfs;
78245 struct timespec tu;
78246 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
78247 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
78248
78249 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
78250 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
78251 oldfs = get_fs();
78252 set_fs(KERNEL_DS);
78253 err = clock_nanosleep_restart(restart);
78254 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
78255 oldfs = get_fs();
78256 set_fs(KERNEL_DS);
78257 err = sys_clock_nanosleep(which_clock, flags,
78258 - (struct timespec __user *) &in,
78259 - (struct timespec __user *) &out);
78260 + (struct timespec __force_user *) &in,
78261 + (struct timespec __force_user *) &out);
78262 set_fs(oldfs);
78263
78264 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
78265 diff --git a/kernel/configs.c b/kernel/configs.c
78266 index c18b1f1..b9a0132 100644
78267 --- a/kernel/configs.c
78268 +++ b/kernel/configs.c
78269 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
78270 struct proc_dir_entry *entry;
78271
78272 /* create the current config file */
78273 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
78274 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
78275 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
78276 + &ikconfig_file_ops);
78277 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78278 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
78279 + &ikconfig_file_ops);
78280 +#endif
78281 +#else
78282 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
78283 &ikconfig_file_ops);
78284 +#endif
78285 +
78286 if (!entry)
78287 return -ENOMEM;
78288
78289 diff --git a/kernel/cred.c b/kernel/cred.c
78290 index e0573a4..3874e41 100644
78291 --- a/kernel/cred.c
78292 +++ b/kernel/cred.c
78293 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
78294 validate_creds(cred);
78295 alter_cred_subscribers(cred, -1);
78296 put_cred(cred);
78297 +
78298 +#ifdef CONFIG_GRKERNSEC_SETXID
78299 + cred = (struct cred *) tsk->delayed_cred;
78300 + if (cred != NULL) {
78301 + tsk->delayed_cred = NULL;
78302 + validate_creds(cred);
78303 + alter_cred_subscribers(cred, -1);
78304 + put_cred(cred);
78305 + }
78306 +#endif
78307 }
78308
78309 /**
78310 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
78311 * Always returns 0 thus allowing this function to be tail-called at the end
78312 * of, say, sys_setgid().
78313 */
78314 -int commit_creds(struct cred *new)
78315 +static int __commit_creds(struct cred *new)
78316 {
78317 struct task_struct *task = current;
78318 const struct cred *old = task->real_cred;
78319 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
78320
78321 get_cred(new); /* we will require a ref for the subj creds too */
78322
78323 + gr_set_role_label(task, new->uid, new->gid);
78324 +
78325 /* dumpability changes */
78326 if (!uid_eq(old->euid, new->euid) ||
78327 !gid_eq(old->egid, new->egid) ||
78328 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
78329 put_cred(old);
78330 return 0;
78331 }
78332 +#ifdef CONFIG_GRKERNSEC_SETXID
78333 +extern int set_user(struct cred *new);
78334 +
78335 +void gr_delayed_cred_worker(void)
78336 +{
78337 + const struct cred *new = current->delayed_cred;
78338 + struct cred *ncred;
78339 +
78340 + current->delayed_cred = NULL;
78341 +
78342 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
78343 + // from doing get_cred on it when queueing this
78344 + put_cred(new);
78345 + return;
78346 + } else if (new == NULL)
78347 + return;
78348 +
78349 + ncred = prepare_creds();
78350 + if (!ncred)
78351 + goto die;
78352 + // uids
78353 + ncred->uid = new->uid;
78354 + ncred->euid = new->euid;
78355 + ncred->suid = new->suid;
78356 + ncred->fsuid = new->fsuid;
78357 + // gids
78358 + ncred->gid = new->gid;
78359 + ncred->egid = new->egid;
78360 + ncred->sgid = new->sgid;
78361 + ncred->fsgid = new->fsgid;
78362 + // groups
78363 + if (set_groups(ncred, new->group_info) < 0) {
78364 + abort_creds(ncred);
78365 + goto die;
78366 + }
78367 + // caps
78368 + ncred->securebits = new->securebits;
78369 + ncred->cap_inheritable = new->cap_inheritable;
78370 + ncred->cap_permitted = new->cap_permitted;
78371 + ncred->cap_effective = new->cap_effective;
78372 + ncred->cap_bset = new->cap_bset;
78373 +
78374 + if (set_user(ncred)) {
78375 + abort_creds(ncred);
78376 + goto die;
78377 + }
78378 +
78379 + // from doing get_cred on it when queueing this
78380 + put_cred(new);
78381 +
78382 + __commit_creds(ncred);
78383 + return;
78384 +die:
78385 + // from doing get_cred on it when queueing this
78386 + put_cred(new);
78387 + do_group_exit(SIGKILL);
78388 +}
78389 +#endif
78390 +
78391 +int commit_creds(struct cred *new)
78392 +{
78393 +#ifdef CONFIG_GRKERNSEC_SETXID
78394 + int ret;
78395 + int schedule_it = 0;
78396 + struct task_struct *t;
78397 +
78398 + /* we won't get called with tasklist_lock held for writing
78399 + and interrupts disabled as the cred struct in that case is
78400 + init_cred
78401 + */
78402 + if (grsec_enable_setxid && !current_is_single_threaded() &&
78403 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
78404 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
78405 + schedule_it = 1;
78406 + }
78407 + ret = __commit_creds(new);
78408 + if (schedule_it) {
78409 + rcu_read_lock();
78410 + read_lock(&tasklist_lock);
78411 + for (t = next_thread(current); t != current;
78412 + t = next_thread(t)) {
78413 + if (t->delayed_cred == NULL) {
78414 + t->delayed_cred = get_cred(new);
78415 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
78416 + set_tsk_need_resched(t);
78417 + }
78418 + }
78419 + read_unlock(&tasklist_lock);
78420 + rcu_read_unlock();
78421 + }
78422 + return ret;
78423 +#else
78424 + return __commit_creds(new);
78425 +#endif
78426 +}
78427 +
78428 EXPORT_SYMBOL(commit_creds);
78429
78430 /**
78431 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
78432 index 0506d44..2c20034 100644
78433 --- a/kernel/debug/debug_core.c
78434 +++ b/kernel/debug/debug_core.c
78435 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
78436 */
78437 static atomic_t masters_in_kgdb;
78438 static atomic_t slaves_in_kgdb;
78439 -static atomic_t kgdb_break_tasklet_var;
78440 +static atomic_unchecked_t kgdb_break_tasklet_var;
78441 atomic_t kgdb_setting_breakpoint;
78442
78443 struct task_struct *kgdb_usethread;
78444 @@ -133,7 +133,7 @@ int kgdb_single_step;
78445 static pid_t kgdb_sstep_pid;
78446
78447 /* to keep track of the CPU which is doing the single stepping*/
78448 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
78449 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
78450
78451 /*
78452 * If you are debugging a problem where roundup (the collection of
78453 @@ -541,7 +541,7 @@ return_normal:
78454 * kernel will only try for the value of sstep_tries before
78455 * giving up and continuing on.
78456 */
78457 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
78458 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
78459 (kgdb_info[cpu].task &&
78460 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
78461 atomic_set(&kgdb_active, -1);
78462 @@ -635,8 +635,8 @@ cpu_master_loop:
78463 }
78464
78465 kgdb_restore:
78466 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
78467 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
78468 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
78469 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
78470 if (kgdb_info[sstep_cpu].task)
78471 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
78472 else
78473 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
78474 static void kgdb_tasklet_bpt(unsigned long ing)
78475 {
78476 kgdb_breakpoint();
78477 - atomic_set(&kgdb_break_tasklet_var, 0);
78478 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
78479 }
78480
78481 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
78482
78483 void kgdb_schedule_breakpoint(void)
78484 {
78485 - if (atomic_read(&kgdb_break_tasklet_var) ||
78486 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
78487 atomic_read(&kgdb_active) != -1 ||
78488 atomic_read(&kgdb_setting_breakpoint))
78489 return;
78490 - atomic_inc(&kgdb_break_tasklet_var);
78491 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
78492 tasklet_schedule(&kgdb_tasklet_breakpoint);
78493 }
78494 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
78495 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
78496 index 00eb8f7..d7e3244 100644
78497 --- a/kernel/debug/kdb/kdb_main.c
78498 +++ b/kernel/debug/kdb/kdb_main.c
78499 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
78500 continue;
78501
78502 kdb_printf("%-20s%8u 0x%p ", mod->name,
78503 - mod->core_size, (void *)mod);
78504 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
78505 #ifdef CONFIG_MODULE_UNLOAD
78506 kdb_printf("%4ld ", module_refcount(mod));
78507 #endif
78508 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
78509 kdb_printf(" (Loading)");
78510 else
78511 kdb_printf(" (Live)");
78512 - kdb_printf(" 0x%p", mod->module_core);
78513 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
78514
78515 #ifdef CONFIG_MODULE_UNLOAD
78516 {
78517 diff --git a/kernel/events/core.c b/kernel/events/core.c
78518 index e76e495..cbfe63a 100644
78519 --- a/kernel/events/core.c
78520 +++ b/kernel/events/core.c
78521 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
78522 * 0 - disallow raw tracepoint access for unpriv
78523 * 1 - disallow cpu events for unpriv
78524 * 2 - disallow kernel profiling for unpriv
78525 + * 3 - disallow all unpriv perf event use
78526 */
78527 -int sysctl_perf_event_paranoid __read_mostly = 1;
78528 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
78529 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
78530 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
78531 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
78532 +#else
78533 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
78534 +#endif
78535
78536 /* Minimum for 512 kiB + 1 user control page */
78537 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
78538 @@ -184,7 +191,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
78539 return 0;
78540 }
78541
78542 -static atomic64_t perf_event_id;
78543 +static atomic64_unchecked_t perf_event_id;
78544
78545 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
78546 enum event_type_t event_type);
78547 @@ -2747,7 +2754,7 @@ static void __perf_event_read(void *info)
78548
78549 static inline u64 perf_event_count(struct perf_event *event)
78550 {
78551 - return local64_read(&event->count) + atomic64_read(&event->child_count);
78552 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
78553 }
78554
78555 static u64 perf_event_read(struct perf_event *event)
78556 @@ -3093,9 +3100,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
78557 mutex_lock(&event->child_mutex);
78558 total += perf_event_read(event);
78559 *enabled += event->total_time_enabled +
78560 - atomic64_read(&event->child_total_time_enabled);
78561 + atomic64_read_unchecked(&event->child_total_time_enabled);
78562 *running += event->total_time_running +
78563 - atomic64_read(&event->child_total_time_running);
78564 + atomic64_read_unchecked(&event->child_total_time_running);
78565
78566 list_for_each_entry(child, &event->child_list, child_list) {
78567 total += perf_event_read(child);
78568 @@ -3481,10 +3488,10 @@ void perf_event_update_userpage(struct perf_event *event)
78569 userpg->offset -= local64_read(&event->hw.prev_count);
78570
78571 userpg->time_enabled = enabled +
78572 - atomic64_read(&event->child_total_time_enabled);
78573 + atomic64_read_unchecked(&event->child_total_time_enabled);
78574
78575 userpg->time_running = running +
78576 - atomic64_read(&event->child_total_time_running);
78577 + atomic64_read_unchecked(&event->child_total_time_running);
78578
78579 arch_perf_update_userpage(userpg, now);
78580
78581 @@ -4034,7 +4041,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
78582
78583 /* Data. */
78584 sp = perf_user_stack_pointer(regs);
78585 - rem = __output_copy_user(handle, (void *) sp, dump_size);
78586 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
78587 dyn_size = dump_size - rem;
78588
78589 perf_output_skip(handle, rem);
78590 @@ -4122,11 +4129,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
78591 values[n++] = perf_event_count(event);
78592 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
78593 values[n++] = enabled +
78594 - atomic64_read(&event->child_total_time_enabled);
78595 + atomic64_read_unchecked(&event->child_total_time_enabled);
78596 }
78597 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
78598 values[n++] = running +
78599 - atomic64_read(&event->child_total_time_running);
78600 + atomic64_read_unchecked(&event->child_total_time_running);
78601 }
78602 if (read_format & PERF_FORMAT_ID)
78603 values[n++] = primary_event_id(event);
78604 @@ -4835,12 +4842,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
78605 * need to add enough zero bytes after the string to handle
78606 * the 64bit alignment we do later.
78607 */
78608 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
78609 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
78610 if (!buf) {
78611 name = strncpy(tmp, "//enomem", sizeof(tmp));
78612 goto got_name;
78613 }
78614 - name = d_path(&file->f_path, buf, PATH_MAX);
78615 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
78616 if (IS_ERR(name)) {
78617 name = strncpy(tmp, "//toolong", sizeof(tmp));
78618 goto got_name;
78619 @@ -6262,7 +6269,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
78620 event->parent = parent_event;
78621
78622 event->ns = get_pid_ns(task_active_pid_ns(current));
78623 - event->id = atomic64_inc_return(&perf_event_id);
78624 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
78625
78626 event->state = PERF_EVENT_STATE_INACTIVE;
78627
78628 @@ -6572,6 +6579,11 @@ SYSCALL_DEFINE5(perf_event_open,
78629 if (flags & ~PERF_FLAG_ALL)
78630 return -EINVAL;
78631
78632 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
78633 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
78634 + return -EACCES;
78635 +#endif
78636 +
78637 err = perf_copy_attr(attr_uptr, &attr);
78638 if (err)
78639 return err;
78640 @@ -6904,10 +6916,10 @@ static void sync_child_event(struct perf_event *child_event,
78641 /*
78642 * Add back the child's count to the parent's count:
78643 */
78644 - atomic64_add(child_val, &parent_event->child_count);
78645 - atomic64_add(child_event->total_time_enabled,
78646 + atomic64_add_unchecked(child_val, &parent_event->child_count);
78647 + atomic64_add_unchecked(child_event->total_time_enabled,
78648 &parent_event->child_total_time_enabled);
78649 - atomic64_add(child_event->total_time_running,
78650 + atomic64_add_unchecked(child_event->total_time_running,
78651 &parent_event->child_total_time_running);
78652
78653 /*
78654 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
78655 index ca65997..cc8cee4 100644
78656 --- a/kernel/events/internal.h
78657 +++ b/kernel/events/internal.h
78658 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
78659 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
78660 }
78661
78662 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
78663 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
78664 static inline unsigned int \
78665 func_name(struct perf_output_handle *handle, \
78666 - const void *buf, unsigned int len) \
78667 + const void user *buf, unsigned int len) \
78668 { \
78669 unsigned long size, written; \
78670 \
78671 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
78672 return n;
78673 }
78674
78675 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
78676 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
78677
78678 #define MEMCPY_SKIP(dst, src, n) (n)
78679
78680 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
78681 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
78682
78683 #ifndef arch_perf_out_copy_user
78684 #define arch_perf_out_copy_user __copy_from_user_inatomic
78685 #endif
78686
78687 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
78688 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
78689
78690 /* Callchain handling */
78691 extern struct perf_callchain_entry *
78692 diff --git a/kernel/exit.c b/kernel/exit.c
78693 index 7bb73f9..d7978ed 100644
78694 --- a/kernel/exit.c
78695 +++ b/kernel/exit.c
78696 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
78697 struct task_struct *leader;
78698 int zap_leader;
78699 repeat:
78700 +#ifdef CONFIG_NET
78701 + gr_del_task_from_ip_table(p);
78702 +#endif
78703 +
78704 /* don't need to get the RCU readlock here - the process is dead and
78705 * can't be modifying its own credentials. But shut RCU-lockdep up */
78706 rcu_read_lock();
78707 @@ -340,7 +344,7 @@ int allow_signal(int sig)
78708 * know it'll be handled, so that they don't get converted to
78709 * SIGKILL or just silently dropped.
78710 */
78711 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
78712 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
78713 recalc_sigpending();
78714 spin_unlock_irq(&current->sighand->siglock);
78715 return 0;
78716 @@ -709,6 +713,8 @@ void do_exit(long code)
78717 struct task_struct *tsk = current;
78718 int group_dead;
78719
78720 + set_fs(USER_DS);
78721 +
78722 profile_task_exit(tsk);
78723
78724 WARN_ON(blk_needs_flush_plug(tsk));
78725 @@ -725,7 +731,6 @@ void do_exit(long code)
78726 * mm_release()->clear_child_tid() from writing to a user-controlled
78727 * kernel address.
78728 */
78729 - set_fs(USER_DS);
78730
78731 ptrace_event(PTRACE_EVENT_EXIT, code);
78732
78733 @@ -784,6 +789,9 @@ void do_exit(long code)
78734 tsk->exit_code = code;
78735 taskstats_exit(tsk, group_dead);
78736
78737 + gr_acl_handle_psacct(tsk, code);
78738 + gr_acl_handle_exit();
78739 +
78740 exit_mm(tsk);
78741
78742 if (group_dead)
78743 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
78744 * Take down every thread in the group. This is called by fatal signals
78745 * as well as by sys_exit_group (below).
78746 */
78747 -void
78748 +__noreturn void
78749 do_group_exit(int exit_code)
78750 {
78751 struct signal_struct *sig = current->signal;
78752 diff --git a/kernel/fork.c b/kernel/fork.c
78753 index 987b28a..11ee8a5 100644
78754 --- a/kernel/fork.c
78755 +++ b/kernel/fork.c
78756 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
78757 *stackend = STACK_END_MAGIC; /* for overflow detection */
78758
78759 #ifdef CONFIG_CC_STACKPROTECTOR
78760 - tsk->stack_canary = get_random_int();
78761 + tsk->stack_canary = pax_get_random_long();
78762 #endif
78763
78764 /*
78765 @@ -345,13 +345,81 @@ free_tsk:
78766 }
78767
78768 #ifdef CONFIG_MMU
78769 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
78770 +{
78771 + struct vm_area_struct *tmp;
78772 + unsigned long charge;
78773 + struct mempolicy *pol;
78774 + struct file *file;
78775 +
78776 + charge = 0;
78777 + if (mpnt->vm_flags & VM_ACCOUNT) {
78778 + unsigned long len = vma_pages(mpnt);
78779 +
78780 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
78781 + goto fail_nomem;
78782 + charge = len;
78783 + }
78784 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
78785 + if (!tmp)
78786 + goto fail_nomem;
78787 + *tmp = *mpnt;
78788 + tmp->vm_mm = mm;
78789 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
78790 + pol = mpol_dup(vma_policy(mpnt));
78791 + if (IS_ERR(pol))
78792 + goto fail_nomem_policy;
78793 + vma_set_policy(tmp, pol);
78794 + if (anon_vma_fork(tmp, mpnt))
78795 + goto fail_nomem_anon_vma_fork;
78796 + tmp->vm_flags &= ~VM_LOCKED;
78797 + tmp->vm_next = tmp->vm_prev = NULL;
78798 + tmp->vm_mirror = NULL;
78799 + file = tmp->vm_file;
78800 + if (file) {
78801 + struct inode *inode = file_inode(file);
78802 + struct address_space *mapping = file->f_mapping;
78803 +
78804 + get_file(file);
78805 + if (tmp->vm_flags & VM_DENYWRITE)
78806 + atomic_dec(&inode->i_writecount);
78807 + mutex_lock(&mapping->i_mmap_mutex);
78808 + if (tmp->vm_flags & VM_SHARED)
78809 + mapping->i_mmap_writable++;
78810 + flush_dcache_mmap_lock(mapping);
78811 + /* insert tmp into the share list, just after mpnt */
78812 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
78813 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
78814 + else
78815 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
78816 + flush_dcache_mmap_unlock(mapping);
78817 + mutex_unlock(&mapping->i_mmap_mutex);
78818 + }
78819 +
78820 + /*
78821 + * Clear hugetlb-related page reserves for children. This only
78822 + * affects MAP_PRIVATE mappings. Faults generated by the child
78823 + * are not guaranteed to succeed, even if read-only
78824 + */
78825 + if (is_vm_hugetlb_page(tmp))
78826 + reset_vma_resv_huge_pages(tmp);
78827 +
78828 + return tmp;
78829 +
78830 +fail_nomem_anon_vma_fork:
78831 + mpol_put(pol);
78832 +fail_nomem_policy:
78833 + kmem_cache_free(vm_area_cachep, tmp);
78834 +fail_nomem:
78835 + vm_unacct_memory(charge);
78836 + return NULL;
78837 +}
78838 +
78839 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
78840 {
78841 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
78842 struct rb_node **rb_link, *rb_parent;
78843 int retval;
78844 - unsigned long charge;
78845 - struct mempolicy *pol;
78846
78847 uprobe_start_dup_mmap();
78848 down_write(&oldmm->mmap_sem);
78849 @@ -365,8 +433,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
78850 mm->locked_vm = 0;
78851 mm->mmap = NULL;
78852 mm->mmap_cache = NULL;
78853 - mm->free_area_cache = oldmm->mmap_base;
78854 - mm->cached_hole_size = ~0UL;
78855 + mm->free_area_cache = oldmm->free_area_cache;
78856 + mm->cached_hole_size = oldmm->cached_hole_size;
78857 mm->map_count = 0;
78858 cpumask_clear(mm_cpumask(mm));
78859 mm->mm_rb = RB_ROOT;
78860 @@ -382,57 +450,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
78861
78862 prev = NULL;
78863 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
78864 - struct file *file;
78865 -
78866 if (mpnt->vm_flags & VM_DONTCOPY) {
78867 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
78868 -vma_pages(mpnt));
78869 continue;
78870 }
78871 - charge = 0;
78872 - if (mpnt->vm_flags & VM_ACCOUNT) {
78873 - unsigned long len = vma_pages(mpnt);
78874 -
78875 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
78876 - goto fail_nomem;
78877 - charge = len;
78878 - }
78879 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
78880 - if (!tmp)
78881 - goto fail_nomem;
78882 - *tmp = *mpnt;
78883 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
78884 - pol = mpol_dup(vma_policy(mpnt));
78885 - retval = PTR_ERR(pol);
78886 - if (IS_ERR(pol))
78887 - goto fail_nomem_policy;
78888 - vma_set_policy(tmp, pol);
78889 - tmp->vm_mm = mm;
78890 - if (anon_vma_fork(tmp, mpnt))
78891 - goto fail_nomem_anon_vma_fork;
78892 - tmp->vm_flags &= ~VM_LOCKED;
78893 - tmp->vm_next = tmp->vm_prev = NULL;
78894 - file = tmp->vm_file;
78895 - if (file) {
78896 - struct inode *inode = file_inode(file);
78897 - struct address_space *mapping = file->f_mapping;
78898 -
78899 - get_file(file);
78900 - if (tmp->vm_flags & VM_DENYWRITE)
78901 - atomic_dec(&inode->i_writecount);
78902 - mutex_lock(&mapping->i_mmap_mutex);
78903 - if (tmp->vm_flags & VM_SHARED)
78904 - mapping->i_mmap_writable++;
78905 - flush_dcache_mmap_lock(mapping);
78906 - /* insert tmp into the share list, just after mpnt */
78907 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
78908 - vma_nonlinear_insert(tmp,
78909 - &mapping->i_mmap_nonlinear);
78910 - else
78911 - vma_interval_tree_insert_after(tmp, mpnt,
78912 - &mapping->i_mmap);
78913 - flush_dcache_mmap_unlock(mapping);
78914 - mutex_unlock(&mapping->i_mmap_mutex);
78915 + tmp = dup_vma(mm, oldmm, mpnt);
78916 + if (!tmp) {
78917 + retval = -ENOMEM;
78918 + goto out;
78919 }
78920
78921 /*
78922 @@ -464,6 +490,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
78923 if (retval)
78924 goto out;
78925 }
78926 +
78927 +#ifdef CONFIG_PAX_SEGMEXEC
78928 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
78929 + struct vm_area_struct *mpnt_m;
78930 +
78931 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
78932 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
78933 +
78934 + if (!mpnt->vm_mirror)
78935 + continue;
78936 +
78937 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
78938 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
78939 + mpnt->vm_mirror = mpnt_m;
78940 + } else {
78941 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
78942 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
78943 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
78944 + mpnt->vm_mirror->vm_mirror = mpnt;
78945 + }
78946 + }
78947 + BUG_ON(mpnt_m);
78948 + }
78949 +#endif
78950 +
78951 /* a new mm has just been created */
78952 arch_dup_mmap(oldmm, mm);
78953 retval = 0;
78954 @@ -473,14 +524,6 @@ out:
78955 up_write(&oldmm->mmap_sem);
78956 uprobe_end_dup_mmap();
78957 return retval;
78958 -fail_nomem_anon_vma_fork:
78959 - mpol_put(pol);
78960 -fail_nomem_policy:
78961 - kmem_cache_free(vm_area_cachep, tmp);
78962 -fail_nomem:
78963 - retval = -ENOMEM;
78964 - vm_unacct_memory(charge);
78965 - goto out;
78966 }
78967
78968 static inline int mm_alloc_pgd(struct mm_struct *mm)
78969 @@ -695,8 +738,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
78970 return ERR_PTR(err);
78971
78972 mm = get_task_mm(task);
78973 - if (mm && mm != current->mm &&
78974 - !ptrace_may_access(task, mode)) {
78975 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
78976 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
78977 mmput(mm);
78978 mm = ERR_PTR(-EACCES);
78979 }
78980 @@ -918,13 +961,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
78981 spin_unlock(&fs->lock);
78982 return -EAGAIN;
78983 }
78984 - fs->users++;
78985 + atomic_inc(&fs->users);
78986 spin_unlock(&fs->lock);
78987 return 0;
78988 }
78989 tsk->fs = copy_fs_struct(fs);
78990 if (!tsk->fs)
78991 return -ENOMEM;
78992 + /* Carry through gr_chroot_dentry and is_chrooted instead
78993 + of recomputing it here. Already copied when the task struct
78994 + is duplicated. This allows pivot_root to not be treated as
78995 + a chroot
78996 + */
78997 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
78998 +
78999 return 0;
79000 }
79001
79002 @@ -1197,10 +1247,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
79003 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
79004 #endif
79005 retval = -EAGAIN;
79006 +
79007 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
79008 +
79009 if (atomic_read(&p->real_cred->user->processes) >=
79010 task_rlimit(p, RLIMIT_NPROC)) {
79011 - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
79012 - p->real_cred->user != INIT_USER)
79013 + if (p->real_cred->user != INIT_USER &&
79014 + !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))
79015 goto bad_fork_free;
79016 }
79017 current->flags &= ~PF_NPROC_EXCEEDED;
79018 @@ -1446,6 +1499,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
79019 goto bad_fork_free_pid;
79020 }
79021
79022 + /* synchronizes with gr_set_acls()
79023 + we need to call this past the point of no return for fork()
79024 + */
79025 + gr_copy_label(p);
79026 +
79027 if (clone_flags & CLONE_THREAD) {
79028 current->signal->nr_threads++;
79029 atomic_inc(&current->signal->live);
79030 @@ -1529,6 +1587,8 @@ bad_fork_cleanup_count:
79031 bad_fork_free:
79032 free_task(p);
79033 fork_out:
79034 + gr_log_forkfail(retval);
79035 +
79036 return ERR_PTR(retval);
79037 }
79038
79039 @@ -1613,6 +1673,8 @@ long do_fork(unsigned long clone_flags,
79040 if (clone_flags & CLONE_PARENT_SETTID)
79041 put_user(nr, parent_tidptr);
79042
79043 + gr_handle_brute_check();
79044 +
79045 if (clone_flags & CLONE_VFORK) {
79046 p->vfork_done = &vfork;
79047 init_completion(&vfork);
79048 @@ -1723,7 +1785,7 @@ void __init proc_caches_init(void)
79049 mm_cachep = kmem_cache_create("mm_struct",
79050 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
79051 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
79052 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
79053 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
79054 mmap_init();
79055 nsproxy_cache_init();
79056 }
79057 @@ -1763,7 +1825,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
79058 return 0;
79059
79060 /* don't need lock here; in the worst case we'll do useless copy */
79061 - if (fs->users == 1)
79062 + if (atomic_read(&fs->users) == 1)
79063 return 0;
79064
79065 *new_fsp = copy_fs_struct(fs);
79066 @@ -1875,7 +1937,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
79067 fs = current->fs;
79068 spin_lock(&fs->lock);
79069 current->fs = new_fs;
79070 - if (--fs->users)
79071 + gr_set_chroot_entries(current, &current->fs->root);
79072 + if (atomic_dec_return(&fs->users))
79073 new_fs = NULL;
79074 else
79075 new_fs = fs;
79076 diff --git a/kernel/futex.c b/kernel/futex.c
79077 index 49dacfb..5c6b450 100644
79078 --- a/kernel/futex.c
79079 +++ b/kernel/futex.c
79080 @@ -54,6 +54,7 @@
79081 #include <linux/mount.h>
79082 #include <linux/pagemap.h>
79083 #include <linux/syscalls.h>
79084 +#include <linux/ptrace.h>
79085 #include <linux/signal.h>
79086 #include <linux/export.h>
79087 #include <linux/magic.h>
79088 @@ -242,6 +243,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
79089 struct page *page, *page_head;
79090 int err, ro = 0;
79091
79092 +#ifdef CONFIG_PAX_SEGMEXEC
79093 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
79094 + return -EFAULT;
79095 +#endif
79096 +
79097 /*
79098 * The futex address must be "naturally" aligned.
79099 */
79100 @@ -2733,6 +2739,7 @@ static int __init futex_init(void)
79101 {
79102 u32 curval;
79103 int i;
79104 + mm_segment_t oldfs;
79105
79106 /*
79107 * This will fail and we want it. Some arch implementations do
79108 @@ -2744,8 +2751,11 @@ static int __init futex_init(void)
79109 * implementation, the non-functional ones will return
79110 * -ENOSYS.
79111 */
79112 + oldfs = get_fs();
79113 + set_fs(USER_DS);
79114 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
79115 futex_cmpxchg_enabled = 1;
79116 + set_fs(oldfs);
79117
79118 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
79119 plist_head_init(&futex_queues[i].chain);
79120 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
79121 index f9f44fd..29885e4 100644
79122 --- a/kernel/futex_compat.c
79123 +++ b/kernel/futex_compat.c
79124 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
79125 return 0;
79126 }
79127
79128 -static void __user *futex_uaddr(struct robust_list __user *entry,
79129 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
79130 compat_long_t futex_offset)
79131 {
79132 compat_uptr_t base = ptr_to_compat(entry);
79133 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
79134 index 9b22d03..6295b62 100644
79135 --- a/kernel/gcov/base.c
79136 +++ b/kernel/gcov/base.c
79137 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
79138 }
79139
79140 #ifdef CONFIG_MODULES
79141 -static inline int within(void *addr, void *start, unsigned long size)
79142 -{
79143 - return ((addr >= start) && (addr < start + size));
79144 -}
79145 -
79146 /* Update list and generate events when modules are unloaded. */
79147 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
79148 void *data)
79149 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
79150 prev = NULL;
79151 /* Remove entries located in module from linked list. */
79152 for (info = gcov_info_head; info; info = info->next) {
79153 - if (within(info, mod->module_core, mod->core_size)) {
79154 + if (within_module_core_rw((unsigned long)info, mod)) {
79155 if (prev)
79156 prev->next = info->next;
79157 else
79158 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
79159 index 2288fbd..0f3941f 100644
79160 --- a/kernel/hrtimer.c
79161 +++ b/kernel/hrtimer.c
79162 @@ -1435,7 +1435,7 @@ void hrtimer_peek_ahead_timers(void)
79163 local_irq_restore(flags);
79164 }
79165
79166 -static void run_hrtimer_softirq(struct softirq_action *h)
79167 +static void run_hrtimer_softirq(void)
79168 {
79169 hrtimer_peek_ahead_timers();
79170 }
79171 @@ -1770,7 +1770,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
79172 return NOTIFY_OK;
79173 }
79174
79175 -static struct notifier_block __cpuinitdata hrtimers_nb = {
79176 +static struct notifier_block hrtimers_nb = {
79177 .notifier_call = hrtimer_cpu_notify,
79178 };
79179
79180 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
79181 index 55fcce6..0e4cf34 100644
79182 --- a/kernel/irq_work.c
79183 +++ b/kernel/irq_work.c
79184 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
79185 return NOTIFY_OK;
79186 }
79187
79188 -static struct notifier_block cpu_notify;
79189 +static struct notifier_block cpu_notify = {
79190 + .notifier_call = irq_work_cpu_notify,
79191 + .priority = 0,
79192 +};
79193
79194 static __init int irq_work_init_cpu_notifier(void)
79195 {
79196 - cpu_notify.notifier_call = irq_work_cpu_notify;
79197 - cpu_notify.priority = 0;
79198 register_cpu_notifier(&cpu_notify);
79199 return 0;
79200 }
79201 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
79202 index 60f48fa..7f3a770 100644
79203 --- a/kernel/jump_label.c
79204 +++ b/kernel/jump_label.c
79205 @@ -13,6 +13,7 @@
79206 #include <linux/sort.h>
79207 #include <linux/err.h>
79208 #include <linux/static_key.h>
79209 +#include <linux/mm.h>
79210
79211 #ifdef HAVE_JUMP_LABEL
79212
79213 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
79214
79215 size = (((unsigned long)stop - (unsigned long)start)
79216 / sizeof(struct jump_entry));
79217 + pax_open_kernel();
79218 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
79219 + pax_close_kernel();
79220 }
79221
79222 static void jump_label_update(struct static_key *key, int enable);
79223 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
79224 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
79225 struct jump_entry *iter;
79226
79227 + pax_open_kernel();
79228 for (iter = iter_start; iter < iter_stop; iter++) {
79229 if (within_module_init(iter->code, mod))
79230 iter->code = 0;
79231 }
79232 + pax_close_kernel();
79233 }
79234
79235 static int
79236 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
79237 index 3127ad5..159d880 100644
79238 --- a/kernel/kallsyms.c
79239 +++ b/kernel/kallsyms.c
79240 @@ -11,6 +11,9 @@
79241 * Changed the compression method from stem compression to "table lookup"
79242 * compression (see scripts/kallsyms.c for a more complete description)
79243 */
79244 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79245 +#define __INCLUDED_BY_HIDESYM 1
79246 +#endif
79247 #include <linux/kallsyms.h>
79248 #include <linux/module.h>
79249 #include <linux/init.h>
79250 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
79251
79252 static inline int is_kernel_inittext(unsigned long addr)
79253 {
79254 + if (system_state != SYSTEM_BOOTING)
79255 + return 0;
79256 +
79257 if (addr >= (unsigned long)_sinittext
79258 && addr <= (unsigned long)_einittext)
79259 return 1;
79260 return 0;
79261 }
79262
79263 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
79264 +#ifdef CONFIG_MODULES
79265 +static inline int is_module_text(unsigned long addr)
79266 +{
79267 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
79268 + return 1;
79269 +
79270 + addr = ktla_ktva(addr);
79271 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
79272 +}
79273 +#else
79274 +static inline int is_module_text(unsigned long addr)
79275 +{
79276 + return 0;
79277 +}
79278 +#endif
79279 +#endif
79280 +
79281 static inline int is_kernel_text(unsigned long addr)
79282 {
79283 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
79284 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
79285
79286 static inline int is_kernel(unsigned long addr)
79287 {
79288 +
79289 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
79290 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
79291 + return 1;
79292 +
79293 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
79294 +#else
79295 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
79296 +#endif
79297 +
79298 return 1;
79299 return in_gate_area_no_mm(addr);
79300 }
79301
79302 static int is_ksym_addr(unsigned long addr)
79303 {
79304 +
79305 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
79306 + if (is_module_text(addr))
79307 + return 0;
79308 +#endif
79309 +
79310 if (all_var)
79311 return is_kernel(addr);
79312
79313 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
79314
79315 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
79316 {
79317 - iter->name[0] = '\0';
79318 iter->nameoff = get_symbol_offset(new_pos);
79319 iter->pos = new_pos;
79320 }
79321 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
79322 {
79323 struct kallsym_iter *iter = m->private;
79324
79325 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79326 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
79327 + return 0;
79328 +#endif
79329 +
79330 /* Some debugging symbols have no name. Ignore them. */
79331 if (!iter->name[0])
79332 return 0;
79333 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
79334 */
79335 type = iter->exported ? toupper(iter->type) :
79336 tolower(iter->type);
79337 +
79338 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
79339 type, iter->name, iter->module_name);
79340 } else
79341 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
79342 struct kallsym_iter *iter;
79343 int ret;
79344
79345 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
79346 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
79347 if (!iter)
79348 return -ENOMEM;
79349 reset_iter(iter, 0);
79350 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
79351 index e30ac0f..3528cac 100644
79352 --- a/kernel/kcmp.c
79353 +++ b/kernel/kcmp.c
79354 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
79355 struct task_struct *task1, *task2;
79356 int ret;
79357
79358 +#ifdef CONFIG_GRKERNSEC
79359 + return -ENOSYS;
79360 +#endif
79361 +
79362 rcu_read_lock();
79363
79364 /*
79365 diff --git a/kernel/kexec.c b/kernel/kexec.c
79366 index 59f7b55..4022f65 100644
79367 --- a/kernel/kexec.c
79368 +++ b/kernel/kexec.c
79369 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
79370 unsigned long flags)
79371 {
79372 struct compat_kexec_segment in;
79373 - struct kexec_segment out, __user *ksegments;
79374 + struct kexec_segment out;
79375 + struct kexec_segment __user *ksegments;
79376 unsigned long i, result;
79377
79378 /* Don't allow clients that don't understand the native
79379 diff --git a/kernel/kmod.c b/kernel/kmod.c
79380 index 8241906..d625f2c 100644
79381 --- a/kernel/kmod.c
79382 +++ b/kernel/kmod.c
79383 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
79384 kfree(info->argv);
79385 }
79386
79387 -static int call_modprobe(char *module_name, int wait)
79388 +static int call_modprobe(char *module_name, char *module_param, int wait)
79389 {
79390 struct subprocess_info *info;
79391 static char *envp[] = {
79392 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
79393 NULL
79394 };
79395
79396 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
79397 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
79398 if (!argv)
79399 goto out;
79400
79401 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
79402 argv[1] = "-q";
79403 argv[2] = "--";
79404 argv[3] = module_name; /* check free_modprobe_argv() */
79405 - argv[4] = NULL;
79406 + argv[4] = module_param;
79407 + argv[5] = NULL;
79408
79409 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
79410 NULL, free_modprobe_argv, NULL);
79411 @@ -129,9 +130,8 @@ out:
79412 * If module auto-loading support is disabled then this function
79413 * becomes a no-operation.
79414 */
79415 -int __request_module(bool wait, const char *fmt, ...)
79416 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
79417 {
79418 - va_list args;
79419 char module_name[MODULE_NAME_LEN];
79420 unsigned int max_modprobes;
79421 int ret;
79422 @@ -147,9 +147,7 @@ int __request_module(bool wait, const char *fmt, ...)
79423 */
79424 WARN_ON_ONCE(wait && current_is_async());
79425
79426 - va_start(args, fmt);
79427 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
79428 - va_end(args);
79429 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
79430 if (ret >= MODULE_NAME_LEN)
79431 return -ENAMETOOLONG;
79432
79433 @@ -157,6 +155,20 @@ int __request_module(bool wait, const char *fmt, ...)
79434 if (ret)
79435 return ret;
79436
79437 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
79438 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
79439 + /* hack to workaround consolekit/udisks stupidity */
79440 + read_lock(&tasklist_lock);
79441 + if (!strcmp(current->comm, "mount") &&
79442 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
79443 + read_unlock(&tasklist_lock);
79444 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
79445 + return -EPERM;
79446 + }
79447 + read_unlock(&tasklist_lock);
79448 + }
79449 +#endif
79450 +
79451 /* If modprobe needs a service that is in a module, we get a recursive
79452 * loop. Limit the number of running kmod threads to max_threads/2 or
79453 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
79454 @@ -185,11 +197,52 @@ int __request_module(bool wait, const char *fmt, ...)
79455
79456 trace_module_request(module_name, wait, _RET_IP_);
79457
79458 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
79459 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
79460
79461 atomic_dec(&kmod_concurrent);
79462 return ret;
79463 }
79464 +
79465 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
79466 +{
79467 + va_list args;
79468 + int ret;
79469 +
79470 + va_start(args, fmt);
79471 + ret = ____request_module(wait, module_param, fmt, args);
79472 + va_end(args);
79473 +
79474 + return ret;
79475 +}
79476 +
79477 +int __request_module(bool wait, const char *fmt, ...)
79478 +{
79479 + va_list args;
79480 + int ret;
79481 +
79482 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
79483 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
79484 + char module_param[MODULE_NAME_LEN];
79485 +
79486 + memset(module_param, 0, sizeof(module_param));
79487 +
79488 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
79489 +
79490 + va_start(args, fmt);
79491 + ret = ____request_module(wait, module_param, fmt, args);
79492 + va_end(args);
79493 +
79494 + return ret;
79495 + }
79496 +#endif
79497 +
79498 + va_start(args, fmt);
79499 + ret = ____request_module(wait, NULL, fmt, args);
79500 + va_end(args);
79501 +
79502 + return ret;
79503 +}
79504 +
79505 EXPORT_SYMBOL(__request_module);
79506 #endif /* CONFIG_MODULES */
79507
79508 @@ -300,7 +353,7 @@ static int wait_for_helper(void *data)
79509 *
79510 * Thus the __user pointer cast is valid here.
79511 */
79512 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
79513 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
79514
79515 /*
79516 * If ret is 0, either ____call_usermodehelper failed and the
79517 @@ -651,7 +704,7 @@ EXPORT_SYMBOL(call_usermodehelper);
79518 static int proc_cap_handler(struct ctl_table *table, int write,
79519 void __user *buffer, size_t *lenp, loff_t *ppos)
79520 {
79521 - struct ctl_table t;
79522 + ctl_table_no_const t;
79523 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
79524 kernel_cap_t new_cap;
79525 int err, i;
79526 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
79527 index bddf3b2..233bf40 100644
79528 --- a/kernel/kprobes.c
79529 +++ b/kernel/kprobes.c
79530 @@ -31,6 +31,9 @@
79531 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
79532 * <prasanna@in.ibm.com> added function-return probes.
79533 */
79534 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79535 +#define __INCLUDED_BY_HIDESYM 1
79536 +#endif
79537 #include <linux/kprobes.h>
79538 #include <linux/hash.h>
79539 #include <linux/init.h>
79540 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
79541 * kernel image and loaded module images reside. This is required
79542 * so x86_64 can correctly handle the %rip-relative fixups.
79543 */
79544 - kip->insns = module_alloc(PAGE_SIZE);
79545 + kip->insns = module_alloc_exec(PAGE_SIZE);
79546 if (!kip->insns) {
79547 kfree(kip);
79548 return NULL;
79549 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
79550 */
79551 if (!list_is_singular(&kip->list)) {
79552 list_del(&kip->list);
79553 - module_free(NULL, kip->insns);
79554 + module_free_exec(NULL, kip->insns);
79555 kfree(kip);
79556 }
79557 return 1;
79558 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
79559 {
79560 int i, err = 0;
79561 unsigned long offset = 0, size = 0;
79562 - char *modname, namebuf[128];
79563 + char *modname, namebuf[KSYM_NAME_LEN];
79564 const char *symbol_name;
79565 void *addr;
79566 struct kprobe_blackpoint *kb;
79567 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
79568 kprobe_type = "k";
79569
79570 if (sym)
79571 - seq_printf(pi, "%p %s %s+0x%x %s ",
79572 + seq_printf(pi, "%pK %s %s+0x%x %s ",
79573 p->addr, kprobe_type, sym, offset,
79574 (modname ? modname : " "));
79575 else
79576 - seq_printf(pi, "%p %s %p ",
79577 + seq_printf(pi, "%pK %s %pK ",
79578 p->addr, kprobe_type, p->addr);
79579
79580 if (!pp)
79581 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
79582 const char *sym = NULL;
79583 unsigned int i = *(loff_t *) v;
79584 unsigned long offset = 0;
79585 - char *modname, namebuf[128];
79586 + char *modname, namebuf[KSYM_NAME_LEN];
79587
79588 head = &kprobe_table[i];
79589 preempt_disable();
79590 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
79591 index 6ada93c..dce7d5d 100644
79592 --- a/kernel/ksysfs.c
79593 +++ b/kernel/ksysfs.c
79594 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
79595 {
79596 if (count+1 > UEVENT_HELPER_PATH_LEN)
79597 return -ENOENT;
79598 + if (!capable(CAP_SYS_ADMIN))
79599 + return -EPERM;
79600 memcpy(uevent_helper, buf, count);
79601 uevent_helper[count] = '\0';
79602 if (count && uevent_helper[count-1] == '\n')
79603 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
79604 return count;
79605 }
79606
79607 -static struct bin_attribute notes_attr = {
79608 +static bin_attribute_no_const notes_attr __read_only = {
79609 .attr = {
79610 .name = "notes",
79611 .mode = S_IRUGO,
79612 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
79613 index 1f3186b..bb7dbc6 100644
79614 --- a/kernel/lockdep.c
79615 +++ b/kernel/lockdep.c
79616 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
79617 end = (unsigned long) &_end,
79618 addr = (unsigned long) obj;
79619
79620 +#ifdef CONFIG_PAX_KERNEXEC
79621 + start = ktla_ktva(start);
79622 +#endif
79623 +
79624 /*
79625 * static variable?
79626 */
79627 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
79628 if (!static_obj(lock->key)) {
79629 debug_locks_off();
79630 printk("INFO: trying to register non-static key.\n");
79631 + printk("lock:%pS key:%pS.\n", lock, lock->key);
79632 printk("the code is fine but needs lockdep annotation.\n");
79633 printk("turning off the locking correctness validator.\n");
79634 dump_stack();
79635 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
79636 if (!class)
79637 return 0;
79638 }
79639 - atomic_inc((atomic_t *)&class->ops);
79640 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
79641 if (very_verbose(class)) {
79642 printk("\nacquire class [%p] %s", class->key, class->name);
79643 if (class->name_version > 1)
79644 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
79645 index b2c71c5..7b88d63 100644
79646 --- a/kernel/lockdep_proc.c
79647 +++ b/kernel/lockdep_proc.c
79648 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
79649 return 0;
79650 }
79651
79652 - seq_printf(m, "%p", class->key);
79653 + seq_printf(m, "%pK", class->key);
79654 #ifdef CONFIG_DEBUG_LOCKDEP
79655 seq_printf(m, " OPS:%8ld", class->ops);
79656 #endif
79657 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
79658
79659 list_for_each_entry(entry, &class->locks_after, entry) {
79660 if (entry->distance == 1) {
79661 - seq_printf(m, " -> [%p] ", entry->class->key);
79662 + seq_printf(m, " -> [%pK] ", entry->class->key);
79663 print_name(m, entry->class);
79664 seq_puts(m, "\n");
79665 }
79666 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
79667 if (!class->key)
79668 continue;
79669
79670 - seq_printf(m, "[%p] ", class->key);
79671 + seq_printf(m, "[%pK] ", class->key);
79672 print_name(m, class);
79673 seq_puts(m, "\n");
79674 }
79675 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
79676 if (!i)
79677 seq_line(m, '-', 40-namelen, namelen);
79678
79679 - snprintf(ip, sizeof(ip), "[<%p>]",
79680 + snprintf(ip, sizeof(ip), "[<%pK>]",
79681 (void *)class->contention_point[i]);
79682 seq_printf(m, "%40s %14lu %29s %pS\n",
79683 name, stats->contention_point[i],
79684 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
79685 if (!i)
79686 seq_line(m, '-', 40-namelen, namelen);
79687
79688 - snprintf(ip, sizeof(ip), "[<%p>]",
79689 + snprintf(ip, sizeof(ip), "[<%pK>]",
79690 (void *)class->contending_point[i]);
79691 seq_printf(m, "%40s %14lu %29s %pS\n",
79692 name, stats->contending_point[i],
79693 diff --git a/kernel/module.c b/kernel/module.c
79694 index fa53db8..6f17200 100644
79695 --- a/kernel/module.c
79696 +++ b/kernel/module.c
79697 @@ -61,6 +61,7 @@
79698 #include <linux/pfn.h>
79699 #include <linux/bsearch.h>
79700 #include <linux/fips.h>
79701 +#include <linux/grsecurity.h>
79702 #include <uapi/linux/module.h>
79703 #include "module-internal.h"
79704
79705 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
79706
79707 /* Bounds of module allocation, for speeding __module_address.
79708 * Protected by module_mutex. */
79709 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
79710 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
79711 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
79712
79713 int register_module_notifier(struct notifier_block * nb)
79714 {
79715 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
79716 return true;
79717
79718 list_for_each_entry_rcu(mod, &modules, list) {
79719 - struct symsearch arr[] = {
79720 + struct symsearch modarr[] = {
79721 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
79722 NOT_GPL_ONLY, false },
79723 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
79724 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
79725 if (mod->state == MODULE_STATE_UNFORMED)
79726 continue;
79727
79728 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
79729 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
79730 return true;
79731 }
79732 return false;
79733 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
79734 static int percpu_modalloc(struct module *mod,
79735 unsigned long size, unsigned long align)
79736 {
79737 - if (align > PAGE_SIZE) {
79738 + if (align-1 >= PAGE_SIZE) {
79739 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
79740 mod->name, align, PAGE_SIZE);
79741 align = PAGE_SIZE;
79742 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
79743 static ssize_t show_coresize(struct module_attribute *mattr,
79744 struct module_kobject *mk, char *buffer)
79745 {
79746 - return sprintf(buffer, "%u\n", mk->mod->core_size);
79747 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
79748 }
79749
79750 static struct module_attribute modinfo_coresize =
79751 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
79752 static ssize_t show_initsize(struct module_attribute *mattr,
79753 struct module_kobject *mk, char *buffer)
79754 {
79755 - return sprintf(buffer, "%u\n", mk->mod->init_size);
79756 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
79757 }
79758
79759 static struct module_attribute modinfo_initsize =
79760 @@ -1313,7 +1315,7 @@ resolve_symbol_wait(struct module *mod,
79761 */
79762 #ifdef CONFIG_SYSFS
79763
79764 -#ifdef CONFIG_KALLSYMS
79765 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
79766 static inline bool sect_empty(const Elf_Shdr *sect)
79767 {
79768 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
79769 @@ -1453,7 +1455,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
79770 {
79771 unsigned int notes, loaded, i;
79772 struct module_notes_attrs *notes_attrs;
79773 - struct bin_attribute *nattr;
79774 + bin_attribute_no_const *nattr;
79775
79776 /* failed to create section attributes, so can't create notes */
79777 if (!mod->sect_attrs)
79778 @@ -1565,7 +1567,7 @@ static void del_usage_links(struct module *mod)
79779 static int module_add_modinfo_attrs(struct module *mod)
79780 {
79781 struct module_attribute *attr;
79782 - struct module_attribute *temp_attr;
79783 + module_attribute_no_const *temp_attr;
79784 int error = 0;
79785 int i;
79786
79787 @@ -1779,21 +1781,21 @@ static void set_section_ro_nx(void *base,
79788
79789 static void unset_module_core_ro_nx(struct module *mod)
79790 {
79791 - set_page_attributes(mod->module_core + mod->core_text_size,
79792 - mod->module_core + mod->core_size,
79793 + set_page_attributes(mod->module_core_rw,
79794 + mod->module_core_rw + mod->core_size_rw,
79795 set_memory_x);
79796 - set_page_attributes(mod->module_core,
79797 - mod->module_core + mod->core_ro_size,
79798 + set_page_attributes(mod->module_core_rx,
79799 + mod->module_core_rx + mod->core_size_rx,
79800 set_memory_rw);
79801 }
79802
79803 static void unset_module_init_ro_nx(struct module *mod)
79804 {
79805 - set_page_attributes(mod->module_init + mod->init_text_size,
79806 - mod->module_init + mod->init_size,
79807 + set_page_attributes(mod->module_init_rw,
79808 + mod->module_init_rw + mod->init_size_rw,
79809 set_memory_x);
79810 - set_page_attributes(mod->module_init,
79811 - mod->module_init + mod->init_ro_size,
79812 + set_page_attributes(mod->module_init_rx,
79813 + mod->module_init_rx + mod->init_size_rx,
79814 set_memory_rw);
79815 }
79816
79817 @@ -1806,14 +1808,14 @@ void set_all_modules_text_rw(void)
79818 list_for_each_entry_rcu(mod, &modules, list) {
79819 if (mod->state == MODULE_STATE_UNFORMED)
79820 continue;
79821 - if ((mod->module_core) && (mod->core_text_size)) {
79822 - set_page_attributes(mod->module_core,
79823 - mod->module_core + mod->core_text_size,
79824 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
79825 + set_page_attributes(mod->module_core_rx,
79826 + mod->module_core_rx + mod->core_size_rx,
79827 set_memory_rw);
79828 }
79829 - if ((mod->module_init) && (mod->init_text_size)) {
79830 - set_page_attributes(mod->module_init,
79831 - mod->module_init + mod->init_text_size,
79832 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
79833 + set_page_attributes(mod->module_init_rx,
79834 + mod->module_init_rx + mod->init_size_rx,
79835 set_memory_rw);
79836 }
79837 }
79838 @@ -1829,14 +1831,14 @@ void set_all_modules_text_ro(void)
79839 list_for_each_entry_rcu(mod, &modules, list) {
79840 if (mod->state == MODULE_STATE_UNFORMED)
79841 continue;
79842 - if ((mod->module_core) && (mod->core_text_size)) {
79843 - set_page_attributes(mod->module_core,
79844 - mod->module_core + mod->core_text_size,
79845 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
79846 + set_page_attributes(mod->module_core_rx,
79847 + mod->module_core_rx + mod->core_size_rx,
79848 set_memory_ro);
79849 }
79850 - if ((mod->module_init) && (mod->init_text_size)) {
79851 - set_page_attributes(mod->module_init,
79852 - mod->module_init + mod->init_text_size,
79853 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
79854 + set_page_attributes(mod->module_init_rx,
79855 + mod->module_init_rx + mod->init_size_rx,
79856 set_memory_ro);
79857 }
79858 }
79859 @@ -1887,16 +1889,19 @@ static void free_module(struct module *mod)
79860
79861 /* This may be NULL, but that's OK */
79862 unset_module_init_ro_nx(mod);
79863 - module_free(mod, mod->module_init);
79864 + module_free(mod, mod->module_init_rw);
79865 + module_free_exec(mod, mod->module_init_rx);
79866 kfree(mod->args);
79867 percpu_modfree(mod);
79868
79869 /* Free lock-classes: */
79870 - lockdep_free_key_range(mod->module_core, mod->core_size);
79871 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
79872 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
79873
79874 /* Finally, free the core (containing the module structure) */
79875 unset_module_core_ro_nx(mod);
79876 - module_free(mod, mod->module_core);
79877 + module_free_exec(mod, mod->module_core_rx);
79878 + module_free(mod, mod->module_core_rw);
79879
79880 #ifdef CONFIG_MPU
79881 update_protections(current->mm);
79882 @@ -1966,9 +1971,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
79883 int ret = 0;
79884 const struct kernel_symbol *ksym;
79885
79886 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
79887 + int is_fs_load = 0;
79888 + int register_filesystem_found = 0;
79889 + char *p;
79890 +
79891 + p = strstr(mod->args, "grsec_modharden_fs");
79892 + if (p) {
79893 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
79894 + /* copy \0 as well */
79895 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
79896 + is_fs_load = 1;
79897 + }
79898 +#endif
79899 +
79900 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
79901 const char *name = info->strtab + sym[i].st_name;
79902
79903 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
79904 + /* it's a real shame this will never get ripped and copied
79905 + upstream! ;(
79906 + */
79907 + if (is_fs_load && !strcmp(name, "register_filesystem"))
79908 + register_filesystem_found = 1;
79909 +#endif
79910 +
79911 switch (sym[i].st_shndx) {
79912 case SHN_COMMON:
79913 /* We compiled with -fno-common. These are not
79914 @@ -1989,7 +2016,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
79915 ksym = resolve_symbol_wait(mod, info, name);
79916 /* Ok if resolved. */
79917 if (ksym && !IS_ERR(ksym)) {
79918 + pax_open_kernel();
79919 sym[i].st_value = ksym->value;
79920 + pax_close_kernel();
79921 break;
79922 }
79923
79924 @@ -2008,11 +2037,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
79925 secbase = (unsigned long)mod_percpu(mod);
79926 else
79927 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
79928 + pax_open_kernel();
79929 sym[i].st_value += secbase;
79930 + pax_close_kernel();
79931 break;
79932 }
79933 }
79934
79935 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
79936 + if (is_fs_load && !register_filesystem_found) {
79937 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
79938 + ret = -EPERM;
79939 + }
79940 +#endif
79941 +
79942 return ret;
79943 }
79944
79945 @@ -2096,22 +2134,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
79946 || s->sh_entsize != ~0UL
79947 || strstarts(sname, ".init"))
79948 continue;
79949 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
79950 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
79951 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
79952 + else
79953 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
79954 pr_debug("\t%s\n", sname);
79955 }
79956 - switch (m) {
79957 - case 0: /* executable */
79958 - mod->core_size = debug_align(mod->core_size);
79959 - mod->core_text_size = mod->core_size;
79960 - break;
79961 - case 1: /* RO: text and ro-data */
79962 - mod->core_size = debug_align(mod->core_size);
79963 - mod->core_ro_size = mod->core_size;
79964 - break;
79965 - case 3: /* whole core */
79966 - mod->core_size = debug_align(mod->core_size);
79967 - break;
79968 - }
79969 }
79970
79971 pr_debug("Init section allocation order:\n");
79972 @@ -2125,23 +2153,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
79973 || s->sh_entsize != ~0UL
79974 || !strstarts(sname, ".init"))
79975 continue;
79976 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
79977 - | INIT_OFFSET_MASK);
79978 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
79979 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
79980 + else
79981 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
79982 + s->sh_entsize |= INIT_OFFSET_MASK;
79983 pr_debug("\t%s\n", sname);
79984 }
79985 - switch (m) {
79986 - case 0: /* executable */
79987 - mod->init_size = debug_align(mod->init_size);
79988 - mod->init_text_size = mod->init_size;
79989 - break;
79990 - case 1: /* RO: text and ro-data */
79991 - mod->init_size = debug_align(mod->init_size);
79992 - mod->init_ro_size = mod->init_size;
79993 - break;
79994 - case 3: /* whole init */
79995 - mod->init_size = debug_align(mod->init_size);
79996 - break;
79997 - }
79998 }
79999 }
80000
80001 @@ -2314,7 +2332,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
80002
80003 /* Put symbol section at end of init part of module. */
80004 symsect->sh_flags |= SHF_ALLOC;
80005 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
80006 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
80007 info->index.sym) | INIT_OFFSET_MASK;
80008 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
80009
80010 @@ -2331,13 +2349,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
80011 }
80012
80013 /* Append room for core symbols at end of core part. */
80014 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
80015 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
80016 - mod->core_size += strtab_size;
80017 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
80018 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
80019 + mod->core_size_rx += strtab_size;
80020
80021 /* Put string table section at end of init part of module. */
80022 strsect->sh_flags |= SHF_ALLOC;
80023 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
80024 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
80025 info->index.str) | INIT_OFFSET_MASK;
80026 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
80027 }
80028 @@ -2355,12 +2373,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
80029 /* Make sure we get permanent strtab: don't use info->strtab. */
80030 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
80031
80032 + pax_open_kernel();
80033 +
80034 /* Set types up while we still have access to sections. */
80035 for (i = 0; i < mod->num_symtab; i++)
80036 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
80037
80038 - mod->core_symtab = dst = mod->module_core + info->symoffs;
80039 - mod->core_strtab = s = mod->module_core + info->stroffs;
80040 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
80041 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
80042 src = mod->symtab;
80043 for (ndst = i = 0; i < mod->num_symtab; i++) {
80044 if (i == 0 ||
80045 @@ -2372,6 +2392,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
80046 }
80047 }
80048 mod->core_num_syms = ndst;
80049 +
80050 + pax_close_kernel();
80051 }
80052 #else
80053 static inline void layout_symtab(struct module *mod, struct load_info *info)
80054 @@ -2405,17 +2427,33 @@ void * __weak module_alloc(unsigned long size)
80055 return vmalloc_exec(size);
80056 }
80057
80058 -static void *module_alloc_update_bounds(unsigned long size)
80059 +static void *module_alloc_update_bounds_rw(unsigned long size)
80060 {
80061 void *ret = module_alloc(size);
80062
80063 if (ret) {
80064 mutex_lock(&module_mutex);
80065 /* Update module bounds. */
80066 - if ((unsigned long)ret < module_addr_min)
80067 - module_addr_min = (unsigned long)ret;
80068 - if ((unsigned long)ret + size > module_addr_max)
80069 - module_addr_max = (unsigned long)ret + size;
80070 + if ((unsigned long)ret < module_addr_min_rw)
80071 + module_addr_min_rw = (unsigned long)ret;
80072 + if ((unsigned long)ret + size > module_addr_max_rw)
80073 + module_addr_max_rw = (unsigned long)ret + size;
80074 + mutex_unlock(&module_mutex);
80075 + }
80076 + return ret;
80077 +}
80078 +
80079 +static void *module_alloc_update_bounds_rx(unsigned long size)
80080 +{
80081 + void *ret = module_alloc_exec(size);
80082 +
80083 + if (ret) {
80084 + mutex_lock(&module_mutex);
80085 + /* Update module bounds. */
80086 + if ((unsigned long)ret < module_addr_min_rx)
80087 + module_addr_min_rx = (unsigned long)ret;
80088 + if ((unsigned long)ret + size > module_addr_max_rx)
80089 + module_addr_max_rx = (unsigned long)ret + size;
80090 mutex_unlock(&module_mutex);
80091 }
80092 return ret;
80093 @@ -2691,8 +2729,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
80094 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
80095 {
80096 const char *modmagic = get_modinfo(info, "vermagic");
80097 + const char *license = get_modinfo(info, "license");
80098 int err;
80099
80100 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
80101 + if (!license || !license_is_gpl_compatible(license))
80102 + return -ENOEXEC;
80103 +#endif
80104 +
80105 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
80106 modmagic = NULL;
80107
80108 @@ -2718,7 +2762,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
80109 }
80110
80111 /* Set up license info based on the info section */
80112 - set_license(mod, get_modinfo(info, "license"));
80113 + set_license(mod, license);
80114
80115 return 0;
80116 }
80117 @@ -2799,7 +2843,7 @@ static int move_module(struct module *mod, struct load_info *info)
80118 void *ptr;
80119
80120 /* Do the allocs. */
80121 - ptr = module_alloc_update_bounds(mod->core_size);
80122 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
80123 /*
80124 * The pointer to this block is stored in the module structure
80125 * which is inside the block. Just mark it as not being a
80126 @@ -2809,11 +2853,11 @@ static int move_module(struct module *mod, struct load_info *info)
80127 if (!ptr)
80128 return -ENOMEM;
80129
80130 - memset(ptr, 0, mod->core_size);
80131 - mod->module_core = ptr;
80132 + memset(ptr, 0, mod->core_size_rw);
80133 + mod->module_core_rw = ptr;
80134
80135 - if (mod->init_size) {
80136 - ptr = module_alloc_update_bounds(mod->init_size);
80137 + if (mod->init_size_rw) {
80138 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
80139 /*
80140 * The pointer to this block is stored in the module structure
80141 * which is inside the block. This block doesn't need to be
80142 @@ -2822,13 +2866,45 @@ static int move_module(struct module *mod, struct load_info *info)
80143 */
80144 kmemleak_ignore(ptr);
80145 if (!ptr) {
80146 - module_free(mod, mod->module_core);
80147 + module_free(mod, mod->module_core_rw);
80148 return -ENOMEM;
80149 }
80150 - memset(ptr, 0, mod->init_size);
80151 - mod->module_init = ptr;
80152 + memset(ptr, 0, mod->init_size_rw);
80153 + mod->module_init_rw = ptr;
80154 } else
80155 - mod->module_init = NULL;
80156 + mod->module_init_rw = NULL;
80157 +
80158 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
80159 + kmemleak_not_leak(ptr);
80160 + if (!ptr) {
80161 + if (mod->module_init_rw)
80162 + module_free(mod, mod->module_init_rw);
80163 + module_free(mod, mod->module_core_rw);
80164 + return -ENOMEM;
80165 + }
80166 +
80167 + pax_open_kernel();
80168 + memset(ptr, 0, mod->core_size_rx);
80169 + pax_close_kernel();
80170 + mod->module_core_rx = ptr;
80171 +
80172 + if (mod->init_size_rx) {
80173 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
80174 + kmemleak_ignore(ptr);
80175 + if (!ptr && mod->init_size_rx) {
80176 + module_free_exec(mod, mod->module_core_rx);
80177 + if (mod->module_init_rw)
80178 + module_free(mod, mod->module_init_rw);
80179 + module_free(mod, mod->module_core_rw);
80180 + return -ENOMEM;
80181 + }
80182 +
80183 + pax_open_kernel();
80184 + memset(ptr, 0, mod->init_size_rx);
80185 + pax_close_kernel();
80186 + mod->module_init_rx = ptr;
80187 + } else
80188 + mod->module_init_rx = NULL;
80189
80190 /* Transfer each section which specifies SHF_ALLOC */
80191 pr_debug("final section addresses:\n");
80192 @@ -2839,16 +2915,45 @@ static int move_module(struct module *mod, struct load_info *info)
80193 if (!(shdr->sh_flags & SHF_ALLOC))
80194 continue;
80195
80196 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
80197 - dest = mod->module_init
80198 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
80199 - else
80200 - dest = mod->module_core + shdr->sh_entsize;
80201 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
80202 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
80203 + dest = mod->module_init_rw
80204 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
80205 + else
80206 + dest = mod->module_init_rx
80207 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
80208 + } else {
80209 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
80210 + dest = mod->module_core_rw + shdr->sh_entsize;
80211 + else
80212 + dest = mod->module_core_rx + shdr->sh_entsize;
80213 + }
80214 +
80215 + if (shdr->sh_type != SHT_NOBITS) {
80216 +
80217 +#ifdef CONFIG_PAX_KERNEXEC
80218 +#ifdef CONFIG_X86_64
80219 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
80220 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
80221 +#endif
80222 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
80223 + pax_open_kernel();
80224 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
80225 + pax_close_kernel();
80226 + } else
80227 +#endif
80228
80229 - if (shdr->sh_type != SHT_NOBITS)
80230 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
80231 + }
80232 /* Update sh_addr to point to copy in image. */
80233 - shdr->sh_addr = (unsigned long)dest;
80234 +
80235 +#ifdef CONFIG_PAX_KERNEXEC
80236 + if (shdr->sh_flags & SHF_EXECINSTR)
80237 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
80238 + else
80239 +#endif
80240 +
80241 + shdr->sh_addr = (unsigned long)dest;
80242 pr_debug("\t0x%lx %s\n",
80243 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
80244 }
80245 @@ -2905,12 +3010,12 @@ static void flush_module_icache(const struct module *mod)
80246 * Do it before processing of module parameters, so the module
80247 * can provide parameter accessor functions of its own.
80248 */
80249 - if (mod->module_init)
80250 - flush_icache_range((unsigned long)mod->module_init,
80251 - (unsigned long)mod->module_init
80252 - + mod->init_size);
80253 - flush_icache_range((unsigned long)mod->module_core,
80254 - (unsigned long)mod->module_core + mod->core_size);
80255 + if (mod->module_init_rx)
80256 + flush_icache_range((unsigned long)mod->module_init_rx,
80257 + (unsigned long)mod->module_init_rx
80258 + + mod->init_size_rx);
80259 + flush_icache_range((unsigned long)mod->module_core_rx,
80260 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
80261
80262 set_fs(old_fs);
80263 }
80264 @@ -2977,8 +3082,10 @@ static int alloc_module_percpu(struct module *mod, struct load_info *info)
80265 static void module_deallocate(struct module *mod, struct load_info *info)
80266 {
80267 percpu_modfree(mod);
80268 - module_free(mod, mod->module_init);
80269 - module_free(mod, mod->module_core);
80270 + module_free_exec(mod, mod->module_init_rx);
80271 + module_free_exec(mod, mod->module_core_rx);
80272 + module_free(mod, mod->module_init_rw);
80273 + module_free(mod, mod->module_core_rw);
80274 }
80275
80276 int __weak module_finalize(const Elf_Ehdr *hdr,
80277 @@ -2991,7 +3098,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
80278 static int post_relocation(struct module *mod, const struct load_info *info)
80279 {
80280 /* Sort exception table now relocations are done. */
80281 + pax_open_kernel();
80282 sort_extable(mod->extable, mod->extable + mod->num_exentries);
80283 + pax_close_kernel();
80284
80285 /* Copy relocated percpu area over. */
80286 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
80287 @@ -3045,16 +3154,16 @@ static int do_init_module(struct module *mod)
80288 MODULE_STATE_COMING, mod);
80289
80290 /* Set RO and NX regions for core */
80291 - set_section_ro_nx(mod->module_core,
80292 - mod->core_text_size,
80293 - mod->core_ro_size,
80294 - mod->core_size);
80295 + set_section_ro_nx(mod->module_core_rx,
80296 + mod->core_size_rx,
80297 + mod->core_size_rx,
80298 + mod->core_size_rx);
80299
80300 /* Set RO and NX regions for init */
80301 - set_section_ro_nx(mod->module_init,
80302 - mod->init_text_size,
80303 - mod->init_ro_size,
80304 - mod->init_size);
80305 + set_section_ro_nx(mod->module_init_rx,
80306 + mod->init_size_rx,
80307 + mod->init_size_rx,
80308 + mod->init_size_rx);
80309
80310 do_mod_ctors(mod);
80311 /* Start the module */
80312 @@ -3116,11 +3225,12 @@ static int do_init_module(struct module *mod)
80313 mod->strtab = mod->core_strtab;
80314 #endif
80315 unset_module_init_ro_nx(mod);
80316 - module_free(mod, mod->module_init);
80317 - mod->module_init = NULL;
80318 - mod->init_size = 0;
80319 - mod->init_ro_size = 0;
80320 - mod->init_text_size = 0;
80321 + module_free(mod, mod->module_init_rw);
80322 + module_free_exec(mod, mod->module_init_rx);
80323 + mod->module_init_rw = NULL;
80324 + mod->module_init_rx = NULL;
80325 + mod->init_size_rw = 0;
80326 + mod->init_size_rx = 0;
80327 mutex_unlock(&module_mutex);
80328 wake_up_all(&module_wq);
80329
80330 @@ -3252,9 +3362,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
80331 if (err)
80332 goto free_unload;
80333
80334 + /* Now copy in args */
80335 + mod->args = strndup_user(uargs, ~0UL >> 1);
80336 + if (IS_ERR(mod->args)) {
80337 + err = PTR_ERR(mod->args);
80338 + goto free_unload;
80339 + }
80340 +
80341 /* Set up MODINFO_ATTR fields */
80342 setup_modinfo(mod, info);
80343
80344 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
80345 + {
80346 + char *p, *p2;
80347 +
80348 + if (strstr(mod->args, "grsec_modharden_netdev")) {
80349 + 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);
80350 + err = -EPERM;
80351 + goto free_modinfo;
80352 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
80353 + p += sizeof("grsec_modharden_normal") - 1;
80354 + p2 = strstr(p, "_");
80355 + if (p2) {
80356 + *p2 = '\0';
80357 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
80358 + *p2 = '_';
80359 + }
80360 + err = -EPERM;
80361 + goto free_modinfo;
80362 + }
80363 + }
80364 +#endif
80365 +
80366 /* Fix up syms, so that st_value is a pointer to location. */
80367 err = simplify_symbols(mod, info);
80368 if (err < 0)
80369 @@ -3270,13 +3409,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
80370
80371 flush_module_icache(mod);
80372
80373 - /* Now copy in args */
80374 - mod->args = strndup_user(uargs, ~0UL >> 1);
80375 - if (IS_ERR(mod->args)) {
80376 - err = PTR_ERR(mod->args);
80377 - goto free_arch_cleanup;
80378 - }
80379 -
80380 dynamic_debug_setup(info->debug, info->num_debug);
80381
80382 /* Finally it's fully formed, ready to start executing. */
80383 @@ -3311,11 +3443,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
80384 ddebug_cleanup:
80385 dynamic_debug_remove(info->debug);
80386 synchronize_sched();
80387 - kfree(mod->args);
80388 - free_arch_cleanup:
80389 module_arch_cleanup(mod);
80390 free_modinfo:
80391 free_modinfo(mod);
80392 + kfree(mod->args);
80393 free_unload:
80394 module_unload_free(mod);
80395 unlink_mod:
80396 @@ -3398,10 +3529,16 @@ static const char *get_ksymbol(struct module *mod,
80397 unsigned long nextval;
80398
80399 /* At worse, next value is at end of module */
80400 - if (within_module_init(addr, mod))
80401 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
80402 + if (within_module_init_rx(addr, mod))
80403 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
80404 + else if (within_module_init_rw(addr, mod))
80405 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
80406 + else if (within_module_core_rx(addr, mod))
80407 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
80408 + else if (within_module_core_rw(addr, mod))
80409 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
80410 else
80411 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
80412 + return NULL;
80413
80414 /* Scan for closest preceding symbol, and next symbol. (ELF
80415 starts real symbols at 1). */
80416 @@ -3654,7 +3791,7 @@ static int m_show(struct seq_file *m, void *p)
80417 return 0;
80418
80419 seq_printf(m, "%s %u",
80420 - mod->name, mod->init_size + mod->core_size);
80421 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
80422 print_unload_info(m, mod);
80423
80424 /* Informative for users. */
80425 @@ -3663,7 +3800,7 @@ static int m_show(struct seq_file *m, void *p)
80426 mod->state == MODULE_STATE_COMING ? "Loading":
80427 "Live");
80428 /* Used by oprofile and other similar tools. */
80429 - seq_printf(m, " 0x%pK", mod->module_core);
80430 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
80431
80432 /* Taints info */
80433 if (mod->taints)
80434 @@ -3699,7 +3836,17 @@ static const struct file_operations proc_modules_operations = {
80435
80436 static int __init proc_modules_init(void)
80437 {
80438 +#ifndef CONFIG_GRKERNSEC_HIDESYM
80439 +#ifdef CONFIG_GRKERNSEC_PROC_USER
80440 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
80441 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80442 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
80443 +#else
80444 proc_create("modules", 0, NULL, &proc_modules_operations);
80445 +#endif
80446 +#else
80447 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
80448 +#endif
80449 return 0;
80450 }
80451 module_init(proc_modules_init);
80452 @@ -3760,14 +3907,14 @@ struct module *__module_address(unsigned long addr)
80453 {
80454 struct module *mod;
80455
80456 - if (addr < module_addr_min || addr > module_addr_max)
80457 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
80458 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
80459 return NULL;
80460
80461 list_for_each_entry_rcu(mod, &modules, list) {
80462 if (mod->state == MODULE_STATE_UNFORMED)
80463 continue;
80464 - if (within_module_core(addr, mod)
80465 - || within_module_init(addr, mod))
80466 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
80467 return mod;
80468 }
80469 return NULL;
80470 @@ -3802,11 +3949,20 @@ bool is_module_text_address(unsigned long addr)
80471 */
80472 struct module *__module_text_address(unsigned long addr)
80473 {
80474 - struct module *mod = __module_address(addr);
80475 + struct module *mod;
80476 +
80477 +#ifdef CONFIG_X86_32
80478 + addr = ktla_ktva(addr);
80479 +#endif
80480 +
80481 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
80482 + return NULL;
80483 +
80484 + mod = __module_address(addr);
80485 +
80486 if (mod) {
80487 /* Make sure it's within the text section. */
80488 - if (!within(addr, mod->module_init, mod->init_text_size)
80489 - && !within(addr, mod->module_core, mod->core_text_size))
80490 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
80491 mod = NULL;
80492 }
80493 return mod;
80494 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
80495 index 7e3443f..b2a1e6b 100644
80496 --- a/kernel/mutex-debug.c
80497 +++ b/kernel/mutex-debug.c
80498 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
80499 }
80500
80501 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
80502 - struct thread_info *ti)
80503 + struct task_struct *task)
80504 {
80505 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
80506
80507 /* Mark the current thread as blocked on the lock: */
80508 - ti->task->blocked_on = waiter;
80509 + task->blocked_on = waiter;
80510 }
80511
80512 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
80513 - struct thread_info *ti)
80514 + struct task_struct *task)
80515 {
80516 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
80517 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
80518 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
80519 - ti->task->blocked_on = NULL;
80520 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
80521 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
80522 + task->blocked_on = NULL;
80523
80524 list_del_init(&waiter->list);
80525 waiter->task = NULL;
80526 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
80527 index 0799fd3..d06ae3b 100644
80528 --- a/kernel/mutex-debug.h
80529 +++ b/kernel/mutex-debug.h
80530 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
80531 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
80532 extern void debug_mutex_add_waiter(struct mutex *lock,
80533 struct mutex_waiter *waiter,
80534 - struct thread_info *ti);
80535 + struct task_struct *task);
80536 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
80537 - struct thread_info *ti);
80538 + struct task_struct *task);
80539 extern void debug_mutex_unlock(struct mutex *lock);
80540 extern void debug_mutex_init(struct mutex *lock, const char *name,
80541 struct lock_class_key *key);
80542 diff --git a/kernel/mutex.c b/kernel/mutex.c
80543 index ad53a66..f1bf8bc 100644
80544 --- a/kernel/mutex.c
80545 +++ b/kernel/mutex.c
80546 @@ -134,7 +134,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
80547 node->locked = 1;
80548 return;
80549 }
80550 - ACCESS_ONCE(prev->next) = node;
80551 + ACCESS_ONCE_RW(prev->next) = node;
80552 smp_wmb();
80553 /* Wait until the lock holder passes the lock down */
80554 while (!ACCESS_ONCE(node->locked))
80555 @@ -155,7 +155,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
80556 while (!(next = ACCESS_ONCE(node->next)))
80557 arch_mutex_cpu_relax();
80558 }
80559 - ACCESS_ONCE(next->locked) = 1;
80560 + ACCESS_ONCE_RW(next->locked) = 1;
80561 smp_wmb();
80562 }
80563
80564 @@ -341,7 +341,7 @@ slowpath:
80565 spin_lock_mutex(&lock->wait_lock, flags);
80566
80567 debug_mutex_lock_common(lock, &waiter);
80568 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
80569 + debug_mutex_add_waiter(lock, &waiter, task);
80570
80571 /* add waiting tasks to the end of the waitqueue (FIFO): */
80572 list_add_tail(&waiter.list, &lock->wait_list);
80573 @@ -371,8 +371,7 @@ slowpath:
80574 * TASK_UNINTERRUPTIBLE case.)
80575 */
80576 if (unlikely(signal_pending_state(state, task))) {
80577 - mutex_remove_waiter(lock, &waiter,
80578 - task_thread_info(task));
80579 + mutex_remove_waiter(lock, &waiter, task);
80580 mutex_release(&lock->dep_map, 1, ip);
80581 spin_unlock_mutex(&lock->wait_lock, flags);
80582
80583 @@ -391,7 +390,7 @@ slowpath:
80584 done:
80585 lock_acquired(&lock->dep_map, ip);
80586 /* got the lock - rejoice! */
80587 - mutex_remove_waiter(lock, &waiter, current_thread_info());
80588 + mutex_remove_waiter(lock, &waiter, task);
80589 mutex_set_owner(lock);
80590
80591 /* set it to 0 if there are no waiters left: */
80592 diff --git a/kernel/notifier.c b/kernel/notifier.c
80593 index 2d5cc4c..d9ea600 100644
80594 --- a/kernel/notifier.c
80595 +++ b/kernel/notifier.c
80596 @@ -5,6 +5,7 @@
80597 #include <linux/rcupdate.h>
80598 #include <linux/vmalloc.h>
80599 #include <linux/reboot.h>
80600 +#include <linux/mm.h>
80601
80602 /*
80603 * Notifier list for kernel code which wants to be called
80604 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
80605 while ((*nl) != NULL) {
80606 if (n->priority > (*nl)->priority)
80607 break;
80608 - nl = &((*nl)->next);
80609 + nl = (struct notifier_block **)&((*nl)->next);
80610 }
80611 - n->next = *nl;
80612 + pax_open_kernel();
80613 + *(const void **)&n->next = *nl;
80614 rcu_assign_pointer(*nl, n);
80615 + pax_close_kernel();
80616 return 0;
80617 }
80618
80619 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
80620 return 0;
80621 if (n->priority > (*nl)->priority)
80622 break;
80623 - nl = &((*nl)->next);
80624 + nl = (struct notifier_block **)&((*nl)->next);
80625 }
80626 - n->next = *nl;
80627 + pax_open_kernel();
80628 + *(const void **)&n->next = *nl;
80629 rcu_assign_pointer(*nl, n);
80630 + pax_close_kernel();
80631 return 0;
80632 }
80633
80634 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
80635 {
80636 while ((*nl) != NULL) {
80637 if ((*nl) == n) {
80638 + pax_open_kernel();
80639 rcu_assign_pointer(*nl, n->next);
80640 + pax_close_kernel();
80641 return 0;
80642 }
80643 - nl = &((*nl)->next);
80644 + nl = (struct notifier_block **)&((*nl)->next);
80645 }
80646 return -ENOENT;
80647 }
80648 diff --git a/kernel/panic.c b/kernel/panic.c
80649 index 167ec09..0dda5f9 100644
80650 --- a/kernel/panic.c
80651 +++ b/kernel/panic.c
80652 @@ -400,7 +400,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
80653 unsigned taint, struct slowpath_args *args)
80654 {
80655 printk(KERN_WARNING "------------[ cut here ]------------\n");
80656 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
80657 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
80658
80659 if (args)
80660 vprintk(args->fmt, args->args);
80661 @@ -453,7 +453,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
80662 */
80663 void __stack_chk_fail(void)
80664 {
80665 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
80666 + dump_stack();
80667 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
80668 __builtin_return_address(0));
80669 }
80670 EXPORT_SYMBOL(__stack_chk_fail);
80671 diff --git a/kernel/pid.c b/kernel/pid.c
80672 index 0db3e79..95b9dc2 100644
80673 --- a/kernel/pid.c
80674 +++ b/kernel/pid.c
80675 @@ -33,6 +33,7 @@
80676 #include <linux/rculist.h>
80677 #include <linux/bootmem.h>
80678 #include <linux/hash.h>
80679 +#include <linux/security.h>
80680 #include <linux/pid_namespace.h>
80681 #include <linux/init_task.h>
80682 #include <linux/syscalls.h>
80683 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
80684
80685 int pid_max = PID_MAX_DEFAULT;
80686
80687 -#define RESERVED_PIDS 300
80688 +#define RESERVED_PIDS 500
80689
80690 int pid_max_min = RESERVED_PIDS + 1;
80691 int pid_max_max = PID_MAX_LIMIT;
80692 @@ -442,10 +443,18 @@ EXPORT_SYMBOL(pid_task);
80693 */
80694 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
80695 {
80696 + struct task_struct *task;
80697 +
80698 rcu_lockdep_assert(rcu_read_lock_held(),
80699 "find_task_by_pid_ns() needs rcu_read_lock()"
80700 " protection");
80701 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
80702 +
80703 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
80704 +
80705 + if (gr_pid_is_chrooted(task))
80706 + return NULL;
80707 +
80708 + return task;
80709 }
80710
80711 struct task_struct *find_task_by_vpid(pid_t vnr)
80712 @@ -453,6 +462,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
80713 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
80714 }
80715
80716 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
80717 +{
80718 + rcu_lockdep_assert(rcu_read_lock_held(),
80719 + "find_task_by_pid_ns() needs rcu_read_lock()"
80720 + " protection");
80721 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
80722 +}
80723 +
80724 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
80725 {
80726 struct pid *pid;
80727 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
80728 index 6917e8e..9909aeb 100644
80729 --- a/kernel/pid_namespace.c
80730 +++ b/kernel/pid_namespace.c
80731 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
80732 void __user *buffer, size_t *lenp, loff_t *ppos)
80733 {
80734 struct pid_namespace *pid_ns = task_active_pid_ns(current);
80735 - struct ctl_table tmp = *table;
80736 + ctl_table_no_const tmp = *table;
80737
80738 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
80739 return -EPERM;
80740 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
80741 index 42670e9..8719c2f 100644
80742 --- a/kernel/posix-cpu-timers.c
80743 +++ b/kernel/posix-cpu-timers.c
80744 @@ -1636,14 +1636,14 @@ struct k_clock clock_posix_cpu = {
80745
80746 static __init int init_posix_cpu_timers(void)
80747 {
80748 - struct k_clock process = {
80749 + static struct k_clock process = {
80750 .clock_getres = process_cpu_clock_getres,
80751 .clock_get = process_cpu_clock_get,
80752 .timer_create = process_cpu_timer_create,
80753 .nsleep = process_cpu_nsleep,
80754 .nsleep_restart = process_cpu_nsleep_restart,
80755 };
80756 - struct k_clock thread = {
80757 + static struct k_clock thread = {
80758 .clock_getres = thread_cpu_clock_getres,
80759 .clock_get = thread_cpu_clock_get,
80760 .timer_create = thread_cpu_timer_create,
80761 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
80762 index 424c2d4..679242f 100644
80763 --- a/kernel/posix-timers.c
80764 +++ b/kernel/posix-timers.c
80765 @@ -43,6 +43,7 @@
80766 #include <linux/hash.h>
80767 #include <linux/posix-clock.h>
80768 #include <linux/posix-timers.h>
80769 +#include <linux/grsecurity.h>
80770 #include <linux/syscalls.h>
80771 #include <linux/wait.h>
80772 #include <linux/workqueue.h>
80773 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
80774 * which we beg off on and pass to do_sys_settimeofday().
80775 */
80776
80777 -static struct k_clock posix_clocks[MAX_CLOCKS];
80778 +static struct k_clock *posix_clocks[MAX_CLOCKS];
80779
80780 /*
80781 * These ones are defined below.
80782 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
80783 */
80784 static __init int init_posix_timers(void)
80785 {
80786 - struct k_clock clock_realtime = {
80787 + static struct k_clock clock_realtime = {
80788 .clock_getres = hrtimer_get_res,
80789 .clock_get = posix_clock_realtime_get,
80790 .clock_set = posix_clock_realtime_set,
80791 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
80792 .timer_get = common_timer_get,
80793 .timer_del = common_timer_del,
80794 };
80795 - struct k_clock clock_monotonic = {
80796 + static struct k_clock clock_monotonic = {
80797 .clock_getres = hrtimer_get_res,
80798 .clock_get = posix_ktime_get_ts,
80799 .nsleep = common_nsleep,
80800 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
80801 .timer_get = common_timer_get,
80802 .timer_del = common_timer_del,
80803 };
80804 - struct k_clock clock_monotonic_raw = {
80805 + static struct k_clock clock_monotonic_raw = {
80806 .clock_getres = hrtimer_get_res,
80807 .clock_get = posix_get_monotonic_raw,
80808 };
80809 - struct k_clock clock_realtime_coarse = {
80810 + static struct k_clock clock_realtime_coarse = {
80811 .clock_getres = posix_get_coarse_res,
80812 .clock_get = posix_get_realtime_coarse,
80813 };
80814 - struct k_clock clock_monotonic_coarse = {
80815 + static struct k_clock clock_monotonic_coarse = {
80816 .clock_getres = posix_get_coarse_res,
80817 .clock_get = posix_get_monotonic_coarse,
80818 };
80819 - struct k_clock clock_tai = {
80820 + static struct k_clock clock_tai = {
80821 .clock_getres = hrtimer_get_res,
80822 .clock_get = posix_get_tai,
80823 .nsleep = common_nsleep,
80824 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
80825 .timer_get = common_timer_get,
80826 .timer_del = common_timer_del,
80827 };
80828 - struct k_clock clock_boottime = {
80829 + static struct k_clock clock_boottime = {
80830 .clock_getres = hrtimer_get_res,
80831 .clock_get = posix_get_boottime,
80832 .nsleep = common_nsleep,
80833 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
80834 return;
80835 }
80836
80837 - posix_clocks[clock_id] = *new_clock;
80838 + posix_clocks[clock_id] = new_clock;
80839 }
80840 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
80841
80842 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
80843 return (id & CLOCKFD_MASK) == CLOCKFD ?
80844 &clock_posix_dynamic : &clock_posix_cpu;
80845
80846 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
80847 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
80848 return NULL;
80849 - return &posix_clocks[id];
80850 + return posix_clocks[id];
80851 }
80852
80853 static int common_timer_create(struct k_itimer *new_timer)
80854 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
80855 struct k_clock *kc = clockid_to_kclock(which_clock);
80856 struct k_itimer *new_timer;
80857 int error, new_timer_id;
80858 - sigevent_t event;
80859 + sigevent_t event = { };
80860 int it_id_set = IT_ID_NOT_SET;
80861
80862 if (!kc)
80863 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
80864 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
80865 return -EFAULT;
80866
80867 + /* only the CLOCK_REALTIME clock can be set, all other clocks
80868 + have their clock_set fptr set to a nosettime dummy function
80869 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
80870 + call common_clock_set, which calls do_sys_settimeofday, which
80871 + we hook
80872 + */
80873 +
80874 return kc->clock_set(which_clock, &new_tp);
80875 }
80876
80877 diff --git a/kernel/power/process.c b/kernel/power/process.c
80878 index 98088e0..aaf95c0 100644
80879 --- a/kernel/power/process.c
80880 +++ b/kernel/power/process.c
80881 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
80882 u64 elapsed_csecs64;
80883 unsigned int elapsed_csecs;
80884 bool wakeup = false;
80885 + bool timedout = false;
80886
80887 do_gettimeofday(&start);
80888
80889 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
80890
80891 while (true) {
80892 todo = 0;
80893 + if (time_after(jiffies, end_time))
80894 + timedout = true;
80895 read_lock(&tasklist_lock);
80896 do_each_thread(g, p) {
80897 if (p == current || !freeze_task(p))
80898 continue;
80899
80900 - if (!freezer_should_skip(p))
80901 + if (!freezer_should_skip(p)) {
80902 todo++;
80903 + if (timedout) {
80904 + printk(KERN_ERR "Task refusing to freeze:\n");
80905 + sched_show_task(p);
80906 + }
80907 + }
80908 } while_each_thread(g, p);
80909 read_unlock(&tasklist_lock);
80910
80911 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
80912 todo += wq_busy;
80913 }
80914
80915 - if (!todo || time_after(jiffies, end_time))
80916 + if (!todo || timedout)
80917 break;
80918
80919 if (pm_wakeup_pending()) {
80920 diff --git a/kernel/printk.c b/kernel/printk.c
80921 index d37d45c..ab918b3 100644
80922 --- a/kernel/printk.c
80923 +++ b/kernel/printk.c
80924 @@ -390,6 +390,11 @@ static int check_syslog_permissions(int type, bool from_file)
80925 if (from_file && type != SYSLOG_ACTION_OPEN)
80926 return 0;
80927
80928 +#ifdef CONFIG_GRKERNSEC_DMESG
80929 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
80930 + return -EPERM;
80931 +#endif
80932 +
80933 if (syslog_action_restricted(type)) {
80934 if (capable(CAP_SYSLOG))
80935 return 0;
80936 diff --git a/kernel/profile.c b/kernel/profile.c
80937 index 0bf4007..6234708 100644
80938 --- a/kernel/profile.c
80939 +++ b/kernel/profile.c
80940 @@ -37,7 +37,7 @@ struct profile_hit {
80941 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
80942 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
80943
80944 -static atomic_t *prof_buffer;
80945 +static atomic_unchecked_t *prof_buffer;
80946 static unsigned long prof_len, prof_shift;
80947
80948 int prof_on __read_mostly;
80949 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
80950 hits[i].pc = 0;
80951 continue;
80952 }
80953 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
80954 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
80955 hits[i].hits = hits[i].pc = 0;
80956 }
80957 }
80958 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
80959 * Add the current hit(s) and flush the write-queue out
80960 * to the global buffer:
80961 */
80962 - atomic_add(nr_hits, &prof_buffer[pc]);
80963 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
80964 for (i = 0; i < NR_PROFILE_HIT; ++i) {
80965 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
80966 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
80967 hits[i].pc = hits[i].hits = 0;
80968 }
80969 out:
80970 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
80971 {
80972 unsigned long pc;
80973 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
80974 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
80975 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
80976 }
80977 #endif /* !CONFIG_SMP */
80978
80979 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
80980 return -EFAULT;
80981 buf++; p++; count--; read++;
80982 }
80983 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
80984 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
80985 if (copy_to_user(buf, (void *)pnt, count))
80986 return -EFAULT;
80987 read += count;
80988 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
80989 }
80990 #endif
80991 profile_discard_flip_buffers();
80992 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
80993 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
80994 return count;
80995 }
80996
80997 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
80998 index 335a7ae..3bbbceb 100644
80999 --- a/kernel/ptrace.c
81000 +++ b/kernel/ptrace.c
81001 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
81002 if (seize)
81003 flags |= PT_SEIZED;
81004 rcu_read_lock();
81005 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
81006 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
81007 flags |= PT_PTRACE_CAP;
81008 rcu_read_unlock();
81009 task->ptrace = flags;
81010 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
81011 break;
81012 return -EIO;
81013 }
81014 - if (copy_to_user(dst, buf, retval))
81015 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
81016 return -EFAULT;
81017 copied += retval;
81018 src += retval;
81019 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
81020 bool seized = child->ptrace & PT_SEIZED;
81021 int ret = -EIO;
81022 siginfo_t siginfo, *si;
81023 - void __user *datavp = (void __user *) data;
81024 + void __user *datavp = (__force void __user *) data;
81025 unsigned long __user *datalp = datavp;
81026 unsigned long flags;
81027
81028 @@ -1011,14 +1011,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
81029 goto out;
81030 }
81031
81032 + if (gr_handle_ptrace(child, request)) {
81033 + ret = -EPERM;
81034 + goto out_put_task_struct;
81035 + }
81036 +
81037 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
81038 ret = ptrace_attach(child, request, addr, data);
81039 /*
81040 * Some architectures need to do book-keeping after
81041 * a ptrace attach.
81042 */
81043 - if (!ret)
81044 + if (!ret) {
81045 arch_ptrace_attach(child);
81046 + gr_audit_ptrace(child);
81047 + }
81048 goto out_put_task_struct;
81049 }
81050
81051 @@ -1046,7 +1053,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
81052 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
81053 if (copied != sizeof(tmp))
81054 return -EIO;
81055 - return put_user(tmp, (unsigned long __user *)data);
81056 + return put_user(tmp, (__force unsigned long __user *)data);
81057 }
81058
81059 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
81060 @@ -1140,7 +1147,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
81061 }
81062
81063 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
81064 - compat_long_t addr, compat_long_t data)
81065 + compat_ulong_t addr, compat_ulong_t data)
81066 {
81067 struct task_struct *child;
81068 long ret;
81069 @@ -1156,14 +1163,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
81070 goto out;
81071 }
81072
81073 + if (gr_handle_ptrace(child, request)) {
81074 + ret = -EPERM;
81075 + goto out_put_task_struct;
81076 + }
81077 +
81078 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
81079 ret = ptrace_attach(child, request, addr, data);
81080 /*
81081 * Some architectures need to do book-keeping after
81082 * a ptrace attach.
81083 */
81084 - if (!ret)
81085 + if (!ret) {
81086 arch_ptrace_attach(child);
81087 + gr_audit_ptrace(child);
81088 + }
81089 goto out_put_task_struct;
81090 }
81091
81092 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
81093 index 48ab703..07561d4 100644
81094 --- a/kernel/rcupdate.c
81095 +++ b/kernel/rcupdate.c
81096 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
81097 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
81098 */
81099 if (till_stall_check < 3) {
81100 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
81101 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
81102 till_stall_check = 3;
81103 } else if (till_stall_check > 300) {
81104 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
81105 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
81106 till_stall_check = 300;
81107 }
81108 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
81109 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
81110 index a0714a5..2ab5e34 100644
81111 --- a/kernel/rcutiny.c
81112 +++ b/kernel/rcutiny.c
81113 @@ -46,7 +46,7 @@
81114 struct rcu_ctrlblk;
81115 static void invoke_rcu_callbacks(void);
81116 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
81117 -static void rcu_process_callbacks(struct softirq_action *unused);
81118 +static void rcu_process_callbacks(void);
81119 static void __call_rcu(struct rcu_head *head,
81120 void (*func)(struct rcu_head *rcu),
81121 struct rcu_ctrlblk *rcp);
81122 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
81123 rcu_is_callbacks_kthread()));
81124 }
81125
81126 -static void rcu_process_callbacks(struct softirq_action *unused)
81127 +static void rcu_process_callbacks(void)
81128 {
81129 __rcu_process_callbacks(&rcu_sched_ctrlblk);
81130 __rcu_process_callbacks(&rcu_bh_ctrlblk);
81131 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
81132 index 8a23300..4255818 100644
81133 --- a/kernel/rcutiny_plugin.h
81134 +++ b/kernel/rcutiny_plugin.h
81135 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
81136 have_rcu_kthread_work = morework;
81137 local_irq_restore(flags);
81138 if (work)
81139 - rcu_process_callbacks(NULL);
81140 + rcu_process_callbacks();
81141 schedule_timeout_interruptible(1); /* Leave CPU for others. */
81142 }
81143
81144 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
81145 index e1f3a8c..42c94a2 100644
81146 --- a/kernel/rcutorture.c
81147 +++ b/kernel/rcutorture.c
81148 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
81149 { 0 };
81150 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
81151 { 0 };
81152 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
81153 -static atomic_t n_rcu_torture_alloc;
81154 -static atomic_t n_rcu_torture_alloc_fail;
81155 -static atomic_t n_rcu_torture_free;
81156 -static atomic_t n_rcu_torture_mberror;
81157 -static atomic_t n_rcu_torture_error;
81158 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
81159 +static atomic_unchecked_t n_rcu_torture_alloc;
81160 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
81161 +static atomic_unchecked_t n_rcu_torture_free;
81162 +static atomic_unchecked_t n_rcu_torture_mberror;
81163 +static atomic_unchecked_t n_rcu_torture_error;
81164 static long n_rcu_torture_barrier_error;
81165 static long n_rcu_torture_boost_ktrerror;
81166 static long n_rcu_torture_boost_rterror;
81167 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
81168
81169 spin_lock_bh(&rcu_torture_lock);
81170 if (list_empty(&rcu_torture_freelist)) {
81171 - atomic_inc(&n_rcu_torture_alloc_fail);
81172 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
81173 spin_unlock_bh(&rcu_torture_lock);
81174 return NULL;
81175 }
81176 - atomic_inc(&n_rcu_torture_alloc);
81177 + atomic_inc_unchecked(&n_rcu_torture_alloc);
81178 p = rcu_torture_freelist.next;
81179 list_del_init(p);
81180 spin_unlock_bh(&rcu_torture_lock);
81181 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
81182 static void
81183 rcu_torture_free(struct rcu_torture *p)
81184 {
81185 - atomic_inc(&n_rcu_torture_free);
81186 + atomic_inc_unchecked(&n_rcu_torture_free);
81187 spin_lock_bh(&rcu_torture_lock);
81188 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
81189 spin_unlock_bh(&rcu_torture_lock);
81190 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
81191 i = rp->rtort_pipe_count;
81192 if (i > RCU_TORTURE_PIPE_LEN)
81193 i = RCU_TORTURE_PIPE_LEN;
81194 - atomic_inc(&rcu_torture_wcount[i]);
81195 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
81196 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
81197 rp->rtort_mbtest = 0;
81198 rcu_torture_free(rp);
81199 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
81200 i = rp->rtort_pipe_count;
81201 if (i > RCU_TORTURE_PIPE_LEN)
81202 i = RCU_TORTURE_PIPE_LEN;
81203 - atomic_inc(&rcu_torture_wcount[i]);
81204 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
81205 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
81206 rp->rtort_mbtest = 0;
81207 list_del(&rp->rtort_free);
81208 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
81209 i = old_rp->rtort_pipe_count;
81210 if (i > RCU_TORTURE_PIPE_LEN)
81211 i = RCU_TORTURE_PIPE_LEN;
81212 - atomic_inc(&rcu_torture_wcount[i]);
81213 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
81214 old_rp->rtort_pipe_count++;
81215 cur_ops->deferred_free(old_rp);
81216 }
81217 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
81218 return;
81219 }
81220 if (p->rtort_mbtest == 0)
81221 - atomic_inc(&n_rcu_torture_mberror);
81222 + atomic_inc_unchecked(&n_rcu_torture_mberror);
81223 spin_lock(&rand_lock);
81224 cur_ops->read_delay(&rand);
81225 n_rcu_torture_timers++;
81226 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
81227 continue;
81228 }
81229 if (p->rtort_mbtest == 0)
81230 - atomic_inc(&n_rcu_torture_mberror);
81231 + atomic_inc_unchecked(&n_rcu_torture_mberror);
81232 cur_ops->read_delay(&rand);
81233 preempt_disable();
81234 pipe_count = p->rtort_pipe_count;
81235 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
81236 rcu_torture_current,
81237 rcu_torture_current_version,
81238 list_empty(&rcu_torture_freelist),
81239 - atomic_read(&n_rcu_torture_alloc),
81240 - atomic_read(&n_rcu_torture_alloc_fail),
81241 - atomic_read(&n_rcu_torture_free));
81242 + atomic_read_unchecked(&n_rcu_torture_alloc),
81243 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
81244 + atomic_read_unchecked(&n_rcu_torture_free));
81245 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
81246 - atomic_read(&n_rcu_torture_mberror),
81247 + atomic_read_unchecked(&n_rcu_torture_mberror),
81248 n_rcu_torture_boost_ktrerror,
81249 n_rcu_torture_boost_rterror);
81250 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
81251 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
81252 n_barrier_attempts,
81253 n_rcu_torture_barrier_error);
81254 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
81255 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
81256 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
81257 n_rcu_torture_barrier_error != 0 ||
81258 n_rcu_torture_boost_ktrerror != 0 ||
81259 n_rcu_torture_boost_rterror != 0 ||
81260 n_rcu_torture_boost_failure != 0 ||
81261 i > 1) {
81262 cnt += sprintf(&page[cnt], "!!! ");
81263 - atomic_inc(&n_rcu_torture_error);
81264 + atomic_inc_unchecked(&n_rcu_torture_error);
81265 WARN_ON_ONCE(1);
81266 }
81267 cnt += sprintf(&page[cnt], "Reader Pipe: ");
81268 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
81269 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
81270 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
81271 cnt += sprintf(&page[cnt], " %d",
81272 - atomic_read(&rcu_torture_wcount[i]));
81273 + atomic_read_unchecked(&rcu_torture_wcount[i]));
81274 }
81275 cnt += sprintf(&page[cnt], "\n");
81276 if (cur_ops->stats)
81277 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
81278
81279 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
81280
81281 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
81282 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
81283 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
81284 else if (n_online_successes != n_online_attempts ||
81285 n_offline_successes != n_offline_attempts)
81286 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
81287
81288 rcu_torture_current = NULL;
81289 rcu_torture_current_version = 0;
81290 - atomic_set(&n_rcu_torture_alloc, 0);
81291 - atomic_set(&n_rcu_torture_alloc_fail, 0);
81292 - atomic_set(&n_rcu_torture_free, 0);
81293 - atomic_set(&n_rcu_torture_mberror, 0);
81294 - atomic_set(&n_rcu_torture_error, 0);
81295 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
81296 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
81297 + atomic_set_unchecked(&n_rcu_torture_free, 0);
81298 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
81299 + atomic_set_unchecked(&n_rcu_torture_error, 0);
81300 n_rcu_torture_barrier_error = 0;
81301 n_rcu_torture_boost_ktrerror = 0;
81302 n_rcu_torture_boost_rterror = 0;
81303 n_rcu_torture_boost_failure = 0;
81304 n_rcu_torture_boosts = 0;
81305 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
81306 - atomic_set(&rcu_torture_wcount[i], 0);
81307 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
81308 for_each_possible_cpu(cpu) {
81309 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
81310 per_cpu(rcu_torture_count, cpu)[i] = 0;
81311 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
81312 index 3538001..e379e0b 100644
81313 --- a/kernel/rcutree.c
81314 +++ b/kernel/rcutree.c
81315 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
81316 rcu_prepare_for_idle(smp_processor_id());
81317 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
81318 smp_mb__before_atomic_inc(); /* See above. */
81319 - atomic_inc(&rdtp->dynticks);
81320 + atomic_inc_unchecked(&rdtp->dynticks);
81321 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
81322 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
81323 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
81324
81325 /*
81326 * It is illegal to enter an extended quiescent state while
81327 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
81328 int user)
81329 {
81330 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
81331 - atomic_inc(&rdtp->dynticks);
81332 + atomic_inc_unchecked(&rdtp->dynticks);
81333 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
81334 smp_mb__after_atomic_inc(); /* See above. */
81335 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
81336 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
81337 rcu_cleanup_after_idle(smp_processor_id());
81338 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
81339 if (!user && !is_idle_task(current)) {
81340 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
81341 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
81342
81343 if (rdtp->dynticks_nmi_nesting == 0 &&
81344 - (atomic_read(&rdtp->dynticks) & 0x1))
81345 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
81346 return;
81347 rdtp->dynticks_nmi_nesting++;
81348 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
81349 - atomic_inc(&rdtp->dynticks);
81350 + atomic_inc_unchecked(&rdtp->dynticks);
81351 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
81352 smp_mb__after_atomic_inc(); /* See above. */
81353 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
81354 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
81355 }
81356
81357 /**
81358 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
81359 return;
81360 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
81361 smp_mb__before_atomic_inc(); /* See above. */
81362 - atomic_inc(&rdtp->dynticks);
81363 + atomic_inc_unchecked(&rdtp->dynticks);
81364 smp_mb__after_atomic_inc(); /* Force delay to next write. */
81365 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
81366 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
81367 }
81368
81369 /**
81370 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
81371 int ret;
81372
81373 preempt_disable();
81374 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
81375 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
81376 preempt_enable();
81377 return ret;
81378 }
81379 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
81380 */
81381 static int dyntick_save_progress_counter(struct rcu_data *rdp)
81382 {
81383 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
81384 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
81385 return (rdp->dynticks_snap & 0x1) == 0;
81386 }
81387
81388 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
81389 unsigned int curr;
81390 unsigned int snap;
81391
81392 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
81393 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
81394 snap = (unsigned int)rdp->dynticks_snap;
81395
81396 /*
81397 @@ -1440,9 +1440,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
81398 rdp = this_cpu_ptr(rsp->rda);
81399 rcu_preempt_check_blocked_tasks(rnp);
81400 rnp->qsmask = rnp->qsmaskinit;
81401 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
81402 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
81403 WARN_ON_ONCE(rnp->completed != rsp->completed);
81404 - ACCESS_ONCE(rnp->completed) = rsp->completed;
81405 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
81406 if (rnp == rdp->mynode)
81407 rcu_start_gp_per_cpu(rsp, rnp, rdp);
81408 rcu_preempt_boost_start_gp(rnp);
81409 @@ -1524,7 +1524,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
81410 */
81411 rcu_for_each_node_breadth_first(rsp, rnp) {
81412 raw_spin_lock_irq(&rnp->lock);
81413 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
81414 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
81415 rdp = this_cpu_ptr(rsp->rda);
81416 if (rnp == rdp->mynode)
81417 __rcu_process_gp_end(rsp, rnp, rdp);
81418 @@ -1855,7 +1855,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
81419 rsp->qlen += rdp->qlen;
81420 rdp->n_cbs_orphaned += rdp->qlen;
81421 rdp->qlen_lazy = 0;
81422 - ACCESS_ONCE(rdp->qlen) = 0;
81423 + ACCESS_ONCE_RW(rdp->qlen) = 0;
81424 }
81425
81426 /*
81427 @@ -2101,7 +2101,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
81428 }
81429 smp_mb(); /* List handling before counting for rcu_barrier(). */
81430 rdp->qlen_lazy -= count_lazy;
81431 - ACCESS_ONCE(rdp->qlen) -= count;
81432 + ACCESS_ONCE_RW(rdp->qlen) -= count;
81433 rdp->n_cbs_invoked += count;
81434
81435 /* Reinstate batch limit if we have worked down the excess. */
81436 @@ -2295,7 +2295,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
81437 /*
81438 * Do RCU core processing for the current CPU.
81439 */
81440 -static void rcu_process_callbacks(struct softirq_action *unused)
81441 +static void rcu_process_callbacks(void)
81442 {
81443 struct rcu_state *rsp;
81444
81445 @@ -2419,7 +2419,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
81446 local_irq_restore(flags);
81447 return;
81448 }
81449 - ACCESS_ONCE(rdp->qlen)++;
81450 + ACCESS_ONCE_RW(rdp->qlen)++;
81451 if (lazy)
81452 rdp->qlen_lazy++;
81453 else
81454 @@ -2628,11 +2628,11 @@ void synchronize_sched_expedited(void)
81455 * counter wrap on a 32-bit system. Quite a few more CPUs would of
81456 * course be required on a 64-bit system.
81457 */
81458 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
81459 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
81460 (ulong)atomic_long_read(&rsp->expedited_done) +
81461 ULONG_MAX / 8)) {
81462 synchronize_sched();
81463 - atomic_long_inc(&rsp->expedited_wrap);
81464 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
81465 return;
81466 }
81467
81468 @@ -2640,7 +2640,7 @@ void synchronize_sched_expedited(void)
81469 * Take a ticket. Note that atomic_inc_return() implies a
81470 * full memory barrier.
81471 */
81472 - snap = atomic_long_inc_return(&rsp->expedited_start);
81473 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
81474 firstsnap = snap;
81475 get_online_cpus();
81476 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
81477 @@ -2653,14 +2653,14 @@ void synchronize_sched_expedited(void)
81478 synchronize_sched_expedited_cpu_stop,
81479 NULL) == -EAGAIN) {
81480 put_online_cpus();
81481 - atomic_long_inc(&rsp->expedited_tryfail);
81482 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
81483
81484 /* Check to see if someone else did our work for us. */
81485 s = atomic_long_read(&rsp->expedited_done);
81486 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
81487 /* ensure test happens before caller kfree */
81488 smp_mb__before_atomic_inc(); /* ^^^ */
81489 - atomic_long_inc(&rsp->expedited_workdone1);
81490 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
81491 return;
81492 }
81493
81494 @@ -2669,7 +2669,7 @@ void synchronize_sched_expedited(void)
81495 udelay(trycount * num_online_cpus());
81496 } else {
81497 wait_rcu_gp(call_rcu_sched);
81498 - atomic_long_inc(&rsp->expedited_normal);
81499 + atomic_long_inc_unchecked(&rsp->expedited_normal);
81500 return;
81501 }
81502
81503 @@ -2678,7 +2678,7 @@ void synchronize_sched_expedited(void)
81504 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
81505 /* ensure test happens before caller kfree */
81506 smp_mb__before_atomic_inc(); /* ^^^ */
81507 - atomic_long_inc(&rsp->expedited_workdone2);
81508 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
81509 return;
81510 }
81511
81512 @@ -2690,10 +2690,10 @@ void synchronize_sched_expedited(void)
81513 * period works for us.
81514 */
81515 get_online_cpus();
81516 - snap = atomic_long_read(&rsp->expedited_start);
81517 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
81518 smp_mb(); /* ensure read is before try_stop_cpus(). */
81519 }
81520 - atomic_long_inc(&rsp->expedited_stoppedcpus);
81521 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
81522
81523 /*
81524 * Everyone up to our most recent fetch is covered by our grace
81525 @@ -2702,16 +2702,16 @@ void synchronize_sched_expedited(void)
81526 * than we did already did their update.
81527 */
81528 do {
81529 - atomic_long_inc(&rsp->expedited_done_tries);
81530 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
81531 s = atomic_long_read(&rsp->expedited_done);
81532 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
81533 /* ensure test happens before caller kfree */
81534 smp_mb__before_atomic_inc(); /* ^^^ */
81535 - atomic_long_inc(&rsp->expedited_done_lost);
81536 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
81537 break;
81538 }
81539 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
81540 - atomic_long_inc(&rsp->expedited_done_exit);
81541 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
81542
81543 put_online_cpus();
81544 }
81545 @@ -2893,7 +2893,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
81546 * ACCESS_ONCE() to prevent the compiler from speculating
81547 * the increment to precede the early-exit check.
81548 */
81549 - ACCESS_ONCE(rsp->n_barrier_done)++;
81550 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
81551 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
81552 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
81553 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
81554 @@ -2943,7 +2943,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
81555
81556 /* Increment ->n_barrier_done to prevent duplicate work. */
81557 smp_mb(); /* Keep increment after above mechanism. */
81558 - ACCESS_ONCE(rsp->n_barrier_done)++;
81559 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
81560 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
81561 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
81562 smp_mb(); /* Keep increment before caller's subsequent code. */
81563 @@ -2988,10 +2988,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
81564 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
81565 init_callback_list(rdp);
81566 rdp->qlen_lazy = 0;
81567 - ACCESS_ONCE(rdp->qlen) = 0;
81568 + ACCESS_ONCE_RW(rdp->qlen) = 0;
81569 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
81570 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
81571 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
81572 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
81573 rdp->cpu = cpu;
81574 rdp->rsp = rsp;
81575 rcu_boot_init_nocb_percpu_data(rdp);
81576 @@ -3024,8 +3024,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
81577 rdp->blimit = blimit;
81578 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
81579 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
81580 - atomic_set(&rdp->dynticks->dynticks,
81581 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
81582 + atomic_set_unchecked(&rdp->dynticks->dynticks,
81583 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
81584 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
81585
81586 /* Add CPU to rcu_node bitmasks. */
81587 @@ -3120,7 +3120,7 @@ static int __init rcu_spawn_gp_kthread(void)
81588 struct task_struct *t;
81589
81590 for_each_rcu_flavor(rsp) {
81591 - t = kthread_run(rcu_gp_kthread, rsp, rsp->name);
81592 + t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
81593 BUG_ON(IS_ERR(t));
81594 rnp = rcu_get_root(rsp);
81595 raw_spin_lock_irqsave(&rnp->lock, flags);
81596 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
81597 index 4df5034..5ee93f2 100644
81598 --- a/kernel/rcutree.h
81599 +++ b/kernel/rcutree.h
81600 @@ -87,7 +87,7 @@ struct rcu_dynticks {
81601 long long dynticks_nesting; /* Track irq/process nesting level. */
81602 /* Process level is worth LLONG_MAX/2. */
81603 int dynticks_nmi_nesting; /* Track NMI nesting level. */
81604 - atomic_t dynticks; /* Even value for idle, else odd. */
81605 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
81606 #ifdef CONFIG_RCU_FAST_NO_HZ
81607 bool all_lazy; /* Are all CPU's CBs lazy? */
81608 unsigned long nonlazy_posted;
81609 @@ -414,17 +414,17 @@ struct rcu_state {
81610 /* _rcu_barrier(). */
81611 /* End of fields guarded by barrier_mutex. */
81612
81613 - atomic_long_t expedited_start; /* Starting ticket. */
81614 - atomic_long_t expedited_done; /* Done ticket. */
81615 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
81616 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
81617 - atomic_long_t expedited_workdone1; /* # done by others #1. */
81618 - atomic_long_t expedited_workdone2; /* # done by others #2. */
81619 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
81620 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
81621 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
81622 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
81623 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
81624 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
81625 + atomic_long_t expedited_done; /* Done ticket. */
81626 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
81627 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
81628 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
81629 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
81630 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
81631 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
81632 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
81633 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
81634 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
81635
81636 unsigned long jiffies_force_qs; /* Time at which to invoke */
81637 /* force_quiescent_state(). */
81638 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
81639 index 3db5a37..b395fb35 100644
81640 --- a/kernel/rcutree_plugin.h
81641 +++ b/kernel/rcutree_plugin.h
81642 @@ -903,7 +903,7 @@ void synchronize_rcu_expedited(void)
81643
81644 /* Clean up and exit. */
81645 smp_mb(); /* ensure expedited GP seen before counter increment. */
81646 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
81647 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
81648 unlock_mb_ret:
81649 mutex_unlock(&sync_rcu_preempt_exp_mutex);
81650 mb_ret:
81651 @@ -1451,7 +1451,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
81652 free_cpumask_var(cm);
81653 }
81654
81655 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
81656 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
81657 .store = &rcu_cpu_kthread_task,
81658 .thread_should_run = rcu_cpu_kthread_should_run,
81659 .thread_fn = rcu_cpu_kthread,
81660 @@ -1916,7 +1916,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
81661 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
81662 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
81663 cpu, ticks_value, ticks_title,
81664 - atomic_read(&rdtp->dynticks) & 0xfff,
81665 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
81666 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
81667 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
81668 fast_no_hz);
81669 @@ -2079,7 +2079,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
81670
81671 /* Enqueue the callback on the nocb list and update counts. */
81672 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
81673 - ACCESS_ONCE(*old_rhpp) = rhp;
81674 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
81675 atomic_long_add(rhcount, &rdp->nocb_q_count);
81676 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
81677
81678 @@ -2219,12 +2219,12 @@ static int rcu_nocb_kthread(void *arg)
81679 * Extract queued callbacks, update counts, and wait
81680 * for a grace period to elapse.
81681 */
81682 - ACCESS_ONCE(rdp->nocb_head) = NULL;
81683 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
81684 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
81685 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
81686 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
81687 - ACCESS_ONCE(rdp->nocb_p_count) += c;
81688 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
81689 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
81690 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
81691 rcu_nocb_wait_gp(rdp);
81692
81693 /* Each pass through the following loop invokes a callback. */
81694 @@ -2246,8 +2246,8 @@ static int rcu_nocb_kthread(void *arg)
81695 list = next;
81696 }
81697 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
81698 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
81699 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
81700 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
81701 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
81702 rdp->n_nocbs_invoked += c;
81703 }
81704 return 0;
81705 @@ -2274,7 +2274,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
81706 t = kthread_run(rcu_nocb_kthread, rdp,
81707 "rcuo%c/%d", rsp->abbr, cpu);
81708 BUG_ON(IS_ERR(t));
81709 - ACCESS_ONCE(rdp->nocb_kthread) = t;
81710 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
81711 }
81712 }
81713
81714 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
81715 index cf6c174..a8f4b50 100644
81716 --- a/kernel/rcutree_trace.c
81717 +++ b/kernel/rcutree_trace.c
81718 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
81719 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
81720 rdp->passed_quiesce, rdp->qs_pending);
81721 seq_printf(m, " dt=%d/%llx/%d df=%lu",
81722 - atomic_read(&rdp->dynticks->dynticks),
81723 + atomic_read_unchecked(&rdp->dynticks->dynticks),
81724 rdp->dynticks->dynticks_nesting,
81725 rdp->dynticks->dynticks_nmi_nesting,
81726 rdp->dynticks_fqs);
81727 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
81728 struct rcu_state *rsp = (struct rcu_state *)m->private;
81729
81730 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",
81731 - atomic_long_read(&rsp->expedited_start),
81732 + atomic_long_read_unchecked(&rsp->expedited_start),
81733 atomic_long_read(&rsp->expedited_done),
81734 - atomic_long_read(&rsp->expedited_wrap),
81735 - atomic_long_read(&rsp->expedited_tryfail),
81736 - atomic_long_read(&rsp->expedited_workdone1),
81737 - atomic_long_read(&rsp->expedited_workdone2),
81738 - atomic_long_read(&rsp->expedited_normal),
81739 - atomic_long_read(&rsp->expedited_stoppedcpus),
81740 - atomic_long_read(&rsp->expedited_done_tries),
81741 - atomic_long_read(&rsp->expedited_done_lost),
81742 - atomic_long_read(&rsp->expedited_done_exit));
81743 + atomic_long_read_unchecked(&rsp->expedited_wrap),
81744 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
81745 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
81746 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
81747 + atomic_long_read_unchecked(&rsp->expedited_normal),
81748 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
81749 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
81750 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
81751 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
81752 return 0;
81753 }
81754
81755 diff --git a/kernel/resource.c b/kernel/resource.c
81756 index d738698..5f8e60a 100644
81757 --- a/kernel/resource.c
81758 +++ b/kernel/resource.c
81759 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
81760
81761 static int __init ioresources_init(void)
81762 {
81763 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
81764 +#ifdef CONFIG_GRKERNSEC_PROC_USER
81765 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
81766 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
81767 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81768 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
81769 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
81770 +#endif
81771 +#else
81772 proc_create("ioports", 0, NULL, &proc_ioports_operations);
81773 proc_create("iomem", 0, NULL, &proc_iomem_operations);
81774 +#endif
81775 return 0;
81776 }
81777 __initcall(ioresources_init);
81778 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
81779 index 1d96dd0..994ff19 100644
81780 --- a/kernel/rtmutex-tester.c
81781 +++ b/kernel/rtmutex-tester.c
81782 @@ -22,7 +22,7 @@
81783 #define MAX_RT_TEST_MUTEXES 8
81784
81785 static spinlock_t rttest_lock;
81786 -static atomic_t rttest_event;
81787 +static atomic_unchecked_t rttest_event;
81788
81789 struct test_thread_data {
81790 int opcode;
81791 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
81792
81793 case RTTEST_LOCKCONT:
81794 td->mutexes[td->opdata] = 1;
81795 - td->event = atomic_add_return(1, &rttest_event);
81796 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81797 return 0;
81798
81799 case RTTEST_RESET:
81800 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
81801 return 0;
81802
81803 case RTTEST_RESETEVENT:
81804 - atomic_set(&rttest_event, 0);
81805 + atomic_set_unchecked(&rttest_event, 0);
81806 return 0;
81807
81808 default:
81809 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
81810 return ret;
81811
81812 td->mutexes[id] = 1;
81813 - td->event = atomic_add_return(1, &rttest_event);
81814 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81815 rt_mutex_lock(&mutexes[id]);
81816 - td->event = atomic_add_return(1, &rttest_event);
81817 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81818 td->mutexes[id] = 4;
81819 return 0;
81820
81821 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
81822 return ret;
81823
81824 td->mutexes[id] = 1;
81825 - td->event = atomic_add_return(1, &rttest_event);
81826 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81827 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
81828 - td->event = atomic_add_return(1, &rttest_event);
81829 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81830 td->mutexes[id] = ret ? 0 : 4;
81831 return ret ? -EINTR : 0;
81832
81833 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
81834 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
81835 return ret;
81836
81837 - td->event = atomic_add_return(1, &rttest_event);
81838 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81839 rt_mutex_unlock(&mutexes[id]);
81840 - td->event = atomic_add_return(1, &rttest_event);
81841 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81842 td->mutexes[id] = 0;
81843 return 0;
81844
81845 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
81846 break;
81847
81848 td->mutexes[dat] = 2;
81849 - td->event = atomic_add_return(1, &rttest_event);
81850 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81851 break;
81852
81853 default:
81854 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
81855 return;
81856
81857 td->mutexes[dat] = 3;
81858 - td->event = atomic_add_return(1, &rttest_event);
81859 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81860 break;
81861
81862 case RTTEST_LOCKNOWAIT:
81863 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
81864 return;
81865
81866 td->mutexes[dat] = 1;
81867 - td->event = atomic_add_return(1, &rttest_event);
81868 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81869 return;
81870
81871 default:
81872 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
81873 index 64de5f8..7735e12 100644
81874 --- a/kernel/sched/auto_group.c
81875 +++ b/kernel/sched/auto_group.c
81876 @@ -11,7 +11,7 @@
81877
81878 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
81879 static struct autogroup autogroup_default;
81880 -static atomic_t autogroup_seq_nr;
81881 +static atomic_unchecked_t autogroup_seq_nr;
81882
81883 void __init autogroup_init(struct task_struct *init_task)
81884 {
81885 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
81886
81887 kref_init(&ag->kref);
81888 init_rwsem(&ag->lock);
81889 - ag->id = atomic_inc_return(&autogroup_seq_nr);
81890 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
81891 ag->tg = tg;
81892 #ifdef CONFIG_RT_GROUP_SCHED
81893 /*
81894 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
81895 index e8b3350..d83d44e 100644
81896 --- a/kernel/sched/core.c
81897 +++ b/kernel/sched/core.c
81898 @@ -3440,7 +3440,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
81899 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
81900 * positive (at least 1, or number of jiffies left till timeout) if completed.
81901 */
81902 -long __sched
81903 +long __sched __intentional_overflow(-1)
81904 wait_for_completion_interruptible_timeout(struct completion *x,
81905 unsigned long timeout)
81906 {
81907 @@ -3457,7 +3457,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
81908 *
81909 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
81910 */
81911 -int __sched wait_for_completion_killable(struct completion *x)
81912 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
81913 {
81914 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
81915 if (t == -ERESTARTSYS)
81916 @@ -3478,7 +3478,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
81917 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
81918 * positive (at least 1, or number of jiffies left till timeout) if completed.
81919 */
81920 -long __sched
81921 +long __sched __intentional_overflow(-1)
81922 wait_for_completion_killable_timeout(struct completion *x,
81923 unsigned long timeout)
81924 {
81925 @@ -3704,6 +3704,8 @@ int can_nice(const struct task_struct *p, const int nice)
81926 /* convert nice value [19,-20] to rlimit style value [1,40] */
81927 int nice_rlim = 20 - nice;
81928
81929 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
81930 +
81931 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
81932 capable(CAP_SYS_NICE));
81933 }
81934 @@ -3737,7 +3739,8 @@ SYSCALL_DEFINE1(nice, int, increment)
81935 if (nice > 19)
81936 nice = 19;
81937
81938 - if (increment < 0 && !can_nice(current, nice))
81939 + if (increment < 0 && (!can_nice(current, nice) ||
81940 + gr_handle_chroot_nice()))
81941 return -EPERM;
81942
81943 retval = security_task_setnice(current, nice);
81944 @@ -3891,6 +3894,7 @@ recheck:
81945 unsigned long rlim_rtprio =
81946 task_rlimit(p, RLIMIT_RTPRIO);
81947
81948 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
81949 /* can't set/change the rt policy */
81950 if (policy != p->policy && !rlim_rtprio)
81951 return -EPERM;
81952 @@ -4988,7 +4992,7 @@ static void migrate_tasks(unsigned int dead_cpu)
81953
81954 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
81955
81956 -static struct ctl_table sd_ctl_dir[] = {
81957 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
81958 {
81959 .procname = "sched_domain",
81960 .mode = 0555,
81961 @@ -5005,17 +5009,17 @@ static struct ctl_table sd_ctl_root[] = {
81962 {}
81963 };
81964
81965 -static struct ctl_table *sd_alloc_ctl_entry(int n)
81966 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
81967 {
81968 - struct ctl_table *entry =
81969 + ctl_table_no_const *entry =
81970 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
81971
81972 return entry;
81973 }
81974
81975 -static void sd_free_ctl_entry(struct ctl_table **tablep)
81976 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
81977 {
81978 - struct ctl_table *entry;
81979 + ctl_table_no_const *entry;
81980
81981 /*
81982 * In the intermediate directories, both the child directory and
81983 @@ -5023,22 +5027,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
81984 * will always be set. In the lowest directory the names are
81985 * static strings and all have proc handlers.
81986 */
81987 - for (entry = *tablep; entry->mode; entry++) {
81988 - if (entry->child)
81989 - sd_free_ctl_entry(&entry->child);
81990 + for (entry = tablep; entry->mode; entry++) {
81991 + if (entry->child) {
81992 + sd_free_ctl_entry(entry->child);
81993 + pax_open_kernel();
81994 + entry->child = NULL;
81995 + pax_close_kernel();
81996 + }
81997 if (entry->proc_handler == NULL)
81998 kfree(entry->procname);
81999 }
82000
82001 - kfree(*tablep);
82002 - *tablep = NULL;
82003 + kfree(tablep);
82004 }
82005
82006 static int min_load_idx = 0;
82007 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
82008
82009 static void
82010 -set_table_entry(struct ctl_table *entry,
82011 +set_table_entry(ctl_table_no_const *entry,
82012 const char *procname, void *data, int maxlen,
82013 umode_t mode, proc_handler *proc_handler,
82014 bool load_idx)
82015 @@ -5058,7 +5065,7 @@ set_table_entry(struct ctl_table *entry,
82016 static struct ctl_table *
82017 sd_alloc_ctl_domain_table(struct sched_domain *sd)
82018 {
82019 - struct ctl_table *table = sd_alloc_ctl_entry(13);
82020 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
82021
82022 if (table == NULL)
82023 return NULL;
82024 @@ -5093,9 +5100,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
82025 return table;
82026 }
82027
82028 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
82029 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
82030 {
82031 - struct ctl_table *entry, *table;
82032 + ctl_table_no_const *entry, *table;
82033 struct sched_domain *sd;
82034 int domain_num = 0, i;
82035 char buf[32];
82036 @@ -5122,11 +5129,13 @@ static struct ctl_table_header *sd_sysctl_header;
82037 static void register_sched_domain_sysctl(void)
82038 {
82039 int i, cpu_num = num_possible_cpus();
82040 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
82041 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
82042 char buf[32];
82043
82044 WARN_ON(sd_ctl_dir[0].child);
82045 + pax_open_kernel();
82046 sd_ctl_dir[0].child = entry;
82047 + pax_close_kernel();
82048
82049 if (entry == NULL)
82050 return;
82051 @@ -5149,8 +5158,12 @@ static void unregister_sched_domain_sysctl(void)
82052 if (sd_sysctl_header)
82053 unregister_sysctl_table(sd_sysctl_header);
82054 sd_sysctl_header = NULL;
82055 - if (sd_ctl_dir[0].child)
82056 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
82057 + if (sd_ctl_dir[0].child) {
82058 + sd_free_ctl_entry(sd_ctl_dir[0].child);
82059 + pax_open_kernel();
82060 + sd_ctl_dir[0].child = NULL;
82061 + pax_close_kernel();
82062 + }
82063 }
82064 #else
82065 static void register_sched_domain_sysctl(void)
82066 @@ -5249,7 +5262,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
82067 * happens before everything else. This has to be lower priority than
82068 * the notifier in the perf_event subsystem, though.
82069 */
82070 -static struct notifier_block __cpuinitdata migration_notifier = {
82071 +static struct notifier_block migration_notifier = {
82072 .notifier_call = migration_call,
82073 .priority = CPU_PRI_MIGRATION,
82074 };
82075 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
82076 index c61a614..d7f3d7e 100644
82077 --- a/kernel/sched/fair.c
82078 +++ b/kernel/sched/fair.c
82079 @@ -831,7 +831,7 @@ void task_numa_fault(int node, int pages, bool migrated)
82080
82081 static void reset_ptenuma_scan(struct task_struct *p)
82082 {
82083 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
82084 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
82085 p->mm->numa_scan_offset = 0;
82086 }
82087
82088 @@ -5686,7 +5686,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
82089 * run_rebalance_domains is triggered when needed from the scheduler tick.
82090 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
82091 */
82092 -static void run_rebalance_domains(struct softirq_action *h)
82093 +static void run_rebalance_domains(void)
82094 {
82095 int this_cpu = smp_processor_id();
82096 struct rq *this_rq = cpu_rq(this_cpu);
82097 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
82098 index ce39224d..0e09343 100644
82099 --- a/kernel/sched/sched.h
82100 +++ b/kernel/sched/sched.h
82101 @@ -1009,7 +1009,7 @@ struct sched_class {
82102 #ifdef CONFIG_FAIR_GROUP_SCHED
82103 void (*task_move_group) (struct task_struct *p, int on_rq);
82104 #endif
82105 -};
82106 +} __do_const;
82107
82108 #define sched_class_highest (&stop_sched_class)
82109 #define for_each_class(class) \
82110 diff --git a/kernel/signal.c b/kernel/signal.c
82111 index 113411b..20d0a99 100644
82112 --- a/kernel/signal.c
82113 +++ b/kernel/signal.c
82114 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
82115
82116 int print_fatal_signals __read_mostly;
82117
82118 -static void __user *sig_handler(struct task_struct *t, int sig)
82119 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
82120 {
82121 return t->sighand->action[sig - 1].sa.sa_handler;
82122 }
82123
82124 -static int sig_handler_ignored(void __user *handler, int sig)
82125 +static int sig_handler_ignored(__sighandler_t handler, int sig)
82126 {
82127 /* Is it explicitly or implicitly ignored? */
82128 return handler == SIG_IGN ||
82129 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
82130
82131 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
82132 {
82133 - void __user *handler;
82134 + __sighandler_t handler;
82135
82136 handler = sig_handler(t, sig);
82137
82138 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
82139 atomic_inc(&user->sigpending);
82140 rcu_read_unlock();
82141
82142 + if (!override_rlimit)
82143 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
82144 +
82145 if (override_rlimit ||
82146 atomic_read(&user->sigpending) <=
82147 task_rlimit(t, RLIMIT_SIGPENDING)) {
82148 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
82149
82150 int unhandled_signal(struct task_struct *tsk, int sig)
82151 {
82152 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
82153 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
82154 if (is_global_init(tsk))
82155 return 1;
82156 if (handler != SIG_IGN && handler != SIG_DFL)
82157 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
82158 }
82159 }
82160
82161 + /* allow glibc communication via tgkill to other threads in our
82162 + thread group */
82163 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
82164 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
82165 + && gr_handle_signal(t, sig))
82166 + return -EPERM;
82167 +
82168 return security_task_kill(t, info, sig, 0);
82169 }
82170
82171 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
82172 return send_signal(sig, info, p, 1);
82173 }
82174
82175 -static int
82176 +int
82177 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
82178 {
82179 return send_signal(sig, info, t, 0);
82180 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
82181 unsigned long int flags;
82182 int ret, blocked, ignored;
82183 struct k_sigaction *action;
82184 + int is_unhandled = 0;
82185
82186 spin_lock_irqsave(&t->sighand->siglock, flags);
82187 action = &t->sighand->action[sig-1];
82188 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
82189 }
82190 if (action->sa.sa_handler == SIG_DFL)
82191 t->signal->flags &= ~SIGNAL_UNKILLABLE;
82192 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
82193 + is_unhandled = 1;
82194 ret = specific_send_sig_info(sig, info, t);
82195 spin_unlock_irqrestore(&t->sighand->siglock, flags);
82196
82197 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
82198 + normal operation */
82199 + if (is_unhandled) {
82200 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
82201 + gr_handle_crash(t, sig);
82202 + }
82203 +
82204 return ret;
82205 }
82206
82207 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
82208 ret = check_kill_permission(sig, info, p);
82209 rcu_read_unlock();
82210
82211 - if (!ret && sig)
82212 + if (!ret && sig) {
82213 ret = do_send_sig_info(sig, info, p, true);
82214 + if (!ret)
82215 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
82216 + }
82217
82218 return ret;
82219 }
82220 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
82221 int error = -ESRCH;
82222
82223 rcu_read_lock();
82224 - p = find_task_by_vpid(pid);
82225 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
82226 + /* allow glibc communication via tgkill to other threads in our
82227 + thread group */
82228 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
82229 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
82230 + p = find_task_by_vpid_unrestricted(pid);
82231 + else
82232 +#endif
82233 + p = find_task_by_vpid(pid);
82234 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
82235 error = check_kill_permission(sig, info, p);
82236 /*
82237 @@ -3219,6 +3250,16 @@ int __save_altstack(stack_t __user *uss, unsigned long sp)
82238 __put_user(t->sas_ss_size, &uss->ss_size);
82239 }
82240
82241 +#ifdef CONFIG_X86
82242 +void __save_altstack_ex(stack_t __user *uss, unsigned long sp)
82243 +{
82244 + struct task_struct *t = current;
82245 + put_user_ex((void __user *)t->sas_ss_sp, &uss->ss_sp);
82246 + put_user_ex(sas_ss_flags(sp), &uss->ss_flags);
82247 + put_user_ex(t->sas_ss_size, &uss->ss_size);
82248 +}
82249 +#endif
82250 +
82251 #ifdef CONFIG_COMPAT
82252 COMPAT_SYSCALL_DEFINE2(sigaltstack,
82253 const compat_stack_t __user *, uss_ptr,
82254 @@ -3240,8 +3281,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
82255 }
82256 seg = get_fs();
82257 set_fs(KERNEL_DS);
82258 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
82259 - (stack_t __force __user *) &uoss,
82260 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
82261 + (stack_t __force_user *) &uoss,
82262 compat_user_stack_pointer());
82263 set_fs(seg);
82264 if (ret >= 0 && uoss_ptr) {
82265 @@ -3268,6 +3309,16 @@ int __compat_save_altstack(compat_stack_t __user *uss, unsigned long sp)
82266 __put_user(sas_ss_flags(sp), &uss->ss_flags) |
82267 __put_user(t->sas_ss_size, &uss->ss_size);
82268 }
82269 +
82270 +#ifdef CONFIG_X86
82271 +void __compat_save_altstack_ex(compat_stack_t __user *uss, unsigned long sp)
82272 +{
82273 + struct task_struct *t = current;
82274 + put_user_ex(ptr_to_compat((void __user *)t->sas_ss_sp), &uss->ss_sp);
82275 + put_user_ex(sas_ss_flags(sp), &uss->ss_flags);
82276 + put_user_ex(t->sas_ss_size, &uss->ss_size);
82277 +}
82278 +#endif
82279 #endif
82280
82281 #ifdef __ARCH_WANT_SYS_SIGPENDING
82282 diff --git a/kernel/smp.c b/kernel/smp.c
82283 index 4dba0f7..fe9f773 100644
82284 --- a/kernel/smp.c
82285 +++ b/kernel/smp.c
82286 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
82287 return NOTIFY_OK;
82288 }
82289
82290 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
82291 +static struct notifier_block hotplug_cfd_notifier = {
82292 .notifier_call = hotplug_cfd,
82293 };
82294
82295 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
82296 index 02fc5c9..e54c335 100644
82297 --- a/kernel/smpboot.c
82298 +++ b/kernel/smpboot.c
82299 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
82300 }
82301 smpboot_unpark_thread(plug_thread, cpu);
82302 }
82303 - list_add(&plug_thread->list, &hotplug_threads);
82304 + pax_list_add(&plug_thread->list, &hotplug_threads);
82305 out:
82306 mutex_unlock(&smpboot_threads_lock);
82307 return ret;
82308 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
82309 {
82310 get_online_cpus();
82311 mutex_lock(&smpboot_threads_lock);
82312 - list_del(&plug_thread->list);
82313 + pax_list_del(&plug_thread->list);
82314 smpboot_destroy_threads(plug_thread);
82315 mutex_unlock(&smpboot_threads_lock);
82316 put_online_cpus();
82317 diff --git a/kernel/softirq.c b/kernel/softirq.c
82318 index 3d6833f..da6d93d 100644
82319 --- a/kernel/softirq.c
82320 +++ b/kernel/softirq.c
82321 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
82322 EXPORT_SYMBOL(irq_stat);
82323 #endif
82324
82325 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
82326 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
82327
82328 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
82329
82330 -char *softirq_to_name[NR_SOFTIRQS] = {
82331 +const char * const softirq_to_name[NR_SOFTIRQS] = {
82332 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
82333 "TASKLET", "SCHED", "HRTIMER", "RCU"
82334 };
82335 @@ -250,7 +250,7 @@ restart:
82336 kstat_incr_softirqs_this_cpu(vec_nr);
82337
82338 trace_softirq_entry(vec_nr);
82339 - h->action(h);
82340 + h->action();
82341 trace_softirq_exit(vec_nr);
82342 if (unlikely(prev_count != preempt_count())) {
82343 printk(KERN_ERR "huh, entered softirq %u %s %p"
82344 @@ -405,7 +405,7 @@ void __raise_softirq_irqoff(unsigned int nr)
82345 or_softirq_pending(1UL << nr);
82346 }
82347
82348 -void open_softirq(int nr, void (*action)(struct softirq_action *))
82349 +void __init open_softirq(int nr, void (*action)(void))
82350 {
82351 softirq_vec[nr].action = action;
82352 }
82353 @@ -461,7 +461,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
82354
82355 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
82356
82357 -static void tasklet_action(struct softirq_action *a)
82358 +static void tasklet_action(void)
82359 {
82360 struct tasklet_struct *list;
82361
82362 @@ -496,7 +496,7 @@ static void tasklet_action(struct softirq_action *a)
82363 }
82364 }
82365
82366 -static void tasklet_hi_action(struct softirq_action *a)
82367 +static void tasklet_hi_action(void)
82368 {
82369 struct tasklet_struct *list;
82370
82371 @@ -730,7 +730,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
82372 return NOTIFY_OK;
82373 }
82374
82375 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
82376 +static struct notifier_block remote_softirq_cpu_notifier = {
82377 .notifier_call = remote_softirq_cpu_notify,
82378 };
82379
82380 @@ -847,11 +847,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
82381 return NOTIFY_OK;
82382 }
82383
82384 -static struct notifier_block __cpuinitdata cpu_nfb = {
82385 +static struct notifier_block cpu_nfb = {
82386 .notifier_call = cpu_callback
82387 };
82388
82389 -static struct smp_hotplug_thread softirq_threads = {
82390 +static struct smp_hotplug_thread softirq_threads __read_only = {
82391 .store = &ksoftirqd,
82392 .thread_should_run = ksoftirqd_should_run,
82393 .thread_fn = run_ksoftirqd,
82394 diff --git a/kernel/srcu.c b/kernel/srcu.c
82395 index 01d5ccb..cdcbee6 100644
82396 --- a/kernel/srcu.c
82397 +++ b/kernel/srcu.c
82398 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
82399
82400 idx = ACCESS_ONCE(sp->completed) & 0x1;
82401 preempt_disable();
82402 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
82403 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
82404 smp_mb(); /* B */ /* Avoid leaking the critical section. */
82405 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
82406 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
82407 preempt_enable();
82408 return idx;
82409 }
82410 diff --git a/kernel/sys.c b/kernel/sys.c
82411 index 2bbd9a7..0875671 100644
82412 --- a/kernel/sys.c
82413 +++ b/kernel/sys.c
82414 @@ -163,6 +163,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
82415 error = -EACCES;
82416 goto out;
82417 }
82418 +
82419 + if (gr_handle_chroot_setpriority(p, niceval)) {
82420 + error = -EACCES;
82421 + goto out;
82422 + }
82423 +
82424 no_nice = security_task_setnice(p, niceval);
82425 if (no_nice) {
82426 error = no_nice;
82427 @@ -626,6 +632,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
82428 goto error;
82429 }
82430
82431 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
82432 + goto error;
82433 +
82434 if (rgid != (gid_t) -1 ||
82435 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
82436 new->sgid = new->egid;
82437 @@ -661,6 +670,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
82438 old = current_cred();
82439
82440 retval = -EPERM;
82441 +
82442 + if (gr_check_group_change(kgid, kgid, kgid))
82443 + goto error;
82444 +
82445 if (nsown_capable(CAP_SETGID))
82446 new->gid = new->egid = new->sgid = new->fsgid = kgid;
82447 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
82448 @@ -678,7 +691,7 @@ error:
82449 /*
82450 * change the user struct in a credentials set to match the new UID
82451 */
82452 -static int set_user(struct cred *new)
82453 +int set_user(struct cred *new)
82454 {
82455 struct user_struct *new_user;
82456
82457 @@ -758,6 +771,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
82458 goto error;
82459 }
82460
82461 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
82462 + goto error;
82463 +
82464 if (!uid_eq(new->uid, old->uid)) {
82465 retval = set_user(new);
82466 if (retval < 0)
82467 @@ -808,6 +824,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
82468 old = current_cred();
82469
82470 retval = -EPERM;
82471 +
82472 + if (gr_check_crash_uid(kuid))
82473 + goto error;
82474 + if (gr_check_user_change(kuid, kuid, kuid))
82475 + goto error;
82476 +
82477 if (nsown_capable(CAP_SETUID)) {
82478 new->suid = new->uid = kuid;
82479 if (!uid_eq(kuid, old->uid)) {
82480 @@ -877,6 +899,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
82481 goto error;
82482 }
82483
82484 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
82485 + goto error;
82486 +
82487 if (ruid != (uid_t) -1) {
82488 new->uid = kruid;
82489 if (!uid_eq(kruid, old->uid)) {
82490 @@ -959,6 +984,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
82491 goto error;
82492 }
82493
82494 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
82495 + goto error;
82496 +
82497 if (rgid != (gid_t) -1)
82498 new->gid = krgid;
82499 if (egid != (gid_t) -1)
82500 @@ -1020,12 +1048,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
82501 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
82502 nsown_capable(CAP_SETUID)) {
82503 if (!uid_eq(kuid, old->fsuid)) {
82504 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
82505 + goto error;
82506 +
82507 new->fsuid = kuid;
82508 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
82509 goto change_okay;
82510 }
82511 }
82512
82513 +error:
82514 abort_creds(new);
82515 return old_fsuid;
82516
82517 @@ -1058,12 +1090,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
82518 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
82519 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
82520 nsown_capable(CAP_SETGID)) {
82521 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
82522 + goto error;
82523 +
82524 if (!gid_eq(kgid, old->fsgid)) {
82525 new->fsgid = kgid;
82526 goto change_okay;
82527 }
82528 }
82529
82530 +error:
82531 abort_creds(new);
82532 return old_fsgid;
82533
82534 @@ -1432,19 +1468,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
82535 return -EFAULT;
82536
82537 down_read(&uts_sem);
82538 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
82539 + error = __copy_to_user(name->sysname, &utsname()->sysname,
82540 __OLD_UTS_LEN);
82541 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
82542 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
82543 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
82544 __OLD_UTS_LEN);
82545 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
82546 - error |= __copy_to_user(&name->release, &utsname()->release,
82547 + error |= __copy_to_user(name->release, &utsname()->release,
82548 __OLD_UTS_LEN);
82549 error |= __put_user(0, name->release + __OLD_UTS_LEN);
82550 - error |= __copy_to_user(&name->version, &utsname()->version,
82551 + error |= __copy_to_user(name->version, &utsname()->version,
82552 __OLD_UTS_LEN);
82553 error |= __put_user(0, name->version + __OLD_UTS_LEN);
82554 - error |= __copy_to_user(&name->machine, &utsname()->machine,
82555 + error |= __copy_to_user(name->machine, &utsname()->machine,
82556 __OLD_UTS_LEN);
82557 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
82558 up_read(&uts_sem);
82559 @@ -1646,6 +1682,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
82560 */
82561 new_rlim->rlim_cur = 1;
82562 }
82563 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
82564 + is changed to a lower value. Since tasks can be created by the same
82565 + user in between this limit change and an execve by this task, force
82566 + a recheck only for this task by setting PF_NPROC_EXCEEDED
82567 + */
82568 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
82569 + tsk->flags |= PF_NPROC_EXCEEDED;
82570 }
82571 if (!retval) {
82572 if (old_rlim)
82573 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
82574 index 9edcf45..713c960 100644
82575 --- a/kernel/sysctl.c
82576 +++ b/kernel/sysctl.c
82577 @@ -93,7 +93,6 @@
82578
82579
82580 #if defined(CONFIG_SYSCTL)
82581 -
82582 /* External variables not in a header file. */
82583 extern int sysctl_overcommit_memory;
82584 extern int sysctl_overcommit_ratio;
82585 @@ -119,18 +118,18 @@ extern int blk_iopoll_enabled;
82586
82587 /* Constants used for minimum and maximum */
82588 #ifdef CONFIG_LOCKUP_DETECTOR
82589 -static int sixty = 60;
82590 -static int neg_one = -1;
82591 +static int sixty __read_only = 60;
82592 #endif
82593
82594 -static int zero;
82595 -static int __maybe_unused one = 1;
82596 -static int __maybe_unused two = 2;
82597 -static int __maybe_unused three = 3;
82598 -static unsigned long one_ul = 1;
82599 -static int one_hundred = 100;
82600 +static int neg_one __read_only = -1;
82601 +static int zero __read_only = 0;
82602 +static int __maybe_unused one __read_only = 1;
82603 +static int __maybe_unused two __read_only = 2;
82604 +static int __maybe_unused three __read_only = 3;
82605 +static unsigned long one_ul __read_only = 1;
82606 +static int one_hundred __read_only = 100;
82607 #ifdef CONFIG_PRINTK
82608 -static int ten_thousand = 10000;
82609 +static int ten_thousand __read_only = 10000;
82610 #endif
82611
82612 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
82613 @@ -177,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
82614 void __user *buffer, size_t *lenp, loff_t *ppos);
82615 #endif
82616
82617 -#ifdef CONFIG_PRINTK
82618 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
82619 void __user *buffer, size_t *lenp, loff_t *ppos);
82620 -#endif
82621
82622 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
82623 void __user *buffer, size_t *lenp, loff_t *ppos);
82624 @@ -211,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
82625
82626 #endif
82627
82628 +extern struct ctl_table grsecurity_table[];
82629 +
82630 static struct ctl_table kern_table[];
82631 static struct ctl_table vm_table[];
82632 static struct ctl_table fs_table[];
82633 @@ -225,6 +224,20 @@ extern struct ctl_table epoll_table[];
82634 int sysctl_legacy_va_layout;
82635 #endif
82636
82637 +#ifdef CONFIG_PAX_SOFTMODE
82638 +static ctl_table pax_table[] = {
82639 + {
82640 + .procname = "softmode",
82641 + .data = &pax_softmode,
82642 + .maxlen = sizeof(unsigned int),
82643 + .mode = 0600,
82644 + .proc_handler = &proc_dointvec,
82645 + },
82646 +
82647 + { }
82648 +};
82649 +#endif
82650 +
82651 /* The default sysctl tables: */
82652
82653 static struct ctl_table sysctl_base_table[] = {
82654 @@ -273,6 +286,22 @@ static int max_extfrag_threshold = 1000;
82655 #endif
82656
82657 static struct ctl_table kern_table[] = {
82658 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
82659 + {
82660 + .procname = "grsecurity",
82661 + .mode = 0500,
82662 + .child = grsecurity_table,
82663 + },
82664 +#endif
82665 +
82666 +#ifdef CONFIG_PAX_SOFTMODE
82667 + {
82668 + .procname = "pax",
82669 + .mode = 0500,
82670 + .child = pax_table,
82671 + },
82672 +#endif
82673 +
82674 {
82675 .procname = "sched_child_runs_first",
82676 .data = &sysctl_sched_child_runs_first,
82677 @@ -607,7 +636,7 @@ static struct ctl_table kern_table[] = {
82678 .data = &modprobe_path,
82679 .maxlen = KMOD_PATH_LEN,
82680 .mode = 0644,
82681 - .proc_handler = proc_dostring,
82682 + .proc_handler = proc_dostring_modpriv,
82683 },
82684 {
82685 .procname = "modules_disabled",
82686 @@ -774,16 +803,20 @@ static struct ctl_table kern_table[] = {
82687 .extra1 = &zero,
82688 .extra2 = &one,
82689 },
82690 +#endif
82691 {
82692 .procname = "kptr_restrict",
82693 .data = &kptr_restrict,
82694 .maxlen = sizeof(int),
82695 .mode = 0644,
82696 .proc_handler = proc_dointvec_minmax_sysadmin,
82697 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82698 + .extra1 = &two,
82699 +#else
82700 .extra1 = &zero,
82701 +#endif
82702 .extra2 = &two,
82703 },
82704 -#endif
82705 {
82706 .procname = "ngroups_max",
82707 .data = &ngroups_max,
82708 @@ -1025,10 +1058,17 @@ static struct ctl_table kern_table[] = {
82709 */
82710 {
82711 .procname = "perf_event_paranoid",
82712 - .data = &sysctl_perf_event_paranoid,
82713 - .maxlen = sizeof(sysctl_perf_event_paranoid),
82714 + .data = &sysctl_perf_event_legitimately_concerned,
82715 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
82716 .mode = 0644,
82717 - .proc_handler = proc_dointvec,
82718 + /* go ahead, be a hero */
82719 + .proc_handler = proc_dointvec_minmax_sysadmin,
82720 + .extra1 = &neg_one,
82721 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
82722 + .extra2 = &three,
82723 +#else
82724 + .extra2 = &two,
82725 +#endif
82726 },
82727 {
82728 .procname = "perf_event_mlock_kb",
82729 @@ -1282,6 +1322,13 @@ static struct ctl_table vm_table[] = {
82730 .proc_handler = proc_dointvec_minmax,
82731 .extra1 = &zero,
82732 },
82733 + {
82734 + .procname = "heap_stack_gap",
82735 + .data = &sysctl_heap_stack_gap,
82736 + .maxlen = sizeof(sysctl_heap_stack_gap),
82737 + .mode = 0644,
82738 + .proc_handler = proc_doulongvec_minmax,
82739 + },
82740 #else
82741 {
82742 .procname = "nr_trim_pages",
82743 @@ -1746,6 +1793,16 @@ int proc_dostring(struct ctl_table *table, int write,
82744 buffer, lenp, ppos);
82745 }
82746
82747 +int proc_dostring_modpriv(struct ctl_table *table, int write,
82748 + void __user *buffer, size_t *lenp, loff_t *ppos)
82749 +{
82750 + if (write && !capable(CAP_SYS_MODULE))
82751 + return -EPERM;
82752 +
82753 + return _proc_do_string(table->data, table->maxlen, write,
82754 + buffer, lenp, ppos);
82755 +}
82756 +
82757 static size_t proc_skip_spaces(char **buf)
82758 {
82759 size_t ret;
82760 @@ -1851,6 +1908,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
82761 len = strlen(tmp);
82762 if (len > *size)
82763 len = *size;
82764 + if (len > sizeof(tmp))
82765 + len = sizeof(tmp);
82766 if (copy_to_user(*buf, tmp, len))
82767 return -EFAULT;
82768 *size -= len;
82769 @@ -2015,7 +2074,7 @@ int proc_dointvec(struct ctl_table *table, int write,
82770 static int proc_taint(struct ctl_table *table, int write,
82771 void __user *buffer, size_t *lenp, loff_t *ppos)
82772 {
82773 - struct ctl_table t;
82774 + ctl_table_no_const t;
82775 unsigned long tmptaint = get_taint();
82776 int err;
82777
82778 @@ -2043,7 +2102,6 @@ static int proc_taint(struct ctl_table *table, int write,
82779 return err;
82780 }
82781
82782 -#ifdef CONFIG_PRINTK
82783 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
82784 void __user *buffer, size_t *lenp, loff_t *ppos)
82785 {
82786 @@ -2052,7 +2110,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
82787
82788 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
82789 }
82790 -#endif
82791
82792 struct do_proc_dointvec_minmax_conv_param {
82793 int *min;
82794 @@ -2199,8 +2256,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
82795 *i = val;
82796 } else {
82797 val = convdiv * (*i) / convmul;
82798 - if (!first)
82799 + if (!first) {
82800 err = proc_put_char(&buffer, &left, '\t');
82801 + if (err)
82802 + break;
82803 + }
82804 err = proc_put_long(&buffer, &left, val, false);
82805 if (err)
82806 break;
82807 @@ -2592,6 +2652,12 @@ int proc_dostring(struct ctl_table *table, int write,
82808 return -ENOSYS;
82809 }
82810
82811 +int proc_dostring_modpriv(struct ctl_table *table, int write,
82812 + void __user *buffer, size_t *lenp, loff_t *ppos)
82813 +{
82814 + return -ENOSYS;
82815 +}
82816 +
82817 int proc_dointvec(struct ctl_table *table, int write,
82818 void __user *buffer, size_t *lenp, loff_t *ppos)
82819 {
82820 @@ -2648,5 +2714,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
82821 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
82822 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
82823 EXPORT_SYMBOL(proc_dostring);
82824 +EXPORT_SYMBOL(proc_dostring_modpriv);
82825 EXPORT_SYMBOL(proc_doulongvec_minmax);
82826 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
82827 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
82828 index 145bb4d..b2aa969 100644
82829 --- a/kernel/taskstats.c
82830 +++ b/kernel/taskstats.c
82831 @@ -28,9 +28,12 @@
82832 #include <linux/fs.h>
82833 #include <linux/file.h>
82834 #include <linux/pid_namespace.h>
82835 +#include <linux/grsecurity.h>
82836 #include <net/genetlink.h>
82837 #include <linux/atomic.h>
82838
82839 +extern int gr_is_taskstats_denied(int pid);
82840 +
82841 /*
82842 * Maximum length of a cpumask that can be specified in
82843 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
82844 @@ -570,6 +573,9 @@ err:
82845
82846 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
82847 {
82848 + if (gr_is_taskstats_denied(current->pid))
82849 + return -EACCES;
82850 +
82851 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
82852 return cmd_attr_register_cpumask(info);
82853 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
82854 diff --git a/kernel/time.c b/kernel/time.c
82855 index d3617db..c98bbe9 100644
82856 --- a/kernel/time.c
82857 +++ b/kernel/time.c
82858 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
82859 return error;
82860
82861 if (tz) {
82862 + /* we log in do_settimeofday called below, so don't log twice
82863 + */
82864 + if (!tv)
82865 + gr_log_timechange();
82866 +
82867 sys_tz = *tz;
82868 update_vsyscall_tz();
82869 if (firsttime) {
82870 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
82871 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
82872 * value to a scaled second value.
82873 */
82874 -unsigned long
82875 +unsigned long __intentional_overflow(-1)
82876 timespec_to_jiffies(const struct timespec *value)
82877 {
82878 unsigned long sec = value->tv_sec;
82879 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
82880 index f11d83b..d016d91 100644
82881 --- a/kernel/time/alarmtimer.c
82882 +++ b/kernel/time/alarmtimer.c
82883 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
82884 struct platform_device *pdev;
82885 int error = 0;
82886 int i;
82887 - struct k_clock alarm_clock = {
82888 + static struct k_clock alarm_clock = {
82889 .clock_getres = alarm_clock_getres,
82890 .clock_get = alarm_clock_get,
82891 .timer_create = alarm_timer_create,
82892 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
82893 index baeeb5c..c22704a 100644
82894 --- a/kernel/time/timekeeping.c
82895 +++ b/kernel/time/timekeeping.c
82896 @@ -15,6 +15,7 @@
82897 #include <linux/init.h>
82898 #include <linux/mm.h>
82899 #include <linux/sched.h>
82900 +#include <linux/grsecurity.h>
82901 #include <linux/syscore_ops.h>
82902 #include <linux/clocksource.h>
82903 #include <linux/jiffies.h>
82904 @@ -495,6 +496,8 @@ int do_settimeofday(const struct timespec *tv)
82905 if (!timespec_valid_strict(tv))
82906 return -EINVAL;
82907
82908 + gr_log_timechange();
82909 +
82910 raw_spin_lock_irqsave(&timekeeper_lock, flags);
82911 write_seqcount_begin(&timekeeper_seq);
82912
82913 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
82914 index 3bdf283..cc68d83 100644
82915 --- a/kernel/time/timer_list.c
82916 +++ b/kernel/time/timer_list.c
82917 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
82918
82919 static void print_name_offset(struct seq_file *m, void *sym)
82920 {
82921 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82922 + SEQ_printf(m, "<%p>", NULL);
82923 +#else
82924 char symname[KSYM_NAME_LEN];
82925
82926 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
82927 SEQ_printf(m, "<%pK>", sym);
82928 else
82929 SEQ_printf(m, "%s", symname);
82930 +#endif
82931 }
82932
82933 static void
82934 @@ -119,7 +123,11 @@ next_one:
82935 static void
82936 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
82937 {
82938 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82939 + SEQ_printf(m, " .base: %p\n", NULL);
82940 +#else
82941 SEQ_printf(m, " .base: %pK\n", base);
82942 +#endif
82943 SEQ_printf(m, " .index: %d\n",
82944 base->index);
82945 SEQ_printf(m, " .resolution: %Lu nsecs\n",
82946 @@ -355,7 +363,11 @@ static int __init init_timer_list_procfs(void)
82947 {
82948 struct proc_dir_entry *pe;
82949
82950 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
82951 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
82952 +#else
82953 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
82954 +#endif
82955 if (!pe)
82956 return -ENOMEM;
82957 return 0;
82958 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
82959 index 0b537f2..40d6c20 100644
82960 --- a/kernel/time/timer_stats.c
82961 +++ b/kernel/time/timer_stats.c
82962 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
82963 static unsigned long nr_entries;
82964 static struct entry entries[MAX_ENTRIES];
82965
82966 -static atomic_t overflow_count;
82967 +static atomic_unchecked_t overflow_count;
82968
82969 /*
82970 * The entries are in a hash-table, for fast lookup:
82971 @@ -140,7 +140,7 @@ static void reset_entries(void)
82972 nr_entries = 0;
82973 memset(entries, 0, sizeof(entries));
82974 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
82975 - atomic_set(&overflow_count, 0);
82976 + atomic_set_unchecked(&overflow_count, 0);
82977 }
82978
82979 static struct entry *alloc_entry(void)
82980 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
82981 if (likely(entry))
82982 entry->count++;
82983 else
82984 - atomic_inc(&overflow_count);
82985 + atomic_inc_unchecked(&overflow_count);
82986
82987 out_unlock:
82988 raw_spin_unlock_irqrestore(lock, flags);
82989 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
82990
82991 static void print_name_offset(struct seq_file *m, unsigned long addr)
82992 {
82993 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82994 + seq_printf(m, "<%p>", NULL);
82995 +#else
82996 char symname[KSYM_NAME_LEN];
82997
82998 if (lookup_symbol_name(addr, symname) < 0)
82999 - seq_printf(m, "<%p>", (void *)addr);
83000 + seq_printf(m, "<%pK>", (void *)addr);
83001 else
83002 seq_printf(m, "%s", symname);
83003 +#endif
83004 }
83005
83006 static int tstats_show(struct seq_file *m, void *v)
83007 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
83008
83009 seq_puts(m, "Timer Stats Version: v0.2\n");
83010 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
83011 - if (atomic_read(&overflow_count))
83012 + if (atomic_read_unchecked(&overflow_count))
83013 seq_printf(m, "Overflow: %d entries\n",
83014 - atomic_read(&overflow_count));
83015 + atomic_read_unchecked(&overflow_count));
83016
83017 for (i = 0; i < nr_entries; i++) {
83018 entry = entries + i;
83019 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
83020 {
83021 struct proc_dir_entry *pe;
83022
83023 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
83024 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
83025 +#else
83026 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
83027 +#endif
83028 if (!pe)
83029 return -ENOMEM;
83030 return 0;
83031 diff --git a/kernel/timer.c b/kernel/timer.c
83032 index 15bc1b4..32da49c 100644
83033 --- a/kernel/timer.c
83034 +++ b/kernel/timer.c
83035 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
83036 /*
83037 * This function runs timers and the timer-tq in bottom half context.
83038 */
83039 -static void run_timer_softirq(struct softirq_action *h)
83040 +static void run_timer_softirq(void)
83041 {
83042 struct tvec_base *base = __this_cpu_read(tvec_bases);
83043
83044 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
83045 *
83046 * In all cases the return value is guaranteed to be non-negative.
83047 */
83048 -signed long __sched schedule_timeout(signed long timeout)
83049 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
83050 {
83051 struct timer_list timer;
83052 unsigned long expire;
83053 @@ -1635,7 +1635,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
83054 return NOTIFY_OK;
83055 }
83056
83057 -static struct notifier_block __cpuinitdata timers_nb = {
83058 +static struct notifier_block timers_nb = {
83059 .notifier_call = timer_cpu_notify,
83060 };
83061
83062 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
83063 index b8b8560..75b1a09 100644
83064 --- a/kernel/trace/blktrace.c
83065 +++ b/kernel/trace/blktrace.c
83066 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
83067 struct blk_trace *bt = filp->private_data;
83068 char buf[16];
83069
83070 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
83071 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
83072
83073 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
83074 }
83075 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
83076 return 1;
83077
83078 bt = buf->chan->private_data;
83079 - atomic_inc(&bt->dropped);
83080 + atomic_inc_unchecked(&bt->dropped);
83081 return 0;
83082 }
83083
83084 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
83085
83086 bt->dir = dir;
83087 bt->dev = dev;
83088 - atomic_set(&bt->dropped, 0);
83089 + atomic_set_unchecked(&bt->dropped, 0);
83090
83091 ret = -EIO;
83092 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
83093 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
83094 index 6c508ff..ee55a13 100644
83095 --- a/kernel/trace/ftrace.c
83096 +++ b/kernel/trace/ftrace.c
83097 @@ -1915,12 +1915,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
83098 if (unlikely(ftrace_disabled))
83099 return 0;
83100
83101 + ret = ftrace_arch_code_modify_prepare();
83102 + FTRACE_WARN_ON(ret);
83103 + if (ret)
83104 + return 0;
83105 +
83106 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
83107 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
83108 if (ret) {
83109 ftrace_bug(ret, ip);
83110 - return 0;
83111 }
83112 - return 1;
83113 + return ret ? 0 : 1;
83114 }
83115
83116 /*
83117 @@ -3931,8 +3936,10 @@ static int ftrace_process_locs(struct module *mod,
83118 if (!count)
83119 return 0;
83120
83121 + pax_open_kernel();
83122 sort(start, count, sizeof(*start),
83123 ftrace_cmp_ips, ftrace_swap_ips);
83124 + pax_close_kernel();
83125
83126 start_pg = ftrace_allocate_pages(count);
83127 if (!start_pg)
83128 @@ -4655,8 +4662,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
83129 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
83130
83131 static int ftrace_graph_active;
83132 -static struct notifier_block ftrace_suspend_notifier;
83133 -
83134 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
83135 {
83136 return 0;
83137 @@ -4800,6 +4805,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
83138 return NOTIFY_DONE;
83139 }
83140
83141 +static struct notifier_block ftrace_suspend_notifier = {
83142 + .notifier_call = ftrace_suspend_notifier_call
83143 +};
83144 +
83145 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
83146 trace_func_graph_ent_t entryfunc)
83147 {
83148 @@ -4813,7 +4822,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
83149 goto out;
83150 }
83151
83152 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
83153 register_pm_notifier(&ftrace_suspend_notifier);
83154
83155 ftrace_graph_active++;
83156 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
83157 index e444ff8..438b8f4 100644
83158 --- a/kernel/trace/ring_buffer.c
83159 +++ b/kernel/trace/ring_buffer.c
83160 @@ -352,9 +352,9 @@ struct buffer_data_page {
83161 */
83162 struct buffer_page {
83163 struct list_head list; /* list of buffer pages */
83164 - local_t write; /* index for next write */
83165 + local_unchecked_t write; /* index for next write */
83166 unsigned read; /* index for next read */
83167 - local_t entries; /* entries on this page */
83168 + local_unchecked_t entries; /* entries on this page */
83169 unsigned long real_end; /* real end of data */
83170 struct buffer_data_page *page; /* Actual data page */
83171 };
83172 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
83173 unsigned long last_overrun;
83174 local_t entries_bytes;
83175 local_t entries;
83176 - local_t overrun;
83177 - local_t commit_overrun;
83178 + local_unchecked_t overrun;
83179 + local_unchecked_t commit_overrun;
83180 local_t dropped_events;
83181 local_t committing;
83182 local_t commits;
83183 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
83184 *
83185 * We add a counter to the write field to denote this.
83186 */
83187 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
83188 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
83189 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
83190 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
83191
83192 /*
83193 * Just make sure we have seen our old_write and synchronize
83194 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
83195 * cmpxchg to only update if an interrupt did not already
83196 * do it for us. If the cmpxchg fails, we don't care.
83197 */
83198 - (void)local_cmpxchg(&next_page->write, old_write, val);
83199 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
83200 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
83201 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
83202
83203 /*
83204 * No need to worry about races with clearing out the commit.
83205 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
83206
83207 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
83208 {
83209 - return local_read(&bpage->entries) & RB_WRITE_MASK;
83210 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
83211 }
83212
83213 static inline unsigned long rb_page_write(struct buffer_page *bpage)
83214 {
83215 - return local_read(&bpage->write) & RB_WRITE_MASK;
83216 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
83217 }
83218
83219 static int
83220 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
83221 * bytes consumed in ring buffer from here.
83222 * Increment overrun to account for the lost events.
83223 */
83224 - local_add(page_entries, &cpu_buffer->overrun);
83225 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
83226 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
83227 }
83228
83229 @@ -2063,7 +2063,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
83230 * it is our responsibility to update
83231 * the counters.
83232 */
83233 - local_add(entries, &cpu_buffer->overrun);
83234 + local_add_unchecked(entries, &cpu_buffer->overrun);
83235 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
83236
83237 /*
83238 @@ -2213,7 +2213,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
83239 if (tail == BUF_PAGE_SIZE)
83240 tail_page->real_end = 0;
83241
83242 - local_sub(length, &tail_page->write);
83243 + local_sub_unchecked(length, &tail_page->write);
83244 return;
83245 }
83246
83247 @@ -2248,7 +2248,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
83248 rb_event_set_padding(event);
83249
83250 /* Set the write back to the previous setting */
83251 - local_sub(length, &tail_page->write);
83252 + local_sub_unchecked(length, &tail_page->write);
83253 return;
83254 }
83255
83256 @@ -2260,7 +2260,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
83257
83258 /* Set write to end of buffer */
83259 length = (tail + length) - BUF_PAGE_SIZE;
83260 - local_sub(length, &tail_page->write);
83261 + local_sub_unchecked(length, &tail_page->write);
83262 }
83263
83264 /*
83265 @@ -2286,7 +2286,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
83266 * about it.
83267 */
83268 if (unlikely(next_page == commit_page)) {
83269 - local_inc(&cpu_buffer->commit_overrun);
83270 + local_inc_unchecked(&cpu_buffer->commit_overrun);
83271 goto out_reset;
83272 }
83273
83274 @@ -2342,7 +2342,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
83275 cpu_buffer->tail_page) &&
83276 (cpu_buffer->commit_page ==
83277 cpu_buffer->reader_page))) {
83278 - local_inc(&cpu_buffer->commit_overrun);
83279 + local_inc_unchecked(&cpu_buffer->commit_overrun);
83280 goto out_reset;
83281 }
83282 }
83283 @@ -2390,7 +2390,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
83284 length += RB_LEN_TIME_EXTEND;
83285
83286 tail_page = cpu_buffer->tail_page;
83287 - write = local_add_return(length, &tail_page->write);
83288 + write = local_add_return_unchecked(length, &tail_page->write);
83289
83290 /* set write to only the index of the write */
83291 write &= RB_WRITE_MASK;
83292 @@ -2407,7 +2407,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
83293 kmemcheck_annotate_bitfield(event, bitfield);
83294 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
83295
83296 - local_inc(&tail_page->entries);
83297 + local_inc_unchecked(&tail_page->entries);
83298
83299 /*
83300 * If this is the first commit on the page, then update
83301 @@ -2440,7 +2440,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
83302
83303 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
83304 unsigned long write_mask =
83305 - local_read(&bpage->write) & ~RB_WRITE_MASK;
83306 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
83307 unsigned long event_length = rb_event_length(event);
83308 /*
83309 * This is on the tail page. It is possible that
83310 @@ -2450,7 +2450,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
83311 */
83312 old_index += write_mask;
83313 new_index += write_mask;
83314 - index = local_cmpxchg(&bpage->write, old_index, new_index);
83315 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
83316 if (index == old_index) {
83317 /* update counters */
83318 local_sub(event_length, &cpu_buffer->entries_bytes);
83319 @@ -2842,7 +2842,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
83320
83321 /* Do the likely case first */
83322 if (likely(bpage->page == (void *)addr)) {
83323 - local_dec(&bpage->entries);
83324 + local_dec_unchecked(&bpage->entries);
83325 return;
83326 }
83327
83328 @@ -2854,7 +2854,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
83329 start = bpage;
83330 do {
83331 if (bpage->page == (void *)addr) {
83332 - local_dec(&bpage->entries);
83333 + local_dec_unchecked(&bpage->entries);
83334 return;
83335 }
83336 rb_inc_page(cpu_buffer, &bpage);
83337 @@ -3138,7 +3138,7 @@ static inline unsigned long
83338 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
83339 {
83340 return local_read(&cpu_buffer->entries) -
83341 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
83342 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
83343 }
83344
83345 /**
83346 @@ -3227,7 +3227,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
83347 return 0;
83348
83349 cpu_buffer = buffer->buffers[cpu];
83350 - ret = local_read(&cpu_buffer->overrun);
83351 + ret = local_read_unchecked(&cpu_buffer->overrun);
83352
83353 return ret;
83354 }
83355 @@ -3250,7 +3250,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
83356 return 0;
83357
83358 cpu_buffer = buffer->buffers[cpu];
83359 - ret = local_read(&cpu_buffer->commit_overrun);
83360 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
83361
83362 return ret;
83363 }
83364 @@ -3335,7 +3335,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
83365 /* if you care about this being correct, lock the buffer */
83366 for_each_buffer_cpu(buffer, cpu) {
83367 cpu_buffer = buffer->buffers[cpu];
83368 - overruns += local_read(&cpu_buffer->overrun);
83369 + overruns += local_read_unchecked(&cpu_buffer->overrun);
83370 }
83371
83372 return overruns;
83373 @@ -3511,8 +3511,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
83374 /*
83375 * Reset the reader page to size zero.
83376 */
83377 - local_set(&cpu_buffer->reader_page->write, 0);
83378 - local_set(&cpu_buffer->reader_page->entries, 0);
83379 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
83380 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
83381 local_set(&cpu_buffer->reader_page->page->commit, 0);
83382 cpu_buffer->reader_page->real_end = 0;
83383
83384 @@ -3546,7 +3546,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
83385 * want to compare with the last_overrun.
83386 */
83387 smp_mb();
83388 - overwrite = local_read(&(cpu_buffer->overrun));
83389 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
83390
83391 /*
83392 * Here's the tricky part.
83393 @@ -4116,8 +4116,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
83394
83395 cpu_buffer->head_page
83396 = list_entry(cpu_buffer->pages, struct buffer_page, list);
83397 - local_set(&cpu_buffer->head_page->write, 0);
83398 - local_set(&cpu_buffer->head_page->entries, 0);
83399 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
83400 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
83401 local_set(&cpu_buffer->head_page->page->commit, 0);
83402
83403 cpu_buffer->head_page->read = 0;
83404 @@ -4127,14 +4127,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
83405
83406 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
83407 INIT_LIST_HEAD(&cpu_buffer->new_pages);
83408 - local_set(&cpu_buffer->reader_page->write, 0);
83409 - local_set(&cpu_buffer->reader_page->entries, 0);
83410 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
83411 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
83412 local_set(&cpu_buffer->reader_page->page->commit, 0);
83413 cpu_buffer->reader_page->read = 0;
83414
83415 local_set(&cpu_buffer->entries_bytes, 0);
83416 - local_set(&cpu_buffer->overrun, 0);
83417 - local_set(&cpu_buffer->commit_overrun, 0);
83418 + local_set_unchecked(&cpu_buffer->overrun, 0);
83419 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
83420 local_set(&cpu_buffer->dropped_events, 0);
83421 local_set(&cpu_buffer->entries, 0);
83422 local_set(&cpu_buffer->committing, 0);
83423 @@ -4538,8 +4538,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
83424 rb_init_page(bpage);
83425 bpage = reader->page;
83426 reader->page = *data_page;
83427 - local_set(&reader->write, 0);
83428 - local_set(&reader->entries, 0);
83429 + local_set_unchecked(&reader->write, 0);
83430 + local_set_unchecked(&reader->entries, 0);
83431 reader->read = 0;
83432 *data_page = bpage;
83433
83434 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
83435 index 06a5bce..53ad6e7 100644
83436 --- a/kernel/trace/trace.c
83437 +++ b/kernel/trace/trace.c
83438 @@ -3347,7 +3347,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
83439 return 0;
83440 }
83441
83442 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
83443 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
83444 {
83445 /* do nothing if flag is already set */
83446 if (!!(trace_flags & mask) == !!enabled)
83447 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
83448 index 51b4448..7be601f 100644
83449 --- a/kernel/trace/trace.h
83450 +++ b/kernel/trace/trace.h
83451 @@ -1035,7 +1035,7 @@ extern const char *__stop___trace_bprintk_fmt[];
83452 void trace_printk_init_buffers(void);
83453 void trace_printk_start_comm(void);
83454 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
83455 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
83456 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
83457
83458 /*
83459 * Normal trace_printk() and friends allocates special buffers
83460 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
83461 index 6953263..2004e16 100644
83462 --- a/kernel/trace/trace_events.c
83463 +++ b/kernel/trace/trace_events.c
83464 @@ -1748,10 +1748,6 @@ static LIST_HEAD(ftrace_module_file_list);
83465 struct ftrace_module_file_ops {
83466 struct list_head list;
83467 struct module *mod;
83468 - struct file_operations id;
83469 - struct file_operations enable;
83470 - struct file_operations format;
83471 - struct file_operations filter;
83472 };
83473
83474 static struct ftrace_module_file_ops *
83475 @@ -1792,17 +1788,12 @@ trace_create_file_ops(struct module *mod)
83476
83477 file_ops->mod = mod;
83478
83479 - file_ops->id = ftrace_event_id_fops;
83480 - file_ops->id.owner = mod;
83481 -
83482 - file_ops->enable = ftrace_enable_fops;
83483 - file_ops->enable.owner = mod;
83484 -
83485 - file_ops->filter = ftrace_event_filter_fops;
83486 - file_ops->filter.owner = mod;
83487 -
83488 - file_ops->format = ftrace_event_format_fops;
83489 - file_ops->format.owner = mod;
83490 + pax_open_kernel();
83491 + mod->trace_id.owner = mod;
83492 + mod->trace_enable.owner = mod;
83493 + mod->trace_filter.owner = mod;
83494 + mod->trace_format.owner = mod;
83495 + pax_close_kernel();
83496
83497 list_add(&file_ops->list, &ftrace_module_file_list);
83498
83499 @@ -1895,8 +1886,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
83500 struct ftrace_module_file_ops *file_ops)
83501 {
83502 return __trace_add_new_event(call, tr,
83503 - &file_ops->id, &file_ops->enable,
83504 - &file_ops->filter, &file_ops->format);
83505 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
83506 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
83507 }
83508
83509 #else
83510 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
83511 index a5e8f48..a9690d2 100644
83512 --- a/kernel/trace/trace_mmiotrace.c
83513 +++ b/kernel/trace/trace_mmiotrace.c
83514 @@ -24,7 +24,7 @@ struct header_iter {
83515 static struct trace_array *mmio_trace_array;
83516 static bool overrun_detected;
83517 static unsigned long prev_overruns;
83518 -static atomic_t dropped_count;
83519 +static atomic_unchecked_t dropped_count;
83520
83521 static void mmio_reset_data(struct trace_array *tr)
83522 {
83523 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
83524
83525 static unsigned long count_overruns(struct trace_iterator *iter)
83526 {
83527 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
83528 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
83529 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
83530
83531 if (over > prev_overruns)
83532 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
83533 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
83534 sizeof(*entry), 0, pc);
83535 if (!event) {
83536 - atomic_inc(&dropped_count);
83537 + atomic_inc_unchecked(&dropped_count);
83538 return;
83539 }
83540 entry = ring_buffer_event_data(event);
83541 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
83542 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
83543 sizeof(*entry), 0, pc);
83544 if (!event) {
83545 - atomic_inc(&dropped_count);
83546 + atomic_inc_unchecked(&dropped_count);
83547 return;
83548 }
83549 entry = ring_buffer_event_data(event);
83550 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
83551 index bb922d9..2a54a257 100644
83552 --- a/kernel/trace/trace_output.c
83553 +++ b/kernel/trace/trace_output.c
83554 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
83555
83556 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
83557 if (!IS_ERR(p)) {
83558 - p = mangle_path(s->buffer + s->len, p, "\n");
83559 + p = mangle_path(s->buffer + s->len, p, "\n\\");
83560 if (p) {
83561 s->len = p - s->buffer;
83562 return 1;
83563 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
83564 goto out;
83565 }
83566
83567 + pax_open_kernel();
83568 if (event->funcs->trace == NULL)
83569 - event->funcs->trace = trace_nop_print;
83570 + *(void **)&event->funcs->trace = trace_nop_print;
83571 if (event->funcs->raw == NULL)
83572 - event->funcs->raw = trace_nop_print;
83573 + *(void **)&event->funcs->raw = trace_nop_print;
83574 if (event->funcs->hex == NULL)
83575 - event->funcs->hex = trace_nop_print;
83576 + *(void **)&event->funcs->hex = trace_nop_print;
83577 if (event->funcs->binary == NULL)
83578 - event->funcs->binary = trace_nop_print;
83579 + *(void **)&event->funcs->binary = trace_nop_print;
83580 + pax_close_kernel();
83581
83582 key = event->type & (EVENT_HASHSIZE - 1);
83583
83584 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
83585 index b20428c..4845a10 100644
83586 --- a/kernel/trace/trace_stack.c
83587 +++ b/kernel/trace/trace_stack.c
83588 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
83589 return;
83590
83591 /* we do not handle interrupt stacks yet */
83592 - if (!object_is_on_stack(stack))
83593 + if (!object_starts_on_stack(stack))
83594 return;
83595
83596 local_irq_save(flags);
83597 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
83598 index 9064b91..1f5d2f8 100644
83599 --- a/kernel/user_namespace.c
83600 +++ b/kernel/user_namespace.c
83601 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
83602 !kgid_has_mapping(parent_ns, group))
83603 return -EPERM;
83604
83605 +#ifdef CONFIG_GRKERNSEC
83606 + /*
83607 + * This doesn't really inspire confidence:
83608 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
83609 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
83610 + * Increases kernel attack surface in areas developers
83611 + * previously cared little about ("low importance due
83612 + * to requiring "root" capability")
83613 + * To be removed when this code receives *proper* review
83614 + */
83615 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
83616 + !capable(CAP_SETGID))
83617 + return -EPERM;
83618 +#endif
83619 +
83620 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
83621 if (!ns)
83622 return -ENOMEM;
83623 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
83624 if (atomic_read(&current->mm->mm_users) > 1)
83625 return -EINVAL;
83626
83627 - if (current->fs->users != 1)
83628 + if (atomic_read(&current->fs->users) != 1)
83629 return -EINVAL;
83630
83631 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
83632 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
83633 index 4f69f9a..7c6f8f8 100644
83634 --- a/kernel/utsname_sysctl.c
83635 +++ b/kernel/utsname_sysctl.c
83636 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
83637 static int proc_do_uts_string(ctl_table *table, int write,
83638 void __user *buffer, size_t *lenp, loff_t *ppos)
83639 {
83640 - struct ctl_table uts_table;
83641 + ctl_table_no_const uts_table;
83642 int r;
83643 memcpy(&uts_table, table, sizeof(uts_table));
83644 uts_table.data = get_uts(table, write);
83645 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
83646 index 05039e3..17490c7 100644
83647 --- a/kernel/watchdog.c
83648 +++ b/kernel/watchdog.c
83649 @@ -531,7 +531,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
83650 }
83651 #endif /* CONFIG_SYSCTL */
83652
83653 -static struct smp_hotplug_thread watchdog_threads = {
83654 +static struct smp_hotplug_thread watchdog_threads __read_only = {
83655 .store = &softlockup_watchdog,
83656 .thread_should_run = watchdog_should_run,
83657 .thread_fn = watchdog,
83658 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
83659 index 6f01921..139869b 100644
83660 --- a/kernel/workqueue.c
83661 +++ b/kernel/workqueue.c
83662 @@ -4596,7 +4596,7 @@ static void rebind_workers(struct worker_pool *pool)
83663 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
83664 worker_flags |= WORKER_REBOUND;
83665 worker_flags &= ~WORKER_UNBOUND;
83666 - ACCESS_ONCE(worker->flags) = worker_flags;
83667 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
83668 }
83669
83670 spin_unlock_irq(&pool->lock);
83671 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
83672 index 74fdc5c..3310593 100644
83673 --- a/lib/Kconfig.debug
83674 +++ b/lib/Kconfig.debug
83675 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
83676
83677 config DEBUG_LOCK_ALLOC
83678 bool "Lock debugging: detect incorrect freeing of live locks"
83679 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
83680 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
83681 select DEBUG_SPINLOCK
83682 select DEBUG_MUTEXES
83683 select LOCKDEP
83684 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
83685
83686 config PROVE_LOCKING
83687 bool "Lock debugging: prove locking correctness"
83688 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
83689 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
83690 select LOCKDEP
83691 select DEBUG_SPINLOCK
83692 select DEBUG_MUTEXES
83693 @@ -614,7 +614,7 @@ config LOCKDEP
83694
83695 config LOCK_STAT
83696 bool "Lock usage statistics"
83697 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
83698 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
83699 select LOCKDEP
83700 select DEBUG_SPINLOCK
83701 select DEBUG_MUTEXES
83702 @@ -1282,6 +1282,7 @@ config LATENCYTOP
83703 depends on DEBUG_KERNEL
83704 depends on STACKTRACE_SUPPORT
83705 depends on PROC_FS
83706 + depends on !GRKERNSEC_HIDESYM
83707 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
83708 select KALLSYMS
83709 select KALLSYMS_ALL
83710 @@ -1298,7 +1299,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
83711 config DEBUG_STRICT_USER_COPY_CHECKS
83712 bool "Strict user copy size checks"
83713 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
83714 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
83715 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
83716 help
83717 Enabling this option turns a certain set of sanity checks for user
83718 copy operations into compile time failures.
83719 @@ -1328,7 +1329,7 @@ config INTERVAL_TREE_TEST
83720
83721 config PROVIDE_OHCI1394_DMA_INIT
83722 bool "Remote debugging over FireWire early on boot"
83723 - depends on PCI && X86
83724 + depends on PCI && X86 && !GRKERNSEC
83725 help
83726 If you want to debug problems which hang or crash the kernel early
83727 on boot and the crashing machine has a FireWire port, you can use
83728 @@ -1357,7 +1358,7 @@ config PROVIDE_OHCI1394_DMA_INIT
83729
83730 config FIREWIRE_OHCI_REMOTE_DMA
83731 bool "Remote debugging over FireWire with firewire-ohci"
83732 - depends on FIREWIRE_OHCI
83733 + depends on FIREWIRE_OHCI && !GRKERNSEC
83734 help
83735 This option lets you use the FireWire bus for remote debugging
83736 with help of the firewire-ohci driver. It enables unfiltered
83737 diff --git a/lib/Makefile b/lib/Makefile
83738 index c55a037..fb46e3b 100644
83739 --- a/lib/Makefile
83740 +++ b/lib/Makefile
83741 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
83742
83743 obj-$(CONFIG_BTREE) += btree.o
83744 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
83745 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
83746 +obj-y += list_debug.o
83747 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
83748
83749 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
83750 diff --git a/lib/bitmap.c b/lib/bitmap.c
83751 index 06f7e4f..f3cf2b0 100644
83752 --- a/lib/bitmap.c
83753 +++ b/lib/bitmap.c
83754 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
83755 {
83756 int c, old_c, totaldigits, ndigits, nchunks, nbits;
83757 u32 chunk;
83758 - const char __user __force *ubuf = (const char __user __force *)buf;
83759 + const char __user *ubuf = (const char __force_user *)buf;
83760
83761 bitmap_zero(maskp, nmaskbits);
83762
83763 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
83764 {
83765 if (!access_ok(VERIFY_READ, ubuf, ulen))
83766 return -EFAULT;
83767 - return __bitmap_parse((const char __force *)ubuf,
83768 + return __bitmap_parse((const char __force_kernel *)ubuf,
83769 ulen, 1, maskp, nmaskbits);
83770
83771 }
83772 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
83773 {
83774 unsigned a, b;
83775 int c, old_c, totaldigits;
83776 - const char __user __force *ubuf = (const char __user __force *)buf;
83777 + const char __user *ubuf = (const char __force_user *)buf;
83778 int exp_digit, in_range;
83779
83780 totaldigits = c = 0;
83781 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
83782 {
83783 if (!access_ok(VERIFY_READ, ubuf, ulen))
83784 return -EFAULT;
83785 - return __bitmap_parselist((const char __force *)ubuf,
83786 + return __bitmap_parselist((const char __force_kernel *)ubuf,
83787 ulen, 1, maskp, nmaskbits);
83788 }
83789 EXPORT_SYMBOL(bitmap_parselist_user);
83790 diff --git a/lib/bug.c b/lib/bug.c
83791 index 1686034..a9c00c8 100644
83792 --- a/lib/bug.c
83793 +++ b/lib/bug.c
83794 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
83795 return BUG_TRAP_TYPE_NONE;
83796
83797 bug = find_bug(bugaddr);
83798 + if (!bug)
83799 + return BUG_TRAP_TYPE_NONE;
83800
83801 file = NULL;
83802 line = 0;
83803 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
83804 index 37061ed..da83f48 100644
83805 --- a/lib/debugobjects.c
83806 +++ b/lib/debugobjects.c
83807 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
83808 if (limit > 4)
83809 return;
83810
83811 - is_on_stack = object_is_on_stack(addr);
83812 + is_on_stack = object_starts_on_stack(addr);
83813 if (is_on_stack == onstack)
83814 return;
83815
83816 diff --git a/lib/devres.c b/lib/devres.c
83817 index 8235331..5881053 100644
83818 --- a/lib/devres.c
83819 +++ b/lib/devres.c
83820 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
83821 void devm_iounmap(struct device *dev, void __iomem *addr)
83822 {
83823 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
83824 - (void *)addr));
83825 + (void __force *)addr));
83826 iounmap(addr);
83827 }
83828 EXPORT_SYMBOL(devm_iounmap);
83829 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
83830 {
83831 ioport_unmap(addr);
83832 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
83833 - devm_ioport_map_match, (void *)addr));
83834 + devm_ioport_map_match, (void __force *)addr));
83835 }
83836 EXPORT_SYMBOL(devm_ioport_unmap);
83837 #endif /* CONFIG_HAS_IOPORT */
83838 diff --git a/lib/div64.c b/lib/div64.c
83839 index a163b6c..9618fa5 100644
83840 --- a/lib/div64.c
83841 +++ b/lib/div64.c
83842 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
83843 EXPORT_SYMBOL(__div64_32);
83844
83845 #ifndef div_s64_rem
83846 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
83847 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
83848 {
83849 u64 quotient;
83850
83851 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
83852 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
83853 */
83854 #ifndef div64_u64
83855 -u64 div64_u64(u64 dividend, u64 divisor)
83856 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
83857 {
83858 u32 high = divisor >> 32;
83859 u64 quot;
83860 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
83861 index d87a17a..ac0d79a 100644
83862 --- a/lib/dma-debug.c
83863 +++ b/lib/dma-debug.c
83864 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
83865
83866 void dma_debug_add_bus(struct bus_type *bus)
83867 {
83868 - struct notifier_block *nb;
83869 + notifier_block_no_const *nb;
83870
83871 if (global_disable)
83872 return;
83873 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
83874
83875 static void check_for_stack(struct device *dev, void *addr)
83876 {
83877 - if (object_is_on_stack(addr))
83878 + if (object_starts_on_stack(addr))
83879 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
83880 "stack [addr=%p]\n", addr);
83881 }
83882 diff --git a/lib/inflate.c b/lib/inflate.c
83883 index 013a761..c28f3fc 100644
83884 --- a/lib/inflate.c
83885 +++ b/lib/inflate.c
83886 @@ -269,7 +269,7 @@ static void free(void *where)
83887 malloc_ptr = free_mem_ptr;
83888 }
83889 #else
83890 -#define malloc(a) kmalloc(a, GFP_KERNEL)
83891 +#define malloc(a) kmalloc((a), GFP_KERNEL)
83892 #define free(a) kfree(a)
83893 #endif
83894
83895 diff --git a/lib/ioremap.c b/lib/ioremap.c
83896 index 0c9216c..863bd89 100644
83897 --- a/lib/ioremap.c
83898 +++ b/lib/ioremap.c
83899 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
83900 unsigned long next;
83901
83902 phys_addr -= addr;
83903 - pmd = pmd_alloc(&init_mm, pud, addr);
83904 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
83905 if (!pmd)
83906 return -ENOMEM;
83907 do {
83908 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
83909 unsigned long next;
83910
83911 phys_addr -= addr;
83912 - pud = pud_alloc(&init_mm, pgd, addr);
83913 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
83914 if (!pud)
83915 return -ENOMEM;
83916 do {
83917 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
83918 index bd2bea9..6b3c95e 100644
83919 --- a/lib/is_single_threaded.c
83920 +++ b/lib/is_single_threaded.c
83921 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
83922 struct task_struct *p, *t;
83923 bool ret;
83924
83925 + if (!mm)
83926 + return true;
83927 +
83928 if (atomic_read(&task->signal->live) != 1)
83929 return false;
83930
83931 diff --git a/lib/kobject.c b/lib/kobject.c
83932 index b7e29a6..2f3ca75 100644
83933 --- a/lib/kobject.c
83934 +++ b/lib/kobject.c
83935 @@ -805,7 +805,7 @@ static struct kset *kset_create(const char *name,
83936 kset = kzalloc(sizeof(*kset), GFP_KERNEL);
83937 if (!kset)
83938 return NULL;
83939 - retval = kobject_set_name(&kset->kobj, name);
83940 + retval = kobject_set_name(&kset->kobj, "%s", name);
83941 if (retval) {
83942 kfree(kset);
83943 return NULL;
83944 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
83945
83946
83947 static DEFINE_SPINLOCK(kobj_ns_type_lock);
83948 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
83949 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
83950
83951 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
83952 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
83953 {
83954 enum kobj_ns_type type = ops->type;
83955 int error;
83956 diff --git a/lib/list_debug.c b/lib/list_debug.c
83957 index c24c2f7..06e070b 100644
83958 --- a/lib/list_debug.c
83959 +++ b/lib/list_debug.c
83960 @@ -11,7 +11,9 @@
83961 #include <linux/bug.h>
83962 #include <linux/kernel.h>
83963 #include <linux/rculist.h>
83964 +#include <linux/mm.h>
83965
83966 +#ifdef CONFIG_DEBUG_LIST
83967 /*
83968 * Insert a new entry between two known consecutive entries.
83969 *
83970 @@ -19,21 +21,32 @@
83971 * the prev/next entries already!
83972 */
83973
83974 -void __list_add(struct list_head *new,
83975 - struct list_head *prev,
83976 - struct list_head *next)
83977 +static bool __list_add_debug(struct list_head *new,
83978 + struct list_head *prev,
83979 + struct list_head *next)
83980 {
83981 - WARN(next->prev != prev,
83982 + if (WARN(next->prev != prev,
83983 "list_add corruption. next->prev should be "
83984 "prev (%p), but was %p. (next=%p).\n",
83985 - prev, next->prev, next);
83986 - WARN(prev->next != next,
83987 + prev, next->prev, next) ||
83988 + WARN(prev->next != next,
83989 "list_add corruption. prev->next should be "
83990 "next (%p), but was %p. (prev=%p).\n",
83991 - next, prev->next, prev);
83992 - WARN(new == prev || new == next,
83993 - "list_add double add: new=%p, prev=%p, next=%p.\n",
83994 - new, prev, next);
83995 + next, prev->next, prev) ||
83996 + WARN(new == prev || new == next,
83997 + "list_add double add: new=%p, prev=%p, next=%p.\n",
83998 + new, prev, next))
83999 + return false;
84000 + return true;
84001 +}
84002 +
84003 +void __list_add(struct list_head *new,
84004 + struct list_head *prev,
84005 + struct list_head *next)
84006 +{
84007 + if (!__list_add_debug(new, prev, next))
84008 + return;
84009 +
84010 next->prev = new;
84011 new->next = next;
84012 new->prev = prev;
84013 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
84014 }
84015 EXPORT_SYMBOL(__list_add);
84016
84017 -void __list_del_entry(struct list_head *entry)
84018 +static bool __list_del_entry_debug(struct list_head *entry)
84019 {
84020 struct list_head *prev, *next;
84021
84022 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
84023 WARN(next->prev != entry,
84024 "list_del corruption. next->prev should be %p, "
84025 "but was %p\n", entry, next->prev))
84026 + return false;
84027 + return true;
84028 +}
84029 +
84030 +void __list_del_entry(struct list_head *entry)
84031 +{
84032 + if (!__list_del_entry_debug(entry))
84033 return;
84034
84035 - __list_del(prev, next);
84036 + __list_del(entry->prev, entry->next);
84037 }
84038 EXPORT_SYMBOL(__list_del_entry);
84039
84040 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
84041 void __list_add_rcu(struct list_head *new,
84042 struct list_head *prev, struct list_head *next)
84043 {
84044 - WARN(next->prev != prev,
84045 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
84046 - prev, next->prev, next);
84047 - WARN(prev->next != next,
84048 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
84049 - next, prev->next, prev);
84050 + if (!__list_add_debug(new, prev, next))
84051 + return;
84052 +
84053 new->next = next;
84054 new->prev = prev;
84055 rcu_assign_pointer(list_next_rcu(prev), new);
84056 next->prev = new;
84057 }
84058 EXPORT_SYMBOL(__list_add_rcu);
84059 +#endif
84060 +
84061 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
84062 +{
84063 +#ifdef CONFIG_DEBUG_LIST
84064 + if (!__list_add_debug(new, prev, next))
84065 + return;
84066 +#endif
84067 +
84068 + pax_open_kernel();
84069 + next->prev = new;
84070 + new->next = next;
84071 + new->prev = prev;
84072 + prev->next = new;
84073 + pax_close_kernel();
84074 +}
84075 +EXPORT_SYMBOL(__pax_list_add);
84076 +
84077 +void pax_list_del(struct list_head *entry)
84078 +{
84079 +#ifdef CONFIG_DEBUG_LIST
84080 + if (!__list_del_entry_debug(entry))
84081 + return;
84082 +#endif
84083 +
84084 + pax_open_kernel();
84085 + __list_del(entry->prev, entry->next);
84086 + entry->next = LIST_POISON1;
84087 + entry->prev = LIST_POISON2;
84088 + pax_close_kernel();
84089 +}
84090 +EXPORT_SYMBOL(pax_list_del);
84091 +
84092 +void pax_list_del_init(struct list_head *entry)
84093 +{
84094 + pax_open_kernel();
84095 + __list_del(entry->prev, entry->next);
84096 + INIT_LIST_HEAD(entry);
84097 + pax_close_kernel();
84098 +}
84099 +EXPORT_SYMBOL(pax_list_del_init);
84100 +
84101 +void __pax_list_add_rcu(struct list_head *new,
84102 + struct list_head *prev, struct list_head *next)
84103 +{
84104 +#ifdef CONFIG_DEBUG_LIST
84105 + if (!__list_add_debug(new, prev, next))
84106 + return;
84107 +#endif
84108 +
84109 + pax_open_kernel();
84110 + new->next = next;
84111 + new->prev = prev;
84112 + rcu_assign_pointer(list_next_rcu(prev), new);
84113 + next->prev = new;
84114 + pax_close_kernel();
84115 +}
84116 +EXPORT_SYMBOL(__pax_list_add_rcu);
84117 +
84118 +void pax_list_del_rcu(struct list_head *entry)
84119 +{
84120 +#ifdef CONFIG_DEBUG_LIST
84121 + if (!__list_del_entry_debug(entry))
84122 + return;
84123 +#endif
84124 +
84125 + pax_open_kernel();
84126 + __list_del(entry->prev, entry->next);
84127 + entry->next = LIST_POISON1;
84128 + entry->prev = LIST_POISON2;
84129 + pax_close_kernel();
84130 +}
84131 +EXPORT_SYMBOL(pax_list_del_rcu);
84132 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
84133 index e796429..6e38f9f 100644
84134 --- a/lib/radix-tree.c
84135 +++ b/lib/radix-tree.c
84136 @@ -92,7 +92,7 @@ struct radix_tree_preload {
84137 int nr;
84138 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
84139 };
84140 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
84141 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
84142
84143 static inline void *ptr_to_indirect(void *ptr)
84144 {
84145 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
84146 index bb2b201..46abaf9 100644
84147 --- a/lib/strncpy_from_user.c
84148 +++ b/lib/strncpy_from_user.c
84149 @@ -21,7 +21,7 @@
84150 */
84151 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
84152 {
84153 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
84154 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
84155 long res = 0;
84156
84157 /*
84158 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
84159 index a28df52..3d55877 100644
84160 --- a/lib/strnlen_user.c
84161 +++ b/lib/strnlen_user.c
84162 @@ -26,7 +26,7 @@
84163 */
84164 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
84165 {
84166 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
84167 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
84168 long align, res = 0;
84169 unsigned long c;
84170
84171 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
84172 index d23762e..e21eab2 100644
84173 --- a/lib/swiotlb.c
84174 +++ b/lib/swiotlb.c
84175 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
84176
84177 void
84178 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
84179 - dma_addr_t dev_addr)
84180 + dma_addr_t dev_addr, struct dma_attrs *attrs)
84181 {
84182 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
84183
84184 diff --git a/lib/usercopy.c b/lib/usercopy.c
84185 index 4f5b1dd..7cab418 100644
84186 --- a/lib/usercopy.c
84187 +++ b/lib/usercopy.c
84188 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
84189 WARN(1, "Buffer overflow detected!\n");
84190 }
84191 EXPORT_SYMBOL(copy_from_user_overflow);
84192 +
84193 +void copy_to_user_overflow(void)
84194 +{
84195 + WARN(1, "Buffer overflow detected!\n");
84196 +}
84197 +EXPORT_SYMBOL(copy_to_user_overflow);
84198 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
84199 index e149c64..24aa71a 100644
84200 --- a/lib/vsprintf.c
84201 +++ b/lib/vsprintf.c
84202 @@ -16,6 +16,9 @@
84203 * - scnprintf and vscnprintf
84204 */
84205
84206 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84207 +#define __INCLUDED_BY_HIDESYM 1
84208 +#endif
84209 #include <stdarg.h>
84210 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
84211 #include <linux/types.h>
84212 @@ -981,7 +984,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
84213 return number(buf, end, *(const netdev_features_t *)addr, spec);
84214 }
84215
84216 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84217 +int kptr_restrict __read_mostly = 2;
84218 +#else
84219 int kptr_restrict __read_mostly;
84220 +#endif
84221
84222 /*
84223 * Show a '%p' thing. A kernel extension is that the '%p' is followed
84224 @@ -994,6 +1001,7 @@ int kptr_restrict __read_mostly;
84225 * - 'f' For simple symbolic function names without offset
84226 * - 'S' For symbolic direct pointers with offset
84227 * - 's' For symbolic direct pointers without offset
84228 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
84229 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
84230 * - 'B' For backtraced symbolic direct pointers with offset
84231 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
84232 @@ -1052,12 +1060,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
84233
84234 if (!ptr && *fmt != 'K') {
84235 /*
84236 - * Print (null) with the same width as a pointer so it makes
84237 + * Print (nil) with the same width as a pointer so it makes
84238 * tabular output look nice.
84239 */
84240 if (spec.field_width == -1)
84241 spec.field_width = default_width;
84242 - return string(buf, end, "(null)", spec);
84243 + return string(buf, end, "(nil)", spec);
84244 }
84245
84246 switch (*fmt) {
84247 @@ -1067,6 +1075,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
84248 /* Fallthrough */
84249 case 'S':
84250 case 's':
84251 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84252 + break;
84253 +#else
84254 + return symbol_string(buf, end, ptr, spec, fmt);
84255 +#endif
84256 + case 'A':
84257 case 'B':
84258 return symbol_string(buf, end, ptr, spec, fmt);
84259 case 'R':
84260 @@ -1107,6 +1121,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
84261 va_end(va);
84262 return buf;
84263 }
84264 + case 'P':
84265 + break;
84266 case 'K':
84267 /*
84268 * %pK cannot be used in IRQ context because its test
84269 @@ -1136,6 +1152,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
84270 return number(buf, end,
84271 (unsigned long long) *((phys_addr_t *)ptr), spec);
84272 }
84273 +
84274 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84275 + /* 'P' = approved pointers to copy to userland,
84276 + as in the /proc/kallsyms case, as we make it display nothing
84277 + for non-root users, and the real contents for root users
84278 + Also ignore 'K' pointers, since we force their NULLing for non-root users
84279 + above
84280 + */
84281 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
84282 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
84283 + dump_stack();
84284 + ptr = NULL;
84285 + }
84286 +#endif
84287 +
84288 spec.flags |= SMALL;
84289 if (spec.field_width == -1) {
84290 spec.field_width = default_width;
84291 @@ -1857,11 +1888,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
84292 typeof(type) value; \
84293 if (sizeof(type) == 8) { \
84294 args = PTR_ALIGN(args, sizeof(u32)); \
84295 - *(u32 *)&value = *(u32 *)args; \
84296 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
84297 + *(u32 *)&value = *(const u32 *)args; \
84298 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
84299 } else { \
84300 args = PTR_ALIGN(args, sizeof(type)); \
84301 - value = *(typeof(type) *)args; \
84302 + value = *(const typeof(type) *)args; \
84303 } \
84304 args += sizeof(type); \
84305 value; \
84306 @@ -1924,7 +1955,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
84307 case FORMAT_TYPE_STR: {
84308 const char *str_arg = args;
84309 args += strlen(str_arg) + 1;
84310 - str = string(str, end, (char *)str_arg, spec);
84311 + str = string(str, end, str_arg, spec);
84312 break;
84313 }
84314
84315 diff --git a/localversion-grsec b/localversion-grsec
84316 new file mode 100644
84317 index 0000000..7cd6065
84318 --- /dev/null
84319 +++ b/localversion-grsec
84320 @@ -0,0 +1 @@
84321 +-grsec
84322 diff --git a/mm/Kconfig b/mm/Kconfig
84323 index e742d06..c56fdd8 100644
84324 --- a/mm/Kconfig
84325 +++ b/mm/Kconfig
84326 @@ -317,10 +317,10 @@ config KSM
84327 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
84328
84329 config DEFAULT_MMAP_MIN_ADDR
84330 - int "Low address space to protect from user allocation"
84331 + int "Low address space to protect from user allocation"
84332 depends on MMU
84333 - default 4096
84334 - help
84335 + default 65536
84336 + help
84337 This is the portion of low virtual memory which should be protected
84338 from userspace allocation. Keeping a user from writing to low pages
84339 can help reduce the impact of kernel NULL pointer bugs.
84340 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
84341
84342 config HWPOISON_INJECT
84343 tristate "HWPoison pages injector"
84344 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
84345 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
84346 select PROC_PAGE_MONITOR
84347
84348 config NOMMU_INITIAL_TRIM_EXCESS
84349 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
84350 index 5025174..9fc1c5c 100644
84351 --- a/mm/backing-dev.c
84352 +++ b/mm/backing-dev.c
84353 @@ -515,7 +515,6 @@ EXPORT_SYMBOL(bdi_destroy);
84354 int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
84355 unsigned int cap)
84356 {
84357 - char tmp[32];
84358 int err;
84359
84360 bdi->name = name;
84361 @@ -524,8 +523,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
84362 if (err)
84363 return err;
84364
84365 - sprintf(tmp, "%.28s%s", name, "-%d");
84366 - err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
84367 + err = bdi_register(bdi, NULL, "%.28s-%ld", name, atomic_long_inc_return(&bdi_seq));
84368 if (err) {
84369 bdi_destroy(bdi);
84370 return err;
84371 diff --git a/mm/filemap.c b/mm/filemap.c
84372 index 7905fe7..e60faa8 100644
84373 --- a/mm/filemap.c
84374 +++ b/mm/filemap.c
84375 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
84376 struct address_space *mapping = file->f_mapping;
84377
84378 if (!mapping->a_ops->readpage)
84379 - return -ENOEXEC;
84380 + return -ENODEV;
84381 file_accessed(file);
84382 vma->vm_ops = &generic_file_vm_ops;
84383 return 0;
84384 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
84385 *pos = i_size_read(inode);
84386
84387 if (limit != RLIM_INFINITY) {
84388 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
84389 if (*pos >= limit) {
84390 send_sig(SIGXFSZ, current, 0);
84391 return -EFBIG;
84392 diff --git a/mm/fremap.c b/mm/fremap.c
84393 index 87da359..3f41cb1 100644
84394 --- a/mm/fremap.c
84395 +++ b/mm/fremap.c
84396 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
84397 retry:
84398 vma = find_vma(mm, start);
84399
84400 +#ifdef CONFIG_PAX_SEGMEXEC
84401 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
84402 + goto out;
84403 +#endif
84404 +
84405 /*
84406 * Make sure the vma is shared, that it supports prefaulting,
84407 * and that the remapped range is valid and fully within
84408 diff --git a/mm/highmem.c b/mm/highmem.c
84409 index b32b70c..e512eb0 100644
84410 --- a/mm/highmem.c
84411 +++ b/mm/highmem.c
84412 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
84413 * So no dangers, even with speculative execution.
84414 */
84415 page = pte_page(pkmap_page_table[i]);
84416 + pax_open_kernel();
84417 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
84418 -
84419 + pax_close_kernel();
84420 set_page_address(page, NULL);
84421 need_flush = 1;
84422 }
84423 @@ -198,9 +199,11 @@ start:
84424 }
84425 }
84426 vaddr = PKMAP_ADDR(last_pkmap_nr);
84427 +
84428 + pax_open_kernel();
84429 set_pte_at(&init_mm, vaddr,
84430 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
84431 -
84432 + pax_close_kernel();
84433 pkmap_count[last_pkmap_nr] = 1;
84434 set_page_address(page, (void *)vaddr);
84435
84436 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
84437 index 5cf99bf..5c01c2f 100644
84438 --- a/mm/hugetlb.c
84439 +++ b/mm/hugetlb.c
84440 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
84441 struct hstate *h = &default_hstate;
84442 unsigned long tmp;
84443 int ret;
84444 + ctl_table_no_const hugetlb_table;
84445
84446 tmp = h->max_huge_pages;
84447
84448 if (write && h->order >= MAX_ORDER)
84449 return -EINVAL;
84450
84451 - table->data = &tmp;
84452 - table->maxlen = sizeof(unsigned long);
84453 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
84454 + hugetlb_table = *table;
84455 + hugetlb_table.data = &tmp;
84456 + hugetlb_table.maxlen = sizeof(unsigned long);
84457 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
84458 if (ret)
84459 goto out;
84460
84461 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
84462 struct hstate *h = &default_hstate;
84463 unsigned long tmp;
84464 int ret;
84465 + ctl_table_no_const hugetlb_table;
84466
84467 tmp = h->nr_overcommit_huge_pages;
84468
84469 if (write && h->order >= MAX_ORDER)
84470 return -EINVAL;
84471
84472 - table->data = &tmp;
84473 - table->maxlen = sizeof(unsigned long);
84474 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
84475 + hugetlb_table = *table;
84476 + hugetlb_table.data = &tmp;
84477 + hugetlb_table.maxlen = sizeof(unsigned long);
84478 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
84479 if (ret)
84480 goto out;
84481
84482 @@ -2490,7 +2494,7 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
84483
84484 mm = vma->vm_mm;
84485
84486 - tlb_gather_mmu(&tlb, mm, 0);
84487 + tlb_gather_mmu(&tlb, mm, start, end);
84488 __unmap_hugepage_range(&tlb, vma, start, end, ref_page);
84489 tlb_finish_mmu(&tlb, start, end);
84490 }
84491 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
84492 return 1;
84493 }
84494
84495 +#ifdef CONFIG_PAX_SEGMEXEC
84496 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
84497 +{
84498 + struct mm_struct *mm = vma->vm_mm;
84499 + struct vm_area_struct *vma_m;
84500 + unsigned long address_m;
84501 + pte_t *ptep_m;
84502 +
84503 + vma_m = pax_find_mirror_vma(vma);
84504 + if (!vma_m)
84505 + return;
84506 +
84507 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
84508 + address_m = address + SEGMEXEC_TASK_SIZE;
84509 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
84510 + get_page(page_m);
84511 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
84512 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
84513 +}
84514 +#endif
84515 +
84516 /*
84517 * Hugetlb_cow() should be called with page lock of the original hugepage held.
84518 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
84519 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
84520 make_huge_pte(vma, new_page, 1));
84521 page_remove_rmap(old_page);
84522 hugepage_add_new_anon_rmap(new_page, vma, address);
84523 +
84524 +#ifdef CONFIG_PAX_SEGMEXEC
84525 + pax_mirror_huge_pte(vma, address, new_page);
84526 +#endif
84527 +
84528 /* Make the old page be freed below */
84529 new_page = old_page;
84530 }
84531 @@ -2821,6 +2851,10 @@ retry:
84532 && (vma->vm_flags & VM_SHARED)));
84533 set_huge_pte_at(mm, address, ptep, new_pte);
84534
84535 +#ifdef CONFIG_PAX_SEGMEXEC
84536 + pax_mirror_huge_pte(vma, address, page);
84537 +#endif
84538 +
84539 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
84540 /* Optimization, do the COW without a second fault */
84541 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
84542 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
84543 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
84544 struct hstate *h = hstate_vma(vma);
84545
84546 +#ifdef CONFIG_PAX_SEGMEXEC
84547 + struct vm_area_struct *vma_m;
84548 +#endif
84549 +
84550 address &= huge_page_mask(h);
84551
84552 ptep = huge_pte_offset(mm, address);
84553 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
84554 VM_FAULT_SET_HINDEX(hstate_index(h));
84555 }
84556
84557 +#ifdef CONFIG_PAX_SEGMEXEC
84558 + vma_m = pax_find_mirror_vma(vma);
84559 + if (vma_m) {
84560 + unsigned long address_m;
84561 +
84562 + if (vma->vm_start > vma_m->vm_start) {
84563 + address_m = address;
84564 + address -= SEGMEXEC_TASK_SIZE;
84565 + vma = vma_m;
84566 + h = hstate_vma(vma);
84567 + } else
84568 + address_m = address + SEGMEXEC_TASK_SIZE;
84569 +
84570 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
84571 + return VM_FAULT_OOM;
84572 + address_m &= HPAGE_MASK;
84573 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
84574 + }
84575 +#endif
84576 +
84577 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
84578 if (!ptep)
84579 return VM_FAULT_OOM;
84580 diff --git a/mm/internal.h b/mm/internal.h
84581 index 8562de0..92b2073 100644
84582 --- a/mm/internal.h
84583 +++ b/mm/internal.h
84584 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
84585 * in mm/page_alloc.c
84586 */
84587 extern void __free_pages_bootmem(struct page *page, unsigned int order);
84588 +extern void free_compound_page(struct page *page);
84589 extern void prep_compound_page(struct page *page, unsigned long order);
84590 #ifdef CONFIG_MEMORY_FAILURE
84591 extern bool is_free_buddy_page(struct page *page);
84592 @@ -355,7 +356,7 @@ extern u32 hwpoison_filter_enable;
84593
84594 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
84595 unsigned long, unsigned long,
84596 - unsigned long, unsigned long);
84597 + unsigned long, unsigned long) __intentional_overflow(-1);
84598
84599 extern void set_pageblock_order(void);
84600 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
84601 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
84602 index c8d7f31..2dbeffd 100644
84603 --- a/mm/kmemleak.c
84604 +++ b/mm/kmemleak.c
84605 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
84606
84607 for (i = 0; i < object->trace_len; i++) {
84608 void *ptr = (void *)object->trace[i];
84609 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
84610 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
84611 }
84612 }
84613
84614 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
84615 return -ENOMEM;
84616 }
84617
84618 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
84619 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
84620 &kmemleak_fops);
84621 if (!dentry)
84622 pr_warning("Failed to create the debugfs kmemleak file\n");
84623 diff --git a/mm/maccess.c b/mm/maccess.c
84624 index d53adf9..03a24bf 100644
84625 --- a/mm/maccess.c
84626 +++ b/mm/maccess.c
84627 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
84628 set_fs(KERNEL_DS);
84629 pagefault_disable();
84630 ret = __copy_from_user_inatomic(dst,
84631 - (__force const void __user *)src, size);
84632 + (const void __force_user *)src, size);
84633 pagefault_enable();
84634 set_fs(old_fs);
84635
84636 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
84637
84638 set_fs(KERNEL_DS);
84639 pagefault_disable();
84640 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
84641 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
84642 pagefault_enable();
84643 set_fs(old_fs);
84644
84645 diff --git a/mm/madvise.c b/mm/madvise.c
84646 index 7055883..aafb1ed 100644
84647 --- a/mm/madvise.c
84648 +++ b/mm/madvise.c
84649 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
84650 pgoff_t pgoff;
84651 unsigned long new_flags = vma->vm_flags;
84652
84653 +#ifdef CONFIG_PAX_SEGMEXEC
84654 + struct vm_area_struct *vma_m;
84655 +#endif
84656 +
84657 switch (behavior) {
84658 case MADV_NORMAL:
84659 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
84660 @@ -126,6 +130,13 @@ success:
84661 /*
84662 * vm_flags is protected by the mmap_sem held in write mode.
84663 */
84664 +
84665 +#ifdef CONFIG_PAX_SEGMEXEC
84666 + vma_m = pax_find_mirror_vma(vma);
84667 + if (vma_m)
84668 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
84669 +#endif
84670 +
84671 vma->vm_flags = new_flags;
84672
84673 out:
84674 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
84675 struct vm_area_struct ** prev,
84676 unsigned long start, unsigned long end)
84677 {
84678 +
84679 +#ifdef CONFIG_PAX_SEGMEXEC
84680 + struct vm_area_struct *vma_m;
84681 +#endif
84682 +
84683 *prev = vma;
84684 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
84685 return -EINVAL;
84686 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
84687 zap_page_range(vma, start, end - start, &details);
84688 } else
84689 zap_page_range(vma, start, end - start, NULL);
84690 +
84691 +#ifdef CONFIG_PAX_SEGMEXEC
84692 + vma_m = pax_find_mirror_vma(vma);
84693 + if (vma_m) {
84694 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
84695 + struct zap_details details = {
84696 + .nonlinear_vma = vma_m,
84697 + .last_index = ULONG_MAX,
84698 + };
84699 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
84700 + } else
84701 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
84702 + }
84703 +#endif
84704 +
84705 return 0;
84706 }
84707
84708 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
84709 if (end < start)
84710 return error;
84711
84712 +#ifdef CONFIG_PAX_SEGMEXEC
84713 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
84714 + if (end > SEGMEXEC_TASK_SIZE)
84715 + return error;
84716 + } else
84717 +#endif
84718 +
84719 + if (end > TASK_SIZE)
84720 + return error;
84721 +
84722 error = 0;
84723 if (end == start)
84724 return error;
84725 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
84726 index ceb0c7f..b2b8e94 100644
84727 --- a/mm/memory-failure.c
84728 +++ b/mm/memory-failure.c
84729 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
84730
84731 int sysctl_memory_failure_recovery __read_mostly = 1;
84732
84733 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
84734 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
84735
84736 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
84737
84738 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
84739 pfn, t->comm, t->pid);
84740 si.si_signo = SIGBUS;
84741 si.si_errno = 0;
84742 - si.si_addr = (void *)addr;
84743 + si.si_addr = (void __user *)addr;
84744 #ifdef __ARCH_SI_TRAPNO
84745 si.si_trapno = trapno;
84746 #endif
84747 @@ -760,7 +760,7 @@ static struct page_state {
84748 unsigned long res;
84749 char *msg;
84750 int (*action)(struct page *p, unsigned long pfn);
84751 -} error_states[] = {
84752 +} __do_const error_states[] = {
84753 { reserved, reserved, "reserved kernel", me_kernel },
84754 /*
84755 * free pages are specially detected outside this table:
84756 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
84757 nr_pages = 1 << compound_order(hpage);
84758 else /* normal page or thp */
84759 nr_pages = 1;
84760 - atomic_long_add(nr_pages, &num_poisoned_pages);
84761 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
84762
84763 /*
84764 * We need/can do nothing about count=0 pages.
84765 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
84766 if (!PageHWPoison(hpage)
84767 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
84768 || (p != hpage && TestSetPageHWPoison(hpage))) {
84769 - atomic_long_sub(nr_pages, &num_poisoned_pages);
84770 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
84771 return 0;
84772 }
84773 set_page_hwpoison_huge_page(hpage);
84774 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
84775 }
84776 if (hwpoison_filter(p)) {
84777 if (TestClearPageHWPoison(p))
84778 - atomic_long_sub(nr_pages, &num_poisoned_pages);
84779 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
84780 unlock_page(hpage);
84781 put_page(hpage);
84782 return 0;
84783 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
84784 return 0;
84785 }
84786 if (TestClearPageHWPoison(p))
84787 - atomic_long_sub(nr_pages, &num_poisoned_pages);
84788 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
84789 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
84790 return 0;
84791 }
84792 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
84793 */
84794 if (TestClearPageHWPoison(page)) {
84795 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
84796 - atomic_long_sub(nr_pages, &num_poisoned_pages);
84797 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
84798 freeit = 1;
84799 if (PageHuge(page))
84800 clear_page_hwpoison_huge_page(page);
84801 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
84802 } else {
84803 set_page_hwpoison_huge_page(hpage);
84804 dequeue_hwpoisoned_huge_page(hpage);
84805 - atomic_long_add(1 << compound_trans_order(hpage),
84806 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
84807 &num_poisoned_pages);
84808 }
84809 /* keep elevated page count for bad page */
84810 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
84811 if (PageHuge(page)) {
84812 set_page_hwpoison_huge_page(hpage);
84813 dequeue_hwpoisoned_huge_page(hpage);
84814 - atomic_long_add(1 << compound_trans_order(hpage),
84815 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
84816 &num_poisoned_pages);
84817 } else {
84818 SetPageHWPoison(page);
84819 - atomic_long_inc(&num_poisoned_pages);
84820 + atomic_long_inc_unchecked(&num_poisoned_pages);
84821 }
84822 }
84823 /* keep elevated page count for bad page */
84824 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
84825 put_page(page);
84826 pr_info("soft_offline: %#lx: invalidated\n", pfn);
84827 SetPageHWPoison(page);
84828 - atomic_long_inc(&num_poisoned_pages);
84829 + atomic_long_inc_unchecked(&num_poisoned_pages);
84830 return 0;
84831 }
84832
84833 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
84834 ret = -EIO;
84835 } else {
84836 SetPageHWPoison(page);
84837 - atomic_long_inc(&num_poisoned_pages);
84838 + atomic_long_inc_unchecked(&num_poisoned_pages);
84839 }
84840 } else {
84841 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
84842 diff --git a/mm/memory.c b/mm/memory.c
84843 index 5e50800..7c0340f 100644
84844 --- a/mm/memory.c
84845 +++ b/mm/memory.c
84846 @@ -211,14 +211,15 @@ static int tlb_next_batch(struct mmu_gather *tlb)
84847 * tear-down from @mm. The @fullmm argument is used when @mm is without
84848 * users and we're going to destroy the full address space (exit/execve).
84849 */
84850 -void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm)
84851 +void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
84852 {
84853 tlb->mm = mm;
84854
84855 - tlb->fullmm = fullmm;
84856 + /* Is it from 0 to ~0? */
84857 + tlb->fullmm = !(start | (end+1));
84858 tlb->need_flush_all = 0;
84859 - tlb->start = -1UL;
84860 - tlb->end = 0;
84861 + tlb->start = start;
84862 + tlb->end = end;
84863 tlb->need_flush = 0;
84864 tlb->local.next = NULL;
84865 tlb->local.nr = 0;
84866 @@ -258,8 +259,6 @@ void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long e
84867 {
84868 struct mmu_gather_batch *batch, *next;
84869
84870 - tlb->start = start;
84871 - tlb->end = end;
84872 tlb_flush_mmu(tlb);
84873
84874 /* keep the page table cache within bounds */
84875 @@ -429,6 +428,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
84876 free_pte_range(tlb, pmd, addr);
84877 } while (pmd++, addr = next, addr != end);
84878
84879 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
84880 start &= PUD_MASK;
84881 if (start < floor)
84882 return;
84883 @@ -443,6 +443,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
84884 pmd = pmd_offset(pud, start);
84885 pud_clear(pud);
84886 pmd_free_tlb(tlb, pmd, start);
84887 +#endif
84888 +
84889 }
84890
84891 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
84892 @@ -462,6 +464,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
84893 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
84894 } while (pud++, addr = next, addr != end);
84895
84896 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
84897 start &= PGDIR_MASK;
84898 if (start < floor)
84899 return;
84900 @@ -476,6 +479,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
84901 pud = pud_offset(pgd, start);
84902 pgd_clear(pgd);
84903 pud_free_tlb(tlb, pud, start);
84904 +#endif
84905 +
84906 }
84907
84908 /*
84909 @@ -1101,7 +1106,6 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
84910 spinlock_t *ptl;
84911 pte_t *start_pte;
84912 pte_t *pte;
84913 - unsigned long range_start = addr;
84914
84915 again:
84916 init_rss_vec(rss);
84917 @@ -1204,17 +1208,25 @@ again:
84918 * and page-free while holding it.
84919 */
84920 if (force_flush) {
84921 + unsigned long old_end;
84922 +
84923 force_flush = 0;
84924
84925 -#ifdef HAVE_GENERIC_MMU_GATHER
84926 - tlb->start = range_start;
84927 + /*
84928 + * Flush the TLB just for the previous segment,
84929 + * then update the range to be the remaining
84930 + * TLB range.
84931 + */
84932 + old_end = tlb->end;
84933 tlb->end = addr;
84934 -#endif
84935 +
84936 tlb_flush_mmu(tlb);
84937 - if (addr != end) {
84938 - range_start = addr;
84939 +
84940 + tlb->start = addr;
84941 + tlb->end = old_end;
84942 +
84943 + if (addr != end)
84944 goto again;
84945 - }
84946 }
84947
84948 return addr;
84949 @@ -1399,7 +1411,7 @@ void zap_page_range(struct vm_area_struct *vma, unsigned long start,
84950 unsigned long end = start + size;
84951
84952 lru_add_drain();
84953 - tlb_gather_mmu(&tlb, mm, 0);
84954 + tlb_gather_mmu(&tlb, mm, start, end);
84955 update_hiwater_rss(mm);
84956 mmu_notifier_invalidate_range_start(mm, start, end);
84957 for ( ; vma && vma->vm_start < end; vma = vma->vm_next)
84958 @@ -1425,7 +1437,7 @@ static void zap_page_range_single(struct vm_area_struct *vma, unsigned long addr
84959 unsigned long end = address + size;
84960
84961 lru_add_drain();
84962 - tlb_gather_mmu(&tlb, mm, 0);
84963 + tlb_gather_mmu(&tlb, mm, address, end);
84964 update_hiwater_rss(mm);
84965 mmu_notifier_invalidate_range_start(mm, address, end);
84966 unmap_single_vma(&tlb, vma, address, end, details);
84967 @@ -1638,12 +1650,6 @@ no_page_table:
84968 return page;
84969 }
84970
84971 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
84972 -{
84973 - return stack_guard_page_start(vma, addr) ||
84974 - stack_guard_page_end(vma, addr+PAGE_SIZE);
84975 -}
84976 -
84977 /**
84978 * __get_user_pages() - pin user pages in memory
84979 * @tsk: task_struct of target task
84980 @@ -1730,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
84981
84982 i = 0;
84983
84984 - do {
84985 + while (nr_pages) {
84986 struct vm_area_struct *vma;
84987
84988 - vma = find_extend_vma(mm, start);
84989 + vma = find_vma(mm, start);
84990 if (!vma && in_gate_area(mm, start)) {
84991 unsigned long pg = start & PAGE_MASK;
84992 pgd_t *pgd;
84993 @@ -1782,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
84994 goto next_page;
84995 }
84996
84997 - if (!vma ||
84998 + if (!vma || start < vma->vm_start ||
84999 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
85000 !(vm_flags & vma->vm_flags))
85001 return i ? : -EFAULT;
85002 @@ -1811,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
85003 int ret;
85004 unsigned int fault_flags = 0;
85005
85006 - /* For mlock, just skip the stack guard page. */
85007 - if (foll_flags & FOLL_MLOCK) {
85008 - if (stack_guard_page(vma, start))
85009 - goto next_page;
85010 - }
85011 if (foll_flags & FOLL_WRITE)
85012 fault_flags |= FAULT_FLAG_WRITE;
85013 if (nonblocking)
85014 @@ -1895,7 +1896,7 @@ next_page:
85015 start += page_increm * PAGE_SIZE;
85016 nr_pages -= page_increm;
85017 } while (nr_pages && start < vma->vm_end);
85018 - } while (nr_pages);
85019 + }
85020 return i;
85021 }
85022 EXPORT_SYMBOL(__get_user_pages);
85023 @@ -2102,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
85024 page_add_file_rmap(page);
85025 set_pte_at(mm, addr, pte, mk_pte(page, prot));
85026
85027 +#ifdef CONFIG_PAX_SEGMEXEC
85028 + pax_mirror_file_pte(vma, addr, page, ptl);
85029 +#endif
85030 +
85031 retval = 0;
85032 pte_unmap_unlock(pte, ptl);
85033 return retval;
85034 @@ -2146,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
85035 if (!page_count(page))
85036 return -EINVAL;
85037 if (!(vma->vm_flags & VM_MIXEDMAP)) {
85038 +
85039 +#ifdef CONFIG_PAX_SEGMEXEC
85040 + struct vm_area_struct *vma_m;
85041 +#endif
85042 +
85043 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
85044 BUG_ON(vma->vm_flags & VM_PFNMAP);
85045 vma->vm_flags |= VM_MIXEDMAP;
85046 +
85047 +#ifdef CONFIG_PAX_SEGMEXEC
85048 + vma_m = pax_find_mirror_vma(vma);
85049 + if (vma_m)
85050 + vma_m->vm_flags |= VM_MIXEDMAP;
85051 +#endif
85052 +
85053 }
85054 return insert_page(vma, addr, page, vma->vm_page_prot);
85055 }
85056 @@ -2231,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
85057 unsigned long pfn)
85058 {
85059 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
85060 + BUG_ON(vma->vm_mirror);
85061
85062 if (addr < vma->vm_start || addr >= vma->vm_end)
85063 return -EFAULT;
85064 @@ -2478,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
85065
85066 BUG_ON(pud_huge(*pud));
85067
85068 - pmd = pmd_alloc(mm, pud, addr);
85069 + pmd = (mm == &init_mm) ?
85070 + pmd_alloc_kernel(mm, pud, addr) :
85071 + pmd_alloc(mm, pud, addr);
85072 if (!pmd)
85073 return -ENOMEM;
85074 do {
85075 @@ -2498,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
85076 unsigned long next;
85077 int err;
85078
85079 - pud = pud_alloc(mm, pgd, addr);
85080 + pud = (mm == &init_mm) ?
85081 + pud_alloc_kernel(mm, pgd, addr) :
85082 + pud_alloc(mm, pgd, addr);
85083 if (!pud)
85084 return -ENOMEM;
85085 do {
85086 @@ -2586,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
85087 copy_user_highpage(dst, src, va, vma);
85088 }
85089
85090 +#ifdef CONFIG_PAX_SEGMEXEC
85091 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
85092 +{
85093 + struct mm_struct *mm = vma->vm_mm;
85094 + spinlock_t *ptl;
85095 + pte_t *pte, entry;
85096 +
85097 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
85098 + entry = *pte;
85099 + if (!pte_present(entry)) {
85100 + if (!pte_none(entry)) {
85101 + BUG_ON(pte_file(entry));
85102 + free_swap_and_cache(pte_to_swp_entry(entry));
85103 + pte_clear_not_present_full(mm, address, pte, 0);
85104 + }
85105 + } else {
85106 + struct page *page;
85107 +
85108 + flush_cache_page(vma, address, pte_pfn(entry));
85109 + entry = ptep_clear_flush(vma, address, pte);
85110 + BUG_ON(pte_dirty(entry));
85111 + page = vm_normal_page(vma, address, entry);
85112 + if (page) {
85113 + update_hiwater_rss(mm);
85114 + if (PageAnon(page))
85115 + dec_mm_counter_fast(mm, MM_ANONPAGES);
85116 + else
85117 + dec_mm_counter_fast(mm, MM_FILEPAGES);
85118 + page_remove_rmap(page);
85119 + page_cache_release(page);
85120 + }
85121 + }
85122 + pte_unmap_unlock(pte, ptl);
85123 +}
85124 +
85125 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
85126 + *
85127 + * the ptl of the lower mapped page is held on entry and is not released on exit
85128 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
85129 + */
85130 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
85131 +{
85132 + struct mm_struct *mm = vma->vm_mm;
85133 + unsigned long address_m;
85134 + spinlock_t *ptl_m;
85135 + struct vm_area_struct *vma_m;
85136 + pmd_t *pmd_m;
85137 + pte_t *pte_m, entry_m;
85138 +
85139 + BUG_ON(!page_m || !PageAnon(page_m));
85140 +
85141 + vma_m = pax_find_mirror_vma(vma);
85142 + if (!vma_m)
85143 + return;
85144 +
85145 + BUG_ON(!PageLocked(page_m));
85146 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
85147 + address_m = address + SEGMEXEC_TASK_SIZE;
85148 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
85149 + pte_m = pte_offset_map(pmd_m, address_m);
85150 + ptl_m = pte_lockptr(mm, pmd_m);
85151 + if (ptl != ptl_m) {
85152 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
85153 + if (!pte_none(*pte_m))
85154 + goto out;
85155 + }
85156 +
85157 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
85158 + page_cache_get(page_m);
85159 + page_add_anon_rmap(page_m, vma_m, address_m);
85160 + inc_mm_counter_fast(mm, MM_ANONPAGES);
85161 + set_pte_at(mm, address_m, pte_m, entry_m);
85162 + update_mmu_cache(vma_m, address_m, pte_m);
85163 +out:
85164 + if (ptl != ptl_m)
85165 + spin_unlock(ptl_m);
85166 + pte_unmap(pte_m);
85167 + unlock_page(page_m);
85168 +}
85169 +
85170 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
85171 +{
85172 + struct mm_struct *mm = vma->vm_mm;
85173 + unsigned long address_m;
85174 + spinlock_t *ptl_m;
85175 + struct vm_area_struct *vma_m;
85176 + pmd_t *pmd_m;
85177 + pte_t *pte_m, entry_m;
85178 +
85179 + BUG_ON(!page_m || PageAnon(page_m));
85180 +
85181 + vma_m = pax_find_mirror_vma(vma);
85182 + if (!vma_m)
85183 + return;
85184 +
85185 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
85186 + address_m = address + SEGMEXEC_TASK_SIZE;
85187 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
85188 + pte_m = pte_offset_map(pmd_m, address_m);
85189 + ptl_m = pte_lockptr(mm, pmd_m);
85190 + if (ptl != ptl_m) {
85191 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
85192 + if (!pte_none(*pte_m))
85193 + goto out;
85194 + }
85195 +
85196 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
85197 + page_cache_get(page_m);
85198 + page_add_file_rmap(page_m);
85199 + inc_mm_counter_fast(mm, MM_FILEPAGES);
85200 + set_pte_at(mm, address_m, pte_m, entry_m);
85201 + update_mmu_cache(vma_m, address_m, pte_m);
85202 +out:
85203 + if (ptl != ptl_m)
85204 + spin_unlock(ptl_m);
85205 + pte_unmap(pte_m);
85206 +}
85207 +
85208 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
85209 +{
85210 + struct mm_struct *mm = vma->vm_mm;
85211 + unsigned long address_m;
85212 + spinlock_t *ptl_m;
85213 + struct vm_area_struct *vma_m;
85214 + pmd_t *pmd_m;
85215 + pte_t *pte_m, entry_m;
85216 +
85217 + vma_m = pax_find_mirror_vma(vma);
85218 + if (!vma_m)
85219 + return;
85220 +
85221 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
85222 + address_m = address + SEGMEXEC_TASK_SIZE;
85223 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
85224 + pte_m = pte_offset_map(pmd_m, address_m);
85225 + ptl_m = pte_lockptr(mm, pmd_m);
85226 + if (ptl != ptl_m) {
85227 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
85228 + if (!pte_none(*pte_m))
85229 + goto out;
85230 + }
85231 +
85232 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
85233 + set_pte_at(mm, address_m, pte_m, entry_m);
85234 +out:
85235 + if (ptl != ptl_m)
85236 + spin_unlock(ptl_m);
85237 + pte_unmap(pte_m);
85238 +}
85239 +
85240 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
85241 +{
85242 + struct page *page_m;
85243 + pte_t entry;
85244 +
85245 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
85246 + goto out;
85247 +
85248 + entry = *pte;
85249 + page_m = vm_normal_page(vma, address, entry);
85250 + if (!page_m)
85251 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
85252 + else if (PageAnon(page_m)) {
85253 + if (pax_find_mirror_vma(vma)) {
85254 + pte_unmap_unlock(pte, ptl);
85255 + lock_page(page_m);
85256 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
85257 + if (pte_same(entry, *pte))
85258 + pax_mirror_anon_pte(vma, address, page_m, ptl);
85259 + else
85260 + unlock_page(page_m);
85261 + }
85262 + } else
85263 + pax_mirror_file_pte(vma, address, page_m, ptl);
85264 +
85265 +out:
85266 + pte_unmap_unlock(pte, ptl);
85267 +}
85268 +#endif
85269 +
85270 /*
85271 * This routine handles present pages, when users try to write
85272 * to a shared page. It is done by copying the page to a new address
85273 @@ -2802,6 +3004,12 @@ gotten:
85274 */
85275 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
85276 if (likely(pte_same(*page_table, orig_pte))) {
85277 +
85278 +#ifdef CONFIG_PAX_SEGMEXEC
85279 + if (pax_find_mirror_vma(vma))
85280 + BUG_ON(!trylock_page(new_page));
85281 +#endif
85282 +
85283 if (old_page) {
85284 if (!PageAnon(old_page)) {
85285 dec_mm_counter_fast(mm, MM_FILEPAGES);
85286 @@ -2853,6 +3061,10 @@ gotten:
85287 page_remove_rmap(old_page);
85288 }
85289
85290 +#ifdef CONFIG_PAX_SEGMEXEC
85291 + pax_mirror_anon_pte(vma, address, new_page, ptl);
85292 +#endif
85293 +
85294 /* Free the old page.. */
85295 new_page = old_page;
85296 ret |= VM_FAULT_WRITE;
85297 @@ -3128,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
85298 swap_free(entry);
85299 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
85300 try_to_free_swap(page);
85301 +
85302 +#ifdef CONFIG_PAX_SEGMEXEC
85303 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
85304 +#endif
85305 +
85306 unlock_page(page);
85307 if (page != swapcache) {
85308 /*
85309 @@ -3151,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
85310
85311 /* No need to invalidate - it was non-present before */
85312 update_mmu_cache(vma, address, page_table);
85313 +
85314 +#ifdef CONFIG_PAX_SEGMEXEC
85315 + pax_mirror_anon_pte(vma, address, page, ptl);
85316 +#endif
85317 +
85318 unlock:
85319 pte_unmap_unlock(page_table, ptl);
85320 out:
85321 @@ -3170,40 +3392,6 @@ out_release:
85322 }
85323
85324 /*
85325 - * This is like a special single-page "expand_{down|up}wards()",
85326 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
85327 - * doesn't hit another vma.
85328 - */
85329 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
85330 -{
85331 - address &= PAGE_MASK;
85332 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
85333 - struct vm_area_struct *prev = vma->vm_prev;
85334 -
85335 - /*
85336 - * Is there a mapping abutting this one below?
85337 - *
85338 - * That's only ok if it's the same stack mapping
85339 - * that has gotten split..
85340 - */
85341 - if (prev && prev->vm_end == address)
85342 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
85343 -
85344 - expand_downwards(vma, address - PAGE_SIZE);
85345 - }
85346 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
85347 - struct vm_area_struct *next = vma->vm_next;
85348 -
85349 - /* As VM_GROWSDOWN but s/below/above/ */
85350 - if (next && next->vm_start == address + PAGE_SIZE)
85351 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
85352 -
85353 - expand_upwards(vma, address + PAGE_SIZE);
85354 - }
85355 - return 0;
85356 -}
85357 -
85358 -/*
85359 * We enter with non-exclusive mmap_sem (to exclude vma changes,
85360 * but allow concurrent faults), and pte mapped but not yet locked.
85361 * We return with mmap_sem still held, but pte unmapped and unlocked.
85362 @@ -3212,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
85363 unsigned long address, pte_t *page_table, pmd_t *pmd,
85364 unsigned int flags)
85365 {
85366 - struct page *page;
85367 + struct page *page = NULL;
85368 spinlock_t *ptl;
85369 pte_t entry;
85370
85371 - pte_unmap(page_table);
85372 -
85373 - /* Check if we need to add a guard page to the stack */
85374 - if (check_stack_guard_page(vma, address) < 0)
85375 - return VM_FAULT_SIGBUS;
85376 -
85377 - /* Use the zero-page for reads */
85378 if (!(flags & FAULT_FLAG_WRITE)) {
85379 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
85380 vma->vm_page_prot));
85381 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
85382 + ptl = pte_lockptr(mm, pmd);
85383 + spin_lock(ptl);
85384 if (!pte_none(*page_table))
85385 goto unlock;
85386 goto setpte;
85387 }
85388
85389 /* Allocate our own private page. */
85390 + pte_unmap(page_table);
85391 +
85392 if (unlikely(anon_vma_prepare(vma)))
85393 goto oom;
85394 page = alloc_zeroed_user_highpage_movable(vma, address);
85395 @@ -3256,6 +3440,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
85396 if (!pte_none(*page_table))
85397 goto release;
85398
85399 +#ifdef CONFIG_PAX_SEGMEXEC
85400 + if (pax_find_mirror_vma(vma))
85401 + BUG_ON(!trylock_page(page));
85402 +#endif
85403 +
85404 inc_mm_counter_fast(mm, MM_ANONPAGES);
85405 page_add_new_anon_rmap(page, vma, address);
85406 setpte:
85407 @@ -3263,6 +3452,12 @@ setpte:
85408
85409 /* No need to invalidate - it was non-present before */
85410 update_mmu_cache(vma, address, page_table);
85411 +
85412 +#ifdef CONFIG_PAX_SEGMEXEC
85413 + if (page)
85414 + pax_mirror_anon_pte(vma, address, page, ptl);
85415 +#endif
85416 +
85417 unlock:
85418 pte_unmap_unlock(page_table, ptl);
85419 return 0;
85420 @@ -3406,6 +3601,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85421 */
85422 /* Only go through if we didn't race with anybody else... */
85423 if (likely(pte_same(*page_table, orig_pte))) {
85424 +
85425 +#ifdef CONFIG_PAX_SEGMEXEC
85426 + if (anon && pax_find_mirror_vma(vma))
85427 + BUG_ON(!trylock_page(page));
85428 +#endif
85429 +
85430 flush_icache_page(vma, page);
85431 entry = mk_pte(page, vma->vm_page_prot);
85432 if (flags & FAULT_FLAG_WRITE)
85433 @@ -3425,6 +3626,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85434
85435 /* no need to invalidate: a not-present page won't be cached */
85436 update_mmu_cache(vma, address, page_table);
85437 +
85438 +#ifdef CONFIG_PAX_SEGMEXEC
85439 + if (anon)
85440 + pax_mirror_anon_pte(vma, address, page, ptl);
85441 + else
85442 + pax_mirror_file_pte(vma, address, page, ptl);
85443 +#endif
85444 +
85445 } else {
85446 if (cow_page)
85447 mem_cgroup_uncharge_page(cow_page);
85448 @@ -3746,6 +3955,12 @@ int handle_pte_fault(struct mm_struct *mm,
85449 if (flags & FAULT_FLAG_WRITE)
85450 flush_tlb_fix_spurious_fault(vma, address);
85451 }
85452 +
85453 +#ifdef CONFIG_PAX_SEGMEXEC
85454 + pax_mirror_pte(vma, address, pte, pmd, ptl);
85455 + return 0;
85456 +#endif
85457 +
85458 unlock:
85459 pte_unmap_unlock(pte, ptl);
85460 return 0;
85461 @@ -3762,6 +3977,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85462 pmd_t *pmd;
85463 pte_t *pte;
85464
85465 +#ifdef CONFIG_PAX_SEGMEXEC
85466 + struct vm_area_struct *vma_m;
85467 +#endif
85468 +
85469 __set_current_state(TASK_RUNNING);
85470
85471 count_vm_event(PGFAULT);
85472 @@ -3773,6 +3992,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85473 if (unlikely(is_vm_hugetlb_page(vma)))
85474 return hugetlb_fault(mm, vma, address, flags);
85475
85476 +#ifdef CONFIG_PAX_SEGMEXEC
85477 + vma_m = pax_find_mirror_vma(vma);
85478 + if (vma_m) {
85479 + unsigned long address_m;
85480 + pgd_t *pgd_m;
85481 + pud_t *pud_m;
85482 + pmd_t *pmd_m;
85483 +
85484 + if (vma->vm_start > vma_m->vm_start) {
85485 + address_m = address;
85486 + address -= SEGMEXEC_TASK_SIZE;
85487 + vma = vma_m;
85488 + } else
85489 + address_m = address + SEGMEXEC_TASK_SIZE;
85490 +
85491 + pgd_m = pgd_offset(mm, address_m);
85492 + pud_m = pud_alloc(mm, pgd_m, address_m);
85493 + if (!pud_m)
85494 + return VM_FAULT_OOM;
85495 + pmd_m = pmd_alloc(mm, pud_m, address_m);
85496 + if (!pmd_m)
85497 + return VM_FAULT_OOM;
85498 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
85499 + return VM_FAULT_OOM;
85500 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
85501 + }
85502 +#endif
85503 +
85504 retry:
85505 pgd = pgd_offset(mm, address);
85506 pud = pud_alloc(mm, pgd, address);
85507 @@ -3871,6 +4118,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
85508 spin_unlock(&mm->page_table_lock);
85509 return 0;
85510 }
85511 +
85512 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
85513 +{
85514 + pud_t *new = pud_alloc_one(mm, address);
85515 + if (!new)
85516 + return -ENOMEM;
85517 +
85518 + smp_wmb(); /* See comment in __pte_alloc */
85519 +
85520 + spin_lock(&mm->page_table_lock);
85521 + if (pgd_present(*pgd)) /* Another has populated it */
85522 + pud_free(mm, new);
85523 + else
85524 + pgd_populate_kernel(mm, pgd, new);
85525 + spin_unlock(&mm->page_table_lock);
85526 + return 0;
85527 +}
85528 #endif /* __PAGETABLE_PUD_FOLDED */
85529
85530 #ifndef __PAGETABLE_PMD_FOLDED
85531 @@ -3901,6 +4165,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
85532 spin_unlock(&mm->page_table_lock);
85533 return 0;
85534 }
85535 +
85536 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
85537 +{
85538 + pmd_t *new = pmd_alloc_one(mm, address);
85539 + if (!new)
85540 + return -ENOMEM;
85541 +
85542 + smp_wmb(); /* See comment in __pte_alloc */
85543 +
85544 + spin_lock(&mm->page_table_lock);
85545 +#ifndef __ARCH_HAS_4LEVEL_HACK
85546 + if (pud_present(*pud)) /* Another has populated it */
85547 + pmd_free(mm, new);
85548 + else
85549 + pud_populate_kernel(mm, pud, new);
85550 +#else
85551 + if (pgd_present(*pud)) /* Another has populated it */
85552 + pmd_free(mm, new);
85553 + else
85554 + pgd_populate_kernel(mm, pud, new);
85555 +#endif /* __ARCH_HAS_4LEVEL_HACK */
85556 + spin_unlock(&mm->page_table_lock);
85557 + return 0;
85558 +}
85559 #endif /* __PAGETABLE_PMD_FOLDED */
85560
85561 #if !defined(__HAVE_ARCH_GATE_AREA)
85562 @@ -3914,7 +4202,7 @@ static int __init gate_vma_init(void)
85563 gate_vma.vm_start = FIXADDR_USER_START;
85564 gate_vma.vm_end = FIXADDR_USER_END;
85565 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
85566 - gate_vma.vm_page_prot = __P101;
85567 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
85568
85569 return 0;
85570 }
85571 @@ -4048,8 +4336,8 @@ out:
85572 return ret;
85573 }
85574
85575 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
85576 - void *buf, int len, int write)
85577 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
85578 + void *buf, size_t len, int write)
85579 {
85580 resource_size_t phys_addr;
85581 unsigned long prot = 0;
85582 @@ -4074,8 +4362,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
85583 * Access another process' address space as given in mm. If non-NULL, use the
85584 * given task for page fault accounting.
85585 */
85586 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
85587 - unsigned long addr, void *buf, int len, int write)
85588 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
85589 + unsigned long addr, void *buf, size_t len, int write)
85590 {
85591 struct vm_area_struct *vma;
85592 void *old_buf = buf;
85593 @@ -4083,7 +4371,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
85594 down_read(&mm->mmap_sem);
85595 /* ignore errors, just check how much was successfully transferred */
85596 while (len) {
85597 - int bytes, ret, offset;
85598 + ssize_t bytes, ret, offset;
85599 void *maddr;
85600 struct page *page = NULL;
85601
85602 @@ -4142,8 +4430,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
85603 *
85604 * The caller must hold a reference on @mm.
85605 */
85606 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
85607 - void *buf, int len, int write)
85608 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
85609 + void *buf, size_t len, int write)
85610 {
85611 return __access_remote_vm(NULL, mm, addr, buf, len, write);
85612 }
85613 @@ -4153,11 +4441,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
85614 * Source/target buffer must be kernel space,
85615 * Do not walk the page table directly, use get_user_pages
85616 */
85617 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
85618 - void *buf, int len, int write)
85619 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
85620 + void *buf, size_t len, int write)
85621 {
85622 struct mm_struct *mm;
85623 - int ret;
85624 + ssize_t ret;
85625
85626 mm = get_task_mm(tsk);
85627 if (!mm)
85628 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
85629 index 4baf12e..5497066 100644
85630 --- a/mm/mempolicy.c
85631 +++ b/mm/mempolicy.c
85632 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
85633 unsigned long vmstart;
85634 unsigned long vmend;
85635
85636 +#ifdef CONFIG_PAX_SEGMEXEC
85637 + struct vm_area_struct *vma_m;
85638 +#endif
85639 +
85640 vma = find_vma(mm, start);
85641 if (!vma || vma->vm_start > start)
85642 return -EFAULT;
85643 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
85644 err = vma_replace_policy(vma, new_pol);
85645 if (err)
85646 goto out;
85647 +
85648 +#ifdef CONFIG_PAX_SEGMEXEC
85649 + vma_m = pax_find_mirror_vma(vma);
85650 + if (vma_m) {
85651 + err = vma_replace_policy(vma_m, new_pol);
85652 + if (err)
85653 + goto out;
85654 + }
85655 +#endif
85656 +
85657 }
85658
85659 out:
85660 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
85661
85662 if (end < start)
85663 return -EINVAL;
85664 +
85665 +#ifdef CONFIG_PAX_SEGMEXEC
85666 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
85667 + if (end > SEGMEXEC_TASK_SIZE)
85668 + return -EINVAL;
85669 + } else
85670 +#endif
85671 +
85672 + if (end > TASK_SIZE)
85673 + return -EINVAL;
85674 +
85675 if (end == start)
85676 return 0;
85677
85678 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
85679 */
85680 tcred = __task_cred(task);
85681 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
85682 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
85683 - !capable(CAP_SYS_NICE)) {
85684 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
85685 rcu_read_unlock();
85686 err = -EPERM;
85687 goto out_put;
85688 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
85689 goto out;
85690 }
85691
85692 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
85693 + if (mm != current->mm &&
85694 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
85695 + mmput(mm);
85696 + err = -EPERM;
85697 + goto out;
85698 + }
85699 +#endif
85700 +
85701 err = do_migrate_pages(mm, old, new,
85702 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
85703
85704 diff --git a/mm/migrate.c b/mm/migrate.c
85705 index 6f0c244..6d1ae32 100644
85706 --- a/mm/migrate.c
85707 +++ b/mm/migrate.c
85708 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
85709 */
85710 tcred = __task_cred(task);
85711 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
85712 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
85713 - !capable(CAP_SYS_NICE)) {
85714 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
85715 rcu_read_unlock();
85716 err = -EPERM;
85717 goto out;
85718 diff --git a/mm/mlock.c b/mm/mlock.c
85719 index 79b7cf7..9944291 100644
85720 --- a/mm/mlock.c
85721 +++ b/mm/mlock.c
85722 @@ -13,6 +13,7 @@
85723 #include <linux/pagemap.h>
85724 #include <linux/mempolicy.h>
85725 #include <linux/syscalls.h>
85726 +#include <linux/security.h>
85727 #include <linux/sched.h>
85728 #include <linux/export.h>
85729 #include <linux/rmap.h>
85730 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
85731 {
85732 unsigned long nstart, end, tmp;
85733 struct vm_area_struct * vma, * prev;
85734 - int error;
85735 + int error = 0;
85736
85737 VM_BUG_ON(start & ~PAGE_MASK);
85738 VM_BUG_ON(len != PAGE_ALIGN(len));
85739 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
85740 return -EINVAL;
85741 if (end == start)
85742 return 0;
85743 + if (end > TASK_SIZE)
85744 + return -EINVAL;
85745 +
85746 vma = find_vma(current->mm, start);
85747 if (!vma || vma->vm_start > start)
85748 return -ENOMEM;
85749 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
85750 for (nstart = start ; ; ) {
85751 vm_flags_t newflags;
85752
85753 +#ifdef CONFIG_PAX_SEGMEXEC
85754 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
85755 + break;
85756 +#endif
85757 +
85758 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
85759
85760 newflags = vma->vm_flags & ~VM_LOCKED;
85761 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
85762 lock_limit >>= PAGE_SHIFT;
85763
85764 /* check against resource limits */
85765 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
85766 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
85767 error = do_mlock(start, len, 1);
85768 up_write(&current->mm->mmap_sem);
85769 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
85770 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
85771 vm_flags_t newflags;
85772
85773 +#ifdef CONFIG_PAX_SEGMEXEC
85774 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
85775 + break;
85776 +#endif
85777 +
85778 newflags = vma->vm_flags & ~VM_LOCKED;
85779 if (flags & MCL_CURRENT)
85780 newflags |= VM_LOCKED;
85781 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
85782 lock_limit >>= PAGE_SHIFT;
85783
85784 ret = -ENOMEM;
85785 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
85786 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
85787 capable(CAP_IPC_LOCK))
85788 ret = do_mlockall(flags);
85789 diff --git a/mm/mmap.c b/mm/mmap.c
85790 index 7dbe397..bfb7626 100644
85791 --- a/mm/mmap.c
85792 +++ b/mm/mmap.c
85793 @@ -36,6 +36,7 @@
85794 #include <linux/sched/sysctl.h>
85795 #include <linux/notifier.h>
85796 #include <linux/memory.h>
85797 +#include <linux/random.h>
85798
85799 #include <asm/uaccess.h>
85800 #include <asm/cacheflush.h>
85801 @@ -52,6 +53,16 @@
85802 #define arch_rebalance_pgtables(addr, len) (addr)
85803 #endif
85804
85805 +static inline void verify_mm_writelocked(struct mm_struct *mm)
85806 +{
85807 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
85808 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
85809 + up_read(&mm->mmap_sem);
85810 + BUG();
85811 + }
85812 +#endif
85813 +}
85814 +
85815 static void unmap_region(struct mm_struct *mm,
85816 struct vm_area_struct *vma, struct vm_area_struct *prev,
85817 unsigned long start, unsigned long end);
85818 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
85819 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
85820 *
85821 */
85822 -pgprot_t protection_map[16] = {
85823 +pgprot_t protection_map[16] __read_only = {
85824 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
85825 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
85826 };
85827
85828 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
85829 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
85830 {
85831 - return __pgprot(pgprot_val(protection_map[vm_flags &
85832 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
85833 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
85834 pgprot_val(arch_vm_get_page_prot(vm_flags)));
85835 +
85836 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
85837 + if (!(__supported_pte_mask & _PAGE_NX) &&
85838 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
85839 + (vm_flags & (VM_READ | VM_WRITE)))
85840 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
85841 +#endif
85842 +
85843 + return prot;
85844 }
85845 EXPORT_SYMBOL(vm_get_page_prot);
85846
85847 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
85848 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
85849 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
85850 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
85851 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
85852 /*
85853 * Make sure vm_committed_as in one cacheline and not cacheline shared with
85854 * other variables. It can be updated by several CPUs frequently.
85855 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
85856 struct vm_area_struct *next = vma->vm_next;
85857
85858 might_sleep();
85859 + BUG_ON(vma->vm_mirror);
85860 if (vma->vm_ops && vma->vm_ops->close)
85861 vma->vm_ops->close(vma);
85862 if (vma->vm_file)
85863 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
85864 * not page aligned -Ram Gupta
85865 */
85866 rlim = rlimit(RLIMIT_DATA);
85867 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
85868 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
85869 (mm->end_data - mm->start_data) > rlim)
85870 goto out;
85871 @@ -933,6 +956,12 @@ static int
85872 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
85873 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
85874 {
85875 +
85876 +#ifdef CONFIG_PAX_SEGMEXEC
85877 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
85878 + return 0;
85879 +#endif
85880 +
85881 if (is_mergeable_vma(vma, file, vm_flags) &&
85882 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
85883 if (vma->vm_pgoff == vm_pgoff)
85884 @@ -952,6 +981,12 @@ static int
85885 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
85886 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
85887 {
85888 +
85889 +#ifdef CONFIG_PAX_SEGMEXEC
85890 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
85891 + return 0;
85892 +#endif
85893 +
85894 if (is_mergeable_vma(vma, file, vm_flags) &&
85895 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
85896 pgoff_t vm_pglen;
85897 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
85898 struct vm_area_struct *vma_merge(struct mm_struct *mm,
85899 struct vm_area_struct *prev, unsigned long addr,
85900 unsigned long end, unsigned long vm_flags,
85901 - struct anon_vma *anon_vma, struct file *file,
85902 + struct anon_vma *anon_vma, struct file *file,
85903 pgoff_t pgoff, struct mempolicy *policy)
85904 {
85905 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
85906 struct vm_area_struct *area, *next;
85907 int err;
85908
85909 +#ifdef CONFIG_PAX_SEGMEXEC
85910 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
85911 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
85912 +
85913 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
85914 +#endif
85915 +
85916 /*
85917 * We later require that vma->vm_flags == vm_flags,
85918 * so this tests vma->vm_flags & VM_SPECIAL, too.
85919 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
85920 if (next && next->vm_end == end) /* cases 6, 7, 8 */
85921 next = next->vm_next;
85922
85923 +#ifdef CONFIG_PAX_SEGMEXEC
85924 + if (prev)
85925 + prev_m = pax_find_mirror_vma(prev);
85926 + if (area)
85927 + area_m = pax_find_mirror_vma(area);
85928 + if (next)
85929 + next_m = pax_find_mirror_vma(next);
85930 +#endif
85931 +
85932 /*
85933 * Can it merge with the predecessor?
85934 */
85935 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
85936 /* cases 1, 6 */
85937 err = vma_adjust(prev, prev->vm_start,
85938 next->vm_end, prev->vm_pgoff, NULL);
85939 - } else /* cases 2, 5, 7 */
85940 +
85941 +#ifdef CONFIG_PAX_SEGMEXEC
85942 + if (!err && prev_m)
85943 + err = vma_adjust(prev_m, prev_m->vm_start,
85944 + next_m->vm_end, prev_m->vm_pgoff, NULL);
85945 +#endif
85946 +
85947 + } else { /* cases 2, 5, 7 */
85948 err = vma_adjust(prev, prev->vm_start,
85949 end, prev->vm_pgoff, NULL);
85950 +
85951 +#ifdef CONFIG_PAX_SEGMEXEC
85952 + if (!err && prev_m)
85953 + err = vma_adjust(prev_m, prev_m->vm_start,
85954 + end_m, prev_m->vm_pgoff, NULL);
85955 +#endif
85956 +
85957 + }
85958 if (err)
85959 return NULL;
85960 khugepaged_enter_vma_merge(prev);
85961 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
85962 mpol_equal(policy, vma_policy(next)) &&
85963 can_vma_merge_before(next, vm_flags,
85964 anon_vma, file, pgoff+pglen)) {
85965 - if (prev && addr < prev->vm_end) /* case 4 */
85966 + if (prev && addr < prev->vm_end) { /* case 4 */
85967 err = vma_adjust(prev, prev->vm_start,
85968 addr, prev->vm_pgoff, NULL);
85969 - else /* cases 3, 8 */
85970 +
85971 +#ifdef CONFIG_PAX_SEGMEXEC
85972 + if (!err && prev_m)
85973 + err = vma_adjust(prev_m, prev_m->vm_start,
85974 + addr_m, prev_m->vm_pgoff, NULL);
85975 +#endif
85976 +
85977 + } else { /* cases 3, 8 */
85978 err = vma_adjust(area, addr, next->vm_end,
85979 next->vm_pgoff - pglen, NULL);
85980 +
85981 +#ifdef CONFIG_PAX_SEGMEXEC
85982 + if (!err && area_m)
85983 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
85984 + next_m->vm_pgoff - pglen, NULL);
85985 +#endif
85986 +
85987 + }
85988 if (err)
85989 return NULL;
85990 khugepaged_enter_vma_merge(area);
85991 @@ -1165,8 +1246,10 @@ none:
85992 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
85993 struct file *file, long pages)
85994 {
85995 - const unsigned long stack_flags
85996 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
85997 +
85998 +#ifdef CONFIG_PAX_RANDMMAP
85999 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
86000 +#endif
86001
86002 mm->total_vm += pages;
86003
86004 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
86005 mm->shared_vm += pages;
86006 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
86007 mm->exec_vm += pages;
86008 - } else if (flags & stack_flags)
86009 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
86010 mm->stack_vm += pages;
86011 }
86012 #endif /* CONFIG_PROC_FS */
86013 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
86014 * (the exception is when the underlying filesystem is noexec
86015 * mounted, in which case we dont add PROT_EXEC.)
86016 */
86017 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
86018 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
86019 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
86020 prot |= PROT_EXEC;
86021
86022 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
86023 /* Obtain the address to map to. we verify (or select) it and ensure
86024 * that it represents a valid section of the address space.
86025 */
86026 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
86027 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
86028 if (addr & ~PAGE_MASK)
86029 return addr;
86030
86031 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
86032 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
86033 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
86034
86035 +#ifdef CONFIG_PAX_MPROTECT
86036 + if (mm->pax_flags & MF_PAX_MPROTECT) {
86037 +
86038 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
86039 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
86040 + mm->binfmt->handle_mmap)
86041 + mm->binfmt->handle_mmap(file);
86042 +#endif
86043 +
86044 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
86045 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
86046 + gr_log_rwxmmap(file);
86047 +
86048 +#ifdef CONFIG_PAX_EMUPLT
86049 + vm_flags &= ~VM_EXEC;
86050 +#else
86051 + return -EPERM;
86052 +#endif
86053 +
86054 + }
86055 +
86056 + if (!(vm_flags & VM_EXEC))
86057 + vm_flags &= ~VM_MAYEXEC;
86058 +#else
86059 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
86060 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
86061 +#endif
86062 + else
86063 + vm_flags &= ~VM_MAYWRITE;
86064 + }
86065 +#endif
86066 +
86067 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
86068 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
86069 + vm_flags &= ~VM_PAGEEXEC;
86070 +#endif
86071 +
86072 if (flags & MAP_LOCKED)
86073 if (!can_do_mlock())
86074 return -EPERM;
86075 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
86076 locked += mm->locked_vm;
86077 lock_limit = rlimit(RLIMIT_MEMLOCK);
86078 lock_limit >>= PAGE_SHIFT;
86079 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
86080 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
86081 return -EAGAIN;
86082 }
86083 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
86084 vm_flags |= VM_NORESERVE;
86085 }
86086
86087 + if (!gr_acl_handle_mmap(file, prot))
86088 + return -EACCES;
86089 +
86090 addr = mmap_region(file, addr, len, vm_flags, pgoff);
86091 if (!IS_ERR_VALUE(addr) &&
86092 ((vm_flags & VM_LOCKED) ||
86093 @@ -1432,7 +1556,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
86094 vm_flags_t vm_flags = vma->vm_flags;
86095
86096 /* If it was private or non-writable, the write bit is already clear */
86097 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
86098 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
86099 return 0;
86100
86101 /* The backer wishes to know when pages are first written to? */
86102 @@ -1480,7 +1604,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
86103 unsigned long charged = 0;
86104 struct inode *inode = file ? file_inode(file) : NULL;
86105
86106 +#ifdef CONFIG_PAX_SEGMEXEC
86107 + struct vm_area_struct *vma_m = NULL;
86108 +#endif
86109 +
86110 + /*
86111 + * mm->mmap_sem is required to protect against another thread
86112 + * changing the mappings in case we sleep.
86113 + */
86114 + verify_mm_writelocked(mm);
86115 +
86116 /* Check against address space limit. */
86117 +
86118 +#ifdef CONFIG_PAX_RANDMMAP
86119 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
86120 +#endif
86121 +
86122 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
86123 unsigned long nr_pages;
86124
86125 @@ -1499,11 +1638,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
86126
86127 /* Clear old maps */
86128 error = -ENOMEM;
86129 -munmap_back:
86130 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
86131 if (do_munmap(mm, addr, len))
86132 return -ENOMEM;
86133 - goto munmap_back;
86134 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
86135 }
86136
86137 /*
86138 @@ -1534,6 +1672,16 @@ munmap_back:
86139 goto unacct_error;
86140 }
86141
86142 +#ifdef CONFIG_PAX_SEGMEXEC
86143 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
86144 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
86145 + if (!vma_m) {
86146 + error = -ENOMEM;
86147 + goto free_vma;
86148 + }
86149 + }
86150 +#endif
86151 +
86152 vma->vm_mm = mm;
86153 vma->vm_start = addr;
86154 vma->vm_end = addr + len;
86155 @@ -1558,6 +1706,13 @@ munmap_back:
86156 if (error)
86157 goto unmap_and_free_vma;
86158
86159 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
86160 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
86161 + vma->vm_flags |= VM_PAGEEXEC;
86162 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
86163 + }
86164 +#endif
86165 +
86166 /* Can addr have changed??
86167 *
86168 * Answer: Yes, several device drivers can do it in their
86169 @@ -1596,6 +1751,11 @@ munmap_back:
86170 vma_link(mm, vma, prev, rb_link, rb_parent);
86171 file = vma->vm_file;
86172
86173 +#ifdef CONFIG_PAX_SEGMEXEC
86174 + if (vma_m)
86175 + BUG_ON(pax_mirror_vma(vma_m, vma));
86176 +#endif
86177 +
86178 /* Once vma denies write, undo our temporary denial count */
86179 if (correct_wcount)
86180 atomic_inc(&inode->i_writecount);
86181 @@ -1603,6 +1763,7 @@ out:
86182 perf_event_mmap(vma);
86183
86184 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
86185 + track_exec_limit(mm, addr, addr + len, vm_flags);
86186 if (vm_flags & VM_LOCKED) {
86187 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
86188 vma == get_gate_vma(current->mm)))
86189 @@ -1626,6 +1787,12 @@ unmap_and_free_vma:
86190 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
86191 charged = 0;
86192 free_vma:
86193 +
86194 +#ifdef CONFIG_PAX_SEGMEXEC
86195 + if (vma_m)
86196 + kmem_cache_free(vm_area_cachep, vma_m);
86197 +#endif
86198 +
86199 kmem_cache_free(vm_area_cachep, vma);
86200 unacct_error:
86201 if (charged)
86202 @@ -1633,7 +1800,63 @@ unacct_error:
86203 return error;
86204 }
86205
86206 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
86207 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
86208 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
86209 +{
86210 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
86211 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
86212 +
86213 + return 0;
86214 +}
86215 +#endif
86216 +
86217 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
86218 +{
86219 + if (!vma) {
86220 +#ifdef CONFIG_STACK_GROWSUP
86221 + if (addr > sysctl_heap_stack_gap)
86222 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
86223 + else
86224 + vma = find_vma(current->mm, 0);
86225 + if (vma && (vma->vm_flags & VM_GROWSUP))
86226 + return false;
86227 +#endif
86228 + return true;
86229 + }
86230 +
86231 + if (addr + len > vma->vm_start)
86232 + return false;
86233 +
86234 + if (vma->vm_flags & VM_GROWSDOWN)
86235 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
86236 +#ifdef CONFIG_STACK_GROWSUP
86237 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
86238 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
86239 +#endif
86240 + else if (offset)
86241 + return offset <= vma->vm_start - addr - len;
86242 +
86243 + return true;
86244 +}
86245 +
86246 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
86247 +{
86248 + if (vma->vm_start < len)
86249 + return -ENOMEM;
86250 +
86251 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
86252 + if (offset <= vma->vm_start - len)
86253 + return vma->vm_start - len - offset;
86254 + else
86255 + return -ENOMEM;
86256 + }
86257 +
86258 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
86259 + return vma->vm_start - len - sysctl_heap_stack_gap;
86260 + return -ENOMEM;
86261 +}
86262 +
86263 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
86264 {
86265 /*
86266 * We implement the search by looking for an rbtree node that
86267 @@ -1681,11 +1904,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
86268 }
86269 }
86270
86271 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
86272 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
86273 check_current:
86274 /* Check if current node has a suitable gap */
86275 if (gap_start > high_limit)
86276 return -ENOMEM;
86277 +
86278 + if (gap_end - gap_start > info->threadstack_offset)
86279 + gap_start += info->threadstack_offset;
86280 + else
86281 + gap_start = gap_end;
86282 +
86283 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
86284 + if (gap_end - gap_start > sysctl_heap_stack_gap)
86285 + gap_start += sysctl_heap_stack_gap;
86286 + else
86287 + gap_start = gap_end;
86288 + }
86289 + if (vma->vm_flags & VM_GROWSDOWN) {
86290 + if (gap_end - gap_start > sysctl_heap_stack_gap)
86291 + gap_end -= sysctl_heap_stack_gap;
86292 + else
86293 + gap_end = gap_start;
86294 + }
86295 if (gap_end >= low_limit && gap_end - gap_start >= length)
86296 goto found;
86297
86298 @@ -1735,7 +1976,7 @@ found:
86299 return gap_start;
86300 }
86301
86302 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
86303 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
86304 {
86305 struct mm_struct *mm = current->mm;
86306 struct vm_area_struct *vma;
86307 @@ -1789,6 +2030,24 @@ check_current:
86308 gap_end = vma->vm_start;
86309 if (gap_end < low_limit)
86310 return -ENOMEM;
86311 +
86312 + if (gap_end - gap_start > info->threadstack_offset)
86313 + gap_end -= info->threadstack_offset;
86314 + else
86315 + gap_end = gap_start;
86316 +
86317 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
86318 + if (gap_end - gap_start > sysctl_heap_stack_gap)
86319 + gap_start += sysctl_heap_stack_gap;
86320 + else
86321 + gap_start = gap_end;
86322 + }
86323 + if (vma->vm_flags & VM_GROWSDOWN) {
86324 + if (gap_end - gap_start > sysctl_heap_stack_gap)
86325 + gap_end -= sysctl_heap_stack_gap;
86326 + else
86327 + gap_end = gap_start;
86328 + }
86329 if (gap_start <= high_limit && gap_end - gap_start >= length)
86330 goto found;
86331
86332 @@ -1852,6 +2111,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
86333 struct mm_struct *mm = current->mm;
86334 struct vm_area_struct *vma;
86335 struct vm_unmapped_area_info info;
86336 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
86337
86338 if (len > TASK_SIZE)
86339 return -ENOMEM;
86340 @@ -1859,29 +2119,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
86341 if (flags & MAP_FIXED)
86342 return addr;
86343
86344 +#ifdef CONFIG_PAX_RANDMMAP
86345 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
86346 +#endif
86347 +
86348 if (addr) {
86349 addr = PAGE_ALIGN(addr);
86350 vma = find_vma(mm, addr);
86351 - if (TASK_SIZE - len >= addr &&
86352 - (!vma || addr + len <= vma->vm_start))
86353 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
86354 return addr;
86355 }
86356
86357 info.flags = 0;
86358 info.length = len;
86359 info.low_limit = TASK_UNMAPPED_BASE;
86360 +
86361 +#ifdef CONFIG_PAX_RANDMMAP
86362 + if (mm->pax_flags & MF_PAX_RANDMMAP)
86363 + info.low_limit += mm->delta_mmap;
86364 +#endif
86365 +
86366 info.high_limit = TASK_SIZE;
86367 info.align_mask = 0;
86368 + info.threadstack_offset = offset;
86369 return vm_unmapped_area(&info);
86370 }
86371 #endif
86372
86373 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
86374 {
86375 +
86376 +#ifdef CONFIG_PAX_SEGMEXEC
86377 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
86378 + return;
86379 +#endif
86380 +
86381 /*
86382 * Is this a new hole at the lowest possible address?
86383 */
86384 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
86385 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
86386 mm->free_area_cache = addr;
86387 }
86388
86389 @@ -1899,6 +2175,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
86390 struct mm_struct *mm = current->mm;
86391 unsigned long addr = addr0;
86392 struct vm_unmapped_area_info info;
86393 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
86394
86395 /* requested length too big for entire address space */
86396 if (len > TASK_SIZE)
86397 @@ -1907,12 +2184,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
86398 if (flags & MAP_FIXED)
86399 return addr;
86400
86401 +#ifdef CONFIG_PAX_RANDMMAP
86402 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
86403 +#endif
86404 +
86405 /* requesting a specific address */
86406 if (addr) {
86407 addr = PAGE_ALIGN(addr);
86408 vma = find_vma(mm, addr);
86409 - if (TASK_SIZE - len >= addr &&
86410 - (!vma || addr + len <= vma->vm_start))
86411 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
86412 return addr;
86413 }
86414
86415 @@ -1921,6 +2201,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
86416 info.low_limit = PAGE_SIZE;
86417 info.high_limit = mm->mmap_base;
86418 info.align_mask = 0;
86419 + info.threadstack_offset = offset;
86420 addr = vm_unmapped_area(&info);
86421
86422 /*
86423 @@ -1933,6 +2214,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
86424 VM_BUG_ON(addr != -ENOMEM);
86425 info.flags = 0;
86426 info.low_limit = TASK_UNMAPPED_BASE;
86427 +
86428 +#ifdef CONFIG_PAX_RANDMMAP
86429 + if (mm->pax_flags & MF_PAX_RANDMMAP)
86430 + info.low_limit += mm->delta_mmap;
86431 +#endif
86432 +
86433 info.high_limit = TASK_SIZE;
86434 addr = vm_unmapped_area(&info);
86435 }
86436 @@ -1943,6 +2230,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
86437
86438 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
86439 {
86440 +
86441 +#ifdef CONFIG_PAX_SEGMEXEC
86442 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
86443 + return;
86444 +#endif
86445 +
86446 /*
86447 * Is this a new hole at the highest possible address?
86448 */
86449 @@ -1950,8 +2243,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
86450 mm->free_area_cache = addr;
86451
86452 /* dont allow allocations above current base */
86453 - if (mm->free_area_cache > mm->mmap_base)
86454 + if (mm->free_area_cache > mm->mmap_base) {
86455 mm->free_area_cache = mm->mmap_base;
86456 + mm->cached_hole_size = ~0UL;
86457 + }
86458 }
86459
86460 unsigned long
86461 @@ -2047,6 +2342,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
86462 return vma;
86463 }
86464
86465 +#ifdef CONFIG_PAX_SEGMEXEC
86466 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
86467 +{
86468 + struct vm_area_struct *vma_m;
86469 +
86470 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
86471 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
86472 + BUG_ON(vma->vm_mirror);
86473 + return NULL;
86474 + }
86475 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
86476 + vma_m = vma->vm_mirror;
86477 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
86478 + BUG_ON(vma->vm_file != vma_m->vm_file);
86479 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
86480 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
86481 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
86482 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
86483 + return vma_m;
86484 +}
86485 +#endif
86486 +
86487 /*
86488 * Verify that the stack growth is acceptable and
86489 * update accounting. This is shared with both the
86490 @@ -2063,6 +2380,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
86491 return -ENOMEM;
86492
86493 /* Stack limit test */
86494 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
86495 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
86496 return -ENOMEM;
86497
86498 @@ -2073,6 +2391,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
86499 locked = mm->locked_vm + grow;
86500 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
86501 limit >>= PAGE_SHIFT;
86502 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
86503 if (locked > limit && !capable(CAP_IPC_LOCK))
86504 return -ENOMEM;
86505 }
86506 @@ -2102,37 +2421,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
86507 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
86508 * vma is the last one with address > vma->vm_end. Have to extend vma.
86509 */
86510 +#ifndef CONFIG_IA64
86511 +static
86512 +#endif
86513 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
86514 {
86515 int error;
86516 + bool locknext;
86517
86518 if (!(vma->vm_flags & VM_GROWSUP))
86519 return -EFAULT;
86520
86521 + /* Also guard against wrapping around to address 0. */
86522 + if (address < PAGE_ALIGN(address+1))
86523 + address = PAGE_ALIGN(address+1);
86524 + else
86525 + return -ENOMEM;
86526 +
86527 /*
86528 * We must make sure the anon_vma is allocated
86529 * so that the anon_vma locking is not a noop.
86530 */
86531 if (unlikely(anon_vma_prepare(vma)))
86532 return -ENOMEM;
86533 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
86534 + if (locknext && anon_vma_prepare(vma->vm_next))
86535 + return -ENOMEM;
86536 vma_lock_anon_vma(vma);
86537 + if (locknext)
86538 + vma_lock_anon_vma(vma->vm_next);
86539
86540 /*
86541 * vma->vm_start/vm_end cannot change under us because the caller
86542 * is required to hold the mmap_sem in read mode. We need the
86543 - * anon_vma lock to serialize against concurrent expand_stacks.
86544 - * Also guard against wrapping around to address 0.
86545 + * anon_vma locks to serialize against concurrent expand_stacks
86546 + * and expand_upwards.
86547 */
86548 - if (address < PAGE_ALIGN(address+4))
86549 - address = PAGE_ALIGN(address+4);
86550 - else {
86551 - vma_unlock_anon_vma(vma);
86552 - return -ENOMEM;
86553 - }
86554 error = 0;
86555
86556 /* Somebody else might have raced and expanded it already */
86557 - if (address > vma->vm_end) {
86558 + 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)
86559 + error = -ENOMEM;
86560 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
86561 unsigned long size, grow;
86562
86563 size = address - vma->vm_start;
86564 @@ -2167,6 +2497,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
86565 }
86566 }
86567 }
86568 + if (locknext)
86569 + vma_unlock_anon_vma(vma->vm_next);
86570 vma_unlock_anon_vma(vma);
86571 khugepaged_enter_vma_merge(vma);
86572 validate_mm(vma->vm_mm);
86573 @@ -2181,6 +2513,8 @@ int expand_downwards(struct vm_area_struct *vma,
86574 unsigned long address)
86575 {
86576 int error;
86577 + bool lockprev = false;
86578 + struct vm_area_struct *prev;
86579
86580 /*
86581 * We must make sure the anon_vma is allocated
86582 @@ -2194,6 +2528,15 @@ int expand_downwards(struct vm_area_struct *vma,
86583 if (error)
86584 return error;
86585
86586 + prev = vma->vm_prev;
86587 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
86588 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
86589 +#endif
86590 + if (lockprev && anon_vma_prepare(prev))
86591 + return -ENOMEM;
86592 + if (lockprev)
86593 + vma_lock_anon_vma(prev);
86594 +
86595 vma_lock_anon_vma(vma);
86596
86597 /*
86598 @@ -2203,9 +2546,17 @@ int expand_downwards(struct vm_area_struct *vma,
86599 */
86600
86601 /* Somebody else might have raced and expanded it already */
86602 - if (address < vma->vm_start) {
86603 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
86604 + error = -ENOMEM;
86605 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
86606 unsigned long size, grow;
86607
86608 +#ifdef CONFIG_PAX_SEGMEXEC
86609 + struct vm_area_struct *vma_m;
86610 +
86611 + vma_m = pax_find_mirror_vma(vma);
86612 +#endif
86613 +
86614 size = vma->vm_end - address;
86615 grow = (vma->vm_start - address) >> PAGE_SHIFT;
86616
86617 @@ -2230,13 +2581,27 @@ int expand_downwards(struct vm_area_struct *vma,
86618 vma->vm_pgoff -= grow;
86619 anon_vma_interval_tree_post_update_vma(vma);
86620 vma_gap_update(vma);
86621 +
86622 +#ifdef CONFIG_PAX_SEGMEXEC
86623 + if (vma_m) {
86624 + anon_vma_interval_tree_pre_update_vma(vma_m);
86625 + vma_m->vm_start -= grow << PAGE_SHIFT;
86626 + vma_m->vm_pgoff -= grow;
86627 + anon_vma_interval_tree_post_update_vma(vma_m);
86628 + vma_gap_update(vma_m);
86629 + }
86630 +#endif
86631 +
86632 spin_unlock(&vma->vm_mm->page_table_lock);
86633
86634 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
86635 perf_event_mmap(vma);
86636 }
86637 }
86638 }
86639 vma_unlock_anon_vma(vma);
86640 + if (lockprev)
86641 + vma_unlock_anon_vma(prev);
86642 khugepaged_enter_vma_merge(vma);
86643 validate_mm(vma->vm_mm);
86644 return error;
86645 @@ -2334,6 +2699,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
86646 do {
86647 long nrpages = vma_pages(vma);
86648
86649 +#ifdef CONFIG_PAX_SEGMEXEC
86650 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
86651 + vma = remove_vma(vma);
86652 + continue;
86653 + }
86654 +#endif
86655 +
86656 if (vma->vm_flags & VM_ACCOUNT)
86657 nr_accounted += nrpages;
86658 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
86659 @@ -2356,7 +2728,7 @@ static void unmap_region(struct mm_struct *mm,
86660 struct mmu_gather tlb;
86661
86662 lru_add_drain();
86663 - tlb_gather_mmu(&tlb, mm, 0);
86664 + tlb_gather_mmu(&tlb, mm, start, end);
86665 update_hiwater_rss(mm);
86666 unmap_vmas(&tlb, vma, start, end);
86667 free_pgtables(&tlb, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS,
86668 @@ -2379,6 +2751,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
86669 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
86670 vma->vm_prev = NULL;
86671 do {
86672 +
86673 +#ifdef CONFIG_PAX_SEGMEXEC
86674 + if (vma->vm_mirror) {
86675 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
86676 + vma->vm_mirror->vm_mirror = NULL;
86677 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
86678 + vma->vm_mirror = NULL;
86679 + }
86680 +#endif
86681 +
86682 vma_rb_erase(vma, &mm->mm_rb);
86683 mm->map_count--;
86684 tail_vma = vma;
86685 @@ -2410,14 +2792,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
86686 struct vm_area_struct *new;
86687 int err = -ENOMEM;
86688
86689 +#ifdef CONFIG_PAX_SEGMEXEC
86690 + struct vm_area_struct *vma_m, *new_m = NULL;
86691 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
86692 +#endif
86693 +
86694 if (is_vm_hugetlb_page(vma) && (addr &
86695 ~(huge_page_mask(hstate_vma(vma)))))
86696 return -EINVAL;
86697
86698 +#ifdef CONFIG_PAX_SEGMEXEC
86699 + vma_m = pax_find_mirror_vma(vma);
86700 +#endif
86701 +
86702 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
86703 if (!new)
86704 goto out_err;
86705
86706 +#ifdef CONFIG_PAX_SEGMEXEC
86707 + if (vma_m) {
86708 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
86709 + if (!new_m) {
86710 + kmem_cache_free(vm_area_cachep, new);
86711 + goto out_err;
86712 + }
86713 + }
86714 +#endif
86715 +
86716 /* most fields are the same, copy all, and then fixup */
86717 *new = *vma;
86718
86719 @@ -2430,6 +2831,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
86720 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
86721 }
86722
86723 +#ifdef CONFIG_PAX_SEGMEXEC
86724 + if (vma_m) {
86725 + *new_m = *vma_m;
86726 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
86727 + new_m->vm_mirror = new;
86728 + new->vm_mirror = new_m;
86729 +
86730 + if (new_below)
86731 + new_m->vm_end = addr_m;
86732 + else {
86733 + new_m->vm_start = addr_m;
86734 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
86735 + }
86736 + }
86737 +#endif
86738 +
86739 pol = mpol_dup(vma_policy(vma));
86740 if (IS_ERR(pol)) {
86741 err = PTR_ERR(pol);
86742 @@ -2452,6 +2869,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
86743 else
86744 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
86745
86746 +#ifdef CONFIG_PAX_SEGMEXEC
86747 + if (!err && vma_m) {
86748 + if (anon_vma_clone(new_m, vma_m))
86749 + goto out_free_mpol;
86750 +
86751 + mpol_get(pol);
86752 + vma_set_policy(new_m, pol);
86753 +
86754 + if (new_m->vm_file)
86755 + get_file(new_m->vm_file);
86756 +
86757 + if (new_m->vm_ops && new_m->vm_ops->open)
86758 + new_m->vm_ops->open(new_m);
86759 +
86760 + if (new_below)
86761 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
86762 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
86763 + else
86764 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
86765 +
86766 + if (err) {
86767 + if (new_m->vm_ops && new_m->vm_ops->close)
86768 + new_m->vm_ops->close(new_m);
86769 + if (new_m->vm_file)
86770 + fput(new_m->vm_file);
86771 + mpol_put(pol);
86772 + }
86773 + }
86774 +#endif
86775 +
86776 /* Success. */
86777 if (!err)
86778 return 0;
86779 @@ -2461,10 +2908,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
86780 new->vm_ops->close(new);
86781 if (new->vm_file)
86782 fput(new->vm_file);
86783 - unlink_anon_vmas(new);
86784 out_free_mpol:
86785 mpol_put(pol);
86786 out_free_vma:
86787 +
86788 +#ifdef CONFIG_PAX_SEGMEXEC
86789 + if (new_m) {
86790 + unlink_anon_vmas(new_m);
86791 + kmem_cache_free(vm_area_cachep, new_m);
86792 + }
86793 +#endif
86794 +
86795 + unlink_anon_vmas(new);
86796 kmem_cache_free(vm_area_cachep, new);
86797 out_err:
86798 return err;
86799 @@ -2477,6 +2932,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
86800 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
86801 unsigned long addr, int new_below)
86802 {
86803 +
86804 +#ifdef CONFIG_PAX_SEGMEXEC
86805 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
86806 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
86807 + if (mm->map_count >= sysctl_max_map_count-1)
86808 + return -ENOMEM;
86809 + } else
86810 +#endif
86811 +
86812 if (mm->map_count >= sysctl_max_map_count)
86813 return -ENOMEM;
86814
86815 @@ -2488,11 +2952,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
86816 * work. This now handles partial unmappings.
86817 * Jeremy Fitzhardinge <jeremy@goop.org>
86818 */
86819 +#ifdef CONFIG_PAX_SEGMEXEC
86820 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
86821 {
86822 + int ret = __do_munmap(mm, start, len);
86823 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
86824 + return ret;
86825 +
86826 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
86827 +}
86828 +
86829 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
86830 +#else
86831 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
86832 +#endif
86833 +{
86834 unsigned long end;
86835 struct vm_area_struct *vma, *prev, *last;
86836
86837 + /*
86838 + * mm->mmap_sem is required to protect against another thread
86839 + * changing the mappings in case we sleep.
86840 + */
86841 + verify_mm_writelocked(mm);
86842 +
86843 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
86844 return -EINVAL;
86845
86846 @@ -2567,6 +3050,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
86847 /* Fix up all other VM information */
86848 remove_vma_list(mm, vma);
86849
86850 + track_exec_limit(mm, start, end, 0UL);
86851 +
86852 return 0;
86853 }
86854
86855 @@ -2575,6 +3060,13 @@ int vm_munmap(unsigned long start, size_t len)
86856 int ret;
86857 struct mm_struct *mm = current->mm;
86858
86859 +
86860 +#ifdef CONFIG_PAX_SEGMEXEC
86861 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
86862 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
86863 + return -EINVAL;
86864 +#endif
86865 +
86866 down_write(&mm->mmap_sem);
86867 ret = do_munmap(mm, start, len);
86868 up_write(&mm->mmap_sem);
86869 @@ -2588,16 +3080,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
86870 return vm_munmap(addr, len);
86871 }
86872
86873 -static inline void verify_mm_writelocked(struct mm_struct *mm)
86874 -{
86875 -#ifdef CONFIG_DEBUG_VM
86876 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
86877 - WARN_ON(1);
86878 - up_read(&mm->mmap_sem);
86879 - }
86880 -#endif
86881 -}
86882 -
86883 /*
86884 * this is really a simplified "do_mmap". it only handles
86885 * anonymous maps. eventually we may be able to do some
86886 @@ -2611,6 +3093,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
86887 struct rb_node ** rb_link, * rb_parent;
86888 pgoff_t pgoff = addr >> PAGE_SHIFT;
86889 int error;
86890 + unsigned long charged;
86891
86892 len = PAGE_ALIGN(len);
86893 if (!len)
86894 @@ -2618,16 +3101,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
86895
86896 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
86897
86898 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
86899 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
86900 + flags &= ~VM_EXEC;
86901 +
86902 +#ifdef CONFIG_PAX_MPROTECT
86903 + if (mm->pax_flags & MF_PAX_MPROTECT)
86904 + flags &= ~VM_MAYEXEC;
86905 +#endif
86906 +
86907 + }
86908 +#endif
86909 +
86910 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
86911 if (error & ~PAGE_MASK)
86912 return error;
86913
86914 + charged = len >> PAGE_SHIFT;
86915 +
86916 /*
86917 * mlock MCL_FUTURE?
86918 */
86919 if (mm->def_flags & VM_LOCKED) {
86920 unsigned long locked, lock_limit;
86921 - locked = len >> PAGE_SHIFT;
86922 + locked = charged;
86923 locked += mm->locked_vm;
86924 lock_limit = rlimit(RLIMIT_MEMLOCK);
86925 lock_limit >>= PAGE_SHIFT;
86926 @@ -2644,21 +3141,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
86927 /*
86928 * Clear old maps. this also does some error checking for us
86929 */
86930 - munmap_back:
86931 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
86932 if (do_munmap(mm, addr, len))
86933 return -ENOMEM;
86934 - goto munmap_back;
86935 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
86936 }
86937
86938 /* Check against address space limits *after* clearing old maps... */
86939 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
86940 + if (!may_expand_vm(mm, charged))
86941 return -ENOMEM;
86942
86943 if (mm->map_count > sysctl_max_map_count)
86944 return -ENOMEM;
86945
86946 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
86947 + if (security_vm_enough_memory_mm(mm, charged))
86948 return -ENOMEM;
86949
86950 /* Can we just expand an old private anonymous mapping? */
86951 @@ -2672,7 +3168,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
86952 */
86953 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
86954 if (!vma) {
86955 - vm_unacct_memory(len >> PAGE_SHIFT);
86956 + vm_unacct_memory(charged);
86957 return -ENOMEM;
86958 }
86959
86960 @@ -2686,9 +3182,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
86961 vma_link(mm, vma, prev, rb_link, rb_parent);
86962 out:
86963 perf_event_mmap(vma);
86964 - mm->total_vm += len >> PAGE_SHIFT;
86965 + mm->total_vm += charged;
86966 if (flags & VM_LOCKED)
86967 - mm->locked_vm += (len >> PAGE_SHIFT);
86968 + mm->locked_vm += charged;
86969 + track_exec_limit(mm, addr, addr + len, flags);
86970 return addr;
86971 }
86972
86973 @@ -2735,7 +3232,7 @@ void exit_mmap(struct mm_struct *mm)
86974
86975 lru_add_drain();
86976 flush_cache_mm(mm);
86977 - tlb_gather_mmu(&tlb, mm, 1);
86978 + tlb_gather_mmu(&tlb, mm, 0, -1);
86979 /* update_hiwater_rss(mm) here? but nobody should be looking */
86980 /* Use -1 here to ensure all VMAs in the mm are unmapped */
86981 unmap_vmas(&tlb, vma, 0, -1);
86982 @@ -2750,6 +3247,7 @@ void exit_mmap(struct mm_struct *mm)
86983 while (vma) {
86984 if (vma->vm_flags & VM_ACCOUNT)
86985 nr_accounted += vma_pages(vma);
86986 + vma->vm_mirror = NULL;
86987 vma = remove_vma(vma);
86988 }
86989 vm_unacct_memory(nr_accounted);
86990 @@ -2766,6 +3264,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
86991 struct vm_area_struct *prev;
86992 struct rb_node **rb_link, *rb_parent;
86993
86994 +#ifdef CONFIG_PAX_SEGMEXEC
86995 + struct vm_area_struct *vma_m = NULL;
86996 +#endif
86997 +
86998 + if (security_mmap_addr(vma->vm_start))
86999 + return -EPERM;
87000 +
87001 /*
87002 * The vm_pgoff of a purely anonymous vma should be irrelevant
87003 * until its first write fault, when page's anon_vma and index
87004 @@ -2789,7 +3294,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
87005 security_vm_enough_memory_mm(mm, vma_pages(vma)))
87006 return -ENOMEM;
87007
87008 +#ifdef CONFIG_PAX_SEGMEXEC
87009 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
87010 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87011 + if (!vma_m)
87012 + return -ENOMEM;
87013 + }
87014 +#endif
87015 +
87016 vma_link(mm, vma, prev, rb_link, rb_parent);
87017 +
87018 +#ifdef CONFIG_PAX_SEGMEXEC
87019 + if (vma_m)
87020 + BUG_ON(pax_mirror_vma(vma_m, vma));
87021 +#endif
87022 +
87023 return 0;
87024 }
87025
87026 @@ -2809,6 +3328,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
87027 struct mempolicy *pol;
87028 bool faulted_in_anon_vma = true;
87029
87030 + BUG_ON(vma->vm_mirror);
87031 +
87032 /*
87033 * If anonymous vma has not yet been faulted, update new pgoff
87034 * to match new location, to increase its chance of merging.
87035 @@ -2875,6 +3396,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
87036 return NULL;
87037 }
87038
87039 +#ifdef CONFIG_PAX_SEGMEXEC
87040 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
87041 +{
87042 + struct vm_area_struct *prev_m;
87043 + struct rb_node **rb_link_m, *rb_parent_m;
87044 + struct mempolicy *pol_m;
87045 +
87046 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
87047 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
87048 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
87049 + *vma_m = *vma;
87050 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
87051 + if (anon_vma_clone(vma_m, vma))
87052 + return -ENOMEM;
87053 + pol_m = vma_policy(vma_m);
87054 + mpol_get(pol_m);
87055 + vma_set_policy(vma_m, pol_m);
87056 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
87057 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
87058 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
87059 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
87060 + if (vma_m->vm_file)
87061 + get_file(vma_m->vm_file);
87062 + if (vma_m->vm_ops && vma_m->vm_ops->open)
87063 + vma_m->vm_ops->open(vma_m);
87064 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
87065 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
87066 + vma_m->vm_mirror = vma;
87067 + vma->vm_mirror = vma_m;
87068 + return 0;
87069 +}
87070 +#endif
87071 +
87072 /*
87073 * Return true if the calling process may expand its vm space by the passed
87074 * number of pages
87075 @@ -2886,6 +3440,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
87076
87077 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
87078
87079 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
87080 if (cur + npages > lim)
87081 return 0;
87082 return 1;
87083 @@ -2956,6 +3511,22 @@ int install_special_mapping(struct mm_struct *mm,
87084 vma->vm_start = addr;
87085 vma->vm_end = addr + len;
87086
87087 +#ifdef CONFIG_PAX_MPROTECT
87088 + if (mm->pax_flags & MF_PAX_MPROTECT) {
87089 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
87090 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
87091 + return -EPERM;
87092 + if (!(vm_flags & VM_EXEC))
87093 + vm_flags &= ~VM_MAYEXEC;
87094 +#else
87095 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
87096 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
87097 +#endif
87098 + else
87099 + vm_flags &= ~VM_MAYWRITE;
87100 + }
87101 +#endif
87102 +
87103 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
87104 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
87105
87106 diff --git a/mm/mprotect.c b/mm/mprotect.c
87107 index 94722a4..e661e29 100644
87108 --- a/mm/mprotect.c
87109 +++ b/mm/mprotect.c
87110 @@ -23,10 +23,18 @@
87111 #include <linux/mmu_notifier.h>
87112 #include <linux/migrate.h>
87113 #include <linux/perf_event.h>
87114 +#include <linux/sched/sysctl.h>
87115 +
87116 +#ifdef CONFIG_PAX_MPROTECT
87117 +#include <linux/elf.h>
87118 +#include <linux/binfmts.h>
87119 +#endif
87120 +
87121 #include <asm/uaccess.h>
87122 #include <asm/pgtable.h>
87123 #include <asm/cacheflush.h>
87124 #include <asm/tlbflush.h>
87125 +#include <asm/mmu_context.h>
87126
87127 #ifndef pgprot_modify
87128 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
87129 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
87130 return pages;
87131 }
87132
87133 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
87134 +/* called while holding the mmap semaphor for writing except stack expansion */
87135 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
87136 +{
87137 + unsigned long oldlimit, newlimit = 0UL;
87138 +
87139 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
87140 + return;
87141 +
87142 + spin_lock(&mm->page_table_lock);
87143 + oldlimit = mm->context.user_cs_limit;
87144 + if ((prot & VM_EXEC) && oldlimit < end)
87145 + /* USER_CS limit moved up */
87146 + newlimit = end;
87147 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
87148 + /* USER_CS limit moved down */
87149 + newlimit = start;
87150 +
87151 + if (newlimit) {
87152 + mm->context.user_cs_limit = newlimit;
87153 +
87154 +#ifdef CONFIG_SMP
87155 + wmb();
87156 + cpus_clear(mm->context.cpu_user_cs_mask);
87157 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
87158 +#endif
87159 +
87160 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
87161 + }
87162 + spin_unlock(&mm->page_table_lock);
87163 + if (newlimit == end) {
87164 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
87165 +
87166 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
87167 + if (is_vm_hugetlb_page(vma))
87168 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
87169 + else
87170 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
87171 + }
87172 +}
87173 +#endif
87174 +
87175 int
87176 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
87177 unsigned long start, unsigned long end, unsigned long newflags)
87178 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
87179 int error;
87180 int dirty_accountable = 0;
87181
87182 +#ifdef CONFIG_PAX_SEGMEXEC
87183 + struct vm_area_struct *vma_m = NULL;
87184 + unsigned long start_m, end_m;
87185 +
87186 + start_m = start + SEGMEXEC_TASK_SIZE;
87187 + end_m = end + SEGMEXEC_TASK_SIZE;
87188 +#endif
87189 +
87190 if (newflags == oldflags) {
87191 *pprev = vma;
87192 return 0;
87193 }
87194
87195 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
87196 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
87197 +
87198 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
87199 + return -ENOMEM;
87200 +
87201 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
87202 + return -ENOMEM;
87203 + }
87204 +
87205 /*
87206 * If we make a private mapping writable we increase our commit;
87207 * but (without finer accounting) cannot reduce our commit if we
87208 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
87209 }
87210 }
87211
87212 +#ifdef CONFIG_PAX_SEGMEXEC
87213 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
87214 + if (start != vma->vm_start) {
87215 + error = split_vma(mm, vma, start, 1);
87216 + if (error)
87217 + goto fail;
87218 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
87219 + *pprev = (*pprev)->vm_next;
87220 + }
87221 +
87222 + if (end != vma->vm_end) {
87223 + error = split_vma(mm, vma, end, 0);
87224 + if (error)
87225 + goto fail;
87226 + }
87227 +
87228 + if (pax_find_mirror_vma(vma)) {
87229 + error = __do_munmap(mm, start_m, end_m - start_m);
87230 + if (error)
87231 + goto fail;
87232 + } else {
87233 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87234 + if (!vma_m) {
87235 + error = -ENOMEM;
87236 + goto fail;
87237 + }
87238 + vma->vm_flags = newflags;
87239 + error = pax_mirror_vma(vma_m, vma);
87240 + if (error) {
87241 + vma->vm_flags = oldflags;
87242 + goto fail;
87243 + }
87244 + }
87245 + }
87246 +#endif
87247 +
87248 /*
87249 * First try to merge with previous and/or next vma.
87250 */
87251 @@ -296,9 +400,21 @@ success:
87252 * vm_flags and vm_page_prot are protected by the mmap_sem
87253 * held in write mode.
87254 */
87255 +
87256 +#ifdef CONFIG_PAX_SEGMEXEC
87257 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
87258 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
87259 +#endif
87260 +
87261 vma->vm_flags = newflags;
87262 +
87263 +#ifdef CONFIG_PAX_MPROTECT
87264 + if (mm->binfmt && mm->binfmt->handle_mprotect)
87265 + mm->binfmt->handle_mprotect(vma, newflags);
87266 +#endif
87267 +
87268 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
87269 - vm_get_page_prot(newflags));
87270 + vm_get_page_prot(vma->vm_flags));
87271
87272 if (vma_wants_writenotify(vma)) {
87273 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
87274 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
87275 end = start + len;
87276 if (end <= start)
87277 return -ENOMEM;
87278 +
87279 +#ifdef CONFIG_PAX_SEGMEXEC
87280 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
87281 + if (end > SEGMEXEC_TASK_SIZE)
87282 + return -EINVAL;
87283 + } else
87284 +#endif
87285 +
87286 + if (end > TASK_SIZE)
87287 + return -EINVAL;
87288 +
87289 if (!arch_validate_prot(prot))
87290 return -EINVAL;
87291
87292 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
87293 /*
87294 * Does the application expect PROT_READ to imply PROT_EXEC:
87295 */
87296 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87297 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87298 prot |= PROT_EXEC;
87299
87300 vm_flags = calc_vm_prot_bits(prot);
87301 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
87302 if (start > vma->vm_start)
87303 prev = vma;
87304
87305 +#ifdef CONFIG_PAX_MPROTECT
87306 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
87307 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
87308 +#endif
87309 +
87310 for (nstart = start ; ; ) {
87311 unsigned long newflags;
87312
87313 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
87314
87315 /* newflags >> 4 shift VM_MAY% in place of VM_% */
87316 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
87317 + if (prot & (PROT_WRITE | PROT_EXEC))
87318 + gr_log_rwxmprotect(vma);
87319 +
87320 + error = -EACCES;
87321 + goto out;
87322 + }
87323 +
87324 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
87325 error = -EACCES;
87326 goto out;
87327 }
87328 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
87329 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
87330 if (error)
87331 goto out;
87332 +
87333 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
87334 +
87335 nstart = tmp;
87336
87337 if (nstart < prev->vm_end)
87338 diff --git a/mm/mremap.c b/mm/mremap.c
87339 index 463a257..c0c7a92 100644
87340 --- a/mm/mremap.c
87341 +++ b/mm/mremap.c
87342 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
87343 continue;
87344 pte = ptep_get_and_clear(mm, old_addr, old_pte);
87345 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
87346 +
87347 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
87348 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
87349 + pte = pte_exprotect(pte);
87350 +#endif
87351 +
87352 set_pte_at(mm, new_addr, new_pte, pte);
87353 }
87354
87355 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
87356 if (is_vm_hugetlb_page(vma))
87357 goto Einval;
87358
87359 +#ifdef CONFIG_PAX_SEGMEXEC
87360 + if (pax_find_mirror_vma(vma))
87361 + goto Einval;
87362 +#endif
87363 +
87364 /* We can't remap across vm area boundaries */
87365 if (old_len > vma->vm_end - addr)
87366 goto Efault;
87367 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
87368 unsigned long ret = -EINVAL;
87369 unsigned long charged = 0;
87370 unsigned long map_flags;
87371 + unsigned long pax_task_size = TASK_SIZE;
87372
87373 if (new_addr & ~PAGE_MASK)
87374 goto out;
87375
87376 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
87377 +#ifdef CONFIG_PAX_SEGMEXEC
87378 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
87379 + pax_task_size = SEGMEXEC_TASK_SIZE;
87380 +#endif
87381 +
87382 + pax_task_size -= PAGE_SIZE;
87383 +
87384 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
87385 goto out;
87386
87387 /* Check if the location we're moving into overlaps the
87388 * old location at all, and fail if it does.
87389 */
87390 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
87391 - goto out;
87392 -
87393 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
87394 + if (addr + old_len > new_addr && new_addr + new_len > addr)
87395 goto out;
87396
87397 ret = do_munmap(mm, new_addr, new_len);
87398 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
87399 unsigned long ret = -EINVAL;
87400 unsigned long charged = 0;
87401 bool locked = false;
87402 + unsigned long pax_task_size = TASK_SIZE;
87403
87404 down_write(&current->mm->mmap_sem);
87405
87406 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
87407 if (!new_len)
87408 goto out;
87409
87410 +#ifdef CONFIG_PAX_SEGMEXEC
87411 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
87412 + pax_task_size = SEGMEXEC_TASK_SIZE;
87413 +#endif
87414 +
87415 + pax_task_size -= PAGE_SIZE;
87416 +
87417 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
87418 + old_len > pax_task_size || addr > pax_task_size-old_len)
87419 + goto out;
87420 +
87421 if (flags & MREMAP_FIXED) {
87422 if (flags & MREMAP_MAYMOVE)
87423 ret = mremap_to(addr, old_len, new_addr, new_len,
87424 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
87425 new_addr = addr;
87426 }
87427 ret = addr;
87428 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
87429 goto out;
87430 }
87431 }
87432 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
87433 goto out;
87434 }
87435
87436 + map_flags = vma->vm_flags;
87437 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
87438 + if (!(ret & ~PAGE_MASK)) {
87439 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
87440 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
87441 + }
87442 }
87443 out:
87444 if (ret & ~PAGE_MASK)
87445 diff --git a/mm/nommu.c b/mm/nommu.c
87446 index 298884d..5f74980 100644
87447 --- a/mm/nommu.c
87448 +++ b/mm/nommu.c
87449 @@ -65,7 +65,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
87450 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
87451 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
87452 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
87453 -int heap_stack_gap = 0;
87454
87455 atomic_long_t mmap_pages_allocated;
87456
87457 @@ -842,15 +841,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
87458 EXPORT_SYMBOL(find_vma);
87459
87460 /*
87461 - * find a VMA
87462 - * - we don't extend stack VMAs under NOMMU conditions
87463 - */
87464 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
87465 -{
87466 - return find_vma(mm, addr);
87467 -}
87468 -
87469 -/*
87470 * expand a stack to a given address
87471 * - not supported under NOMMU conditions
87472 */
87473 @@ -1561,6 +1551,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
87474
87475 /* most fields are the same, copy all, and then fixup */
87476 *new = *vma;
87477 + INIT_LIST_HEAD(&new->anon_vma_chain);
87478 *region = *vma->vm_region;
87479 new->vm_region = region;
87480
87481 @@ -1995,8 +1986,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
87482 }
87483 EXPORT_SYMBOL(generic_file_remap_pages);
87484
87485 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87486 - unsigned long addr, void *buf, int len, int write)
87487 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87488 + unsigned long addr, void *buf, size_t len, int write)
87489 {
87490 struct vm_area_struct *vma;
87491
87492 @@ -2037,8 +2028,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87493 *
87494 * The caller must hold a reference on @mm.
87495 */
87496 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87497 - void *buf, int len, int write)
87498 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
87499 + void *buf, size_t len, int write)
87500 {
87501 return __access_remote_vm(NULL, mm, addr, buf, len, write);
87502 }
87503 @@ -2047,7 +2038,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87504 * Access another process' address space.
87505 * - source/target buffer must be kernel space
87506 */
87507 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
87508 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
87509 {
87510 struct mm_struct *mm;
87511
87512 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
87513 index 4514ad7..92eaa1c 100644
87514 --- a/mm/page-writeback.c
87515 +++ b/mm/page-writeback.c
87516 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
87517 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
87518 * - the bdi dirty thresh drops quickly due to change of JBOD workload
87519 */
87520 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
87521 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
87522 unsigned long thresh,
87523 unsigned long bg_thresh,
87524 unsigned long dirty,
87525 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
87526 }
87527 }
87528
87529 -static struct notifier_block __cpuinitdata ratelimit_nb = {
87530 +static struct notifier_block ratelimit_nb = {
87531 .notifier_call = ratelimit_handler,
87532 .next = NULL,
87533 };
87534 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
87535 index 2ee0fd3..6e2edfb 100644
87536 --- a/mm/page_alloc.c
87537 +++ b/mm/page_alloc.c
87538 @@ -60,6 +60,7 @@
87539 #include <linux/page-debug-flags.h>
87540 #include <linux/hugetlb.h>
87541 #include <linux/sched/rt.h>
87542 +#include <linux/random.h>
87543
87544 #include <asm/tlbflush.h>
87545 #include <asm/div64.h>
87546 @@ -345,7 +346,7 @@ out:
87547 * This usage means that zero-order pages may not be compound.
87548 */
87549
87550 -static void free_compound_page(struct page *page)
87551 +void free_compound_page(struct page *page)
87552 {
87553 __free_pages_ok(page, compound_order(page));
87554 }
87555 @@ -702,6 +703,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
87556 int i;
87557 int bad = 0;
87558
87559 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
87560 + unsigned long index = 1UL << order;
87561 +#endif
87562 +
87563 trace_mm_page_free(page, order);
87564 kmemcheck_free_shadow(page, order);
87565
87566 @@ -717,6 +722,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
87567 debug_check_no_obj_freed(page_address(page),
87568 PAGE_SIZE << order);
87569 }
87570 +
87571 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
87572 + for (; index; --index)
87573 + sanitize_highpage(page + index - 1);
87574 +#endif
87575 +
87576 arch_free_page(page, order);
87577 kernel_map_pages(page, 1 << order, 0);
87578
87579 @@ -739,6 +750,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
87580 local_irq_restore(flags);
87581 }
87582
87583 +#ifdef CONFIG_PAX_LATENT_ENTROPY
87584 +bool __meminitdata extra_latent_entropy;
87585 +
87586 +static int __init setup_pax_extra_latent_entropy(char *str)
87587 +{
87588 + extra_latent_entropy = true;
87589 + return 0;
87590 +}
87591 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
87592 +
87593 +volatile u64 latent_entropy;
87594 +#endif
87595 +
87596 /*
87597 * Read access to zone->managed_pages is safe because it's unsigned long,
87598 * but we still need to serialize writers. Currently all callers of
87599 @@ -761,6 +785,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
87600 set_page_count(p, 0);
87601 }
87602
87603 +#ifdef CONFIG_PAX_LATENT_ENTROPY
87604 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
87605 + u64 hash = 0;
87606 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
87607 + const u64 *data = lowmem_page_address(page);
87608 +
87609 + for (index = 0; index < end; index++)
87610 + hash ^= hash + data[index];
87611 + latent_entropy ^= hash;
87612 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
87613 + }
87614 +#endif
87615 +
87616 page_zone(page)->managed_pages += 1 << order;
87617 set_page_refcounted(page);
87618 __free_pages(page, order);
87619 @@ -870,8 +907,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
87620 arch_alloc_page(page, order);
87621 kernel_map_pages(page, 1 << order, 1);
87622
87623 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
87624 if (gfp_flags & __GFP_ZERO)
87625 prep_zero_page(page, order, gfp_flags);
87626 +#endif
87627
87628 if (order && (gfp_flags & __GFP_COMP))
87629 prep_compound_page(page, order);
87630 diff --git a/mm/page_io.c b/mm/page_io.c
87631 index a8a3ef4..7260a60 100644
87632 --- a/mm/page_io.c
87633 +++ b/mm/page_io.c
87634 @@ -214,7 +214,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
87635 struct file *swap_file = sis->swap_file;
87636 struct address_space *mapping = swap_file->f_mapping;
87637 struct iovec iov = {
87638 - .iov_base = kmap(page),
87639 + .iov_base = (void __force_user *)kmap(page),
87640 .iov_len = PAGE_SIZE,
87641 };
87642
87643 diff --git a/mm/percpu.c b/mm/percpu.c
87644 index 8c8e08f..73a5cda 100644
87645 --- a/mm/percpu.c
87646 +++ b/mm/percpu.c
87647 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
87648 static unsigned int pcpu_high_unit_cpu __read_mostly;
87649
87650 /* the address of the first chunk which starts with the kernel static area */
87651 -void *pcpu_base_addr __read_mostly;
87652 +void *pcpu_base_addr __read_only;
87653 EXPORT_SYMBOL_GPL(pcpu_base_addr);
87654
87655 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
87656 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
87657 index fd26d04..0cea1b0 100644
87658 --- a/mm/process_vm_access.c
87659 +++ b/mm/process_vm_access.c
87660 @@ -13,6 +13,7 @@
87661 #include <linux/uio.h>
87662 #include <linux/sched.h>
87663 #include <linux/highmem.h>
87664 +#include <linux/security.h>
87665 #include <linux/ptrace.h>
87666 #include <linux/slab.h>
87667 #include <linux/syscalls.h>
87668 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
87669 size_t iov_l_curr_offset = 0;
87670 ssize_t iov_len;
87671
87672 + return -ENOSYS; // PaX: until properly audited
87673 +
87674 /*
87675 * Work out how many pages of struct pages we're going to need
87676 * when eventually calling get_user_pages
87677 */
87678 for (i = 0; i < riovcnt; i++) {
87679 iov_len = rvec[i].iov_len;
87680 - if (iov_len > 0) {
87681 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
87682 - + iov_len)
87683 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
87684 - / PAGE_SIZE + 1;
87685 - nr_pages = max(nr_pages, nr_pages_iov);
87686 - }
87687 + if (iov_len <= 0)
87688 + continue;
87689 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
87690 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
87691 + nr_pages = max(nr_pages, nr_pages_iov);
87692 }
87693
87694 if (nr_pages == 0)
87695 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
87696 goto free_proc_pages;
87697 }
87698
87699 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
87700 + rc = -EPERM;
87701 + goto put_task_struct;
87702 + }
87703 +
87704 mm = mm_access(task, PTRACE_MODE_ATTACH);
87705 if (!mm || IS_ERR(mm)) {
87706 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
87707 diff --git a/mm/rmap.c b/mm/rmap.c
87708 index 6280da8..b5c090e 100644
87709 --- a/mm/rmap.c
87710 +++ b/mm/rmap.c
87711 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
87712 struct anon_vma *anon_vma = vma->anon_vma;
87713 struct anon_vma_chain *avc;
87714
87715 +#ifdef CONFIG_PAX_SEGMEXEC
87716 + struct anon_vma_chain *avc_m = NULL;
87717 +#endif
87718 +
87719 might_sleep();
87720 if (unlikely(!anon_vma)) {
87721 struct mm_struct *mm = vma->vm_mm;
87722 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
87723 if (!avc)
87724 goto out_enomem;
87725
87726 +#ifdef CONFIG_PAX_SEGMEXEC
87727 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
87728 + if (!avc_m)
87729 + goto out_enomem_free_avc;
87730 +#endif
87731 +
87732 anon_vma = find_mergeable_anon_vma(vma);
87733 allocated = NULL;
87734 if (!anon_vma) {
87735 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
87736 /* page_table_lock to protect against threads */
87737 spin_lock(&mm->page_table_lock);
87738 if (likely(!vma->anon_vma)) {
87739 +
87740 +#ifdef CONFIG_PAX_SEGMEXEC
87741 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
87742 +
87743 + if (vma_m) {
87744 + BUG_ON(vma_m->anon_vma);
87745 + vma_m->anon_vma = anon_vma;
87746 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
87747 + avc_m = NULL;
87748 + }
87749 +#endif
87750 +
87751 vma->anon_vma = anon_vma;
87752 anon_vma_chain_link(vma, avc, anon_vma);
87753 allocated = NULL;
87754 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
87755
87756 if (unlikely(allocated))
87757 put_anon_vma(allocated);
87758 +
87759 +#ifdef CONFIG_PAX_SEGMEXEC
87760 + if (unlikely(avc_m))
87761 + anon_vma_chain_free(avc_m);
87762 +#endif
87763 +
87764 if (unlikely(avc))
87765 anon_vma_chain_free(avc);
87766 }
87767 return 0;
87768
87769 out_enomem_free_avc:
87770 +
87771 +#ifdef CONFIG_PAX_SEGMEXEC
87772 + if (avc_m)
87773 + anon_vma_chain_free(avc_m);
87774 +#endif
87775 +
87776 anon_vma_chain_free(avc);
87777 out_enomem:
87778 return -ENOMEM;
87779 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
87780 * Attach the anon_vmas from src to dst.
87781 * Returns 0 on success, -ENOMEM on failure.
87782 */
87783 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
87784 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
87785 {
87786 struct anon_vma_chain *avc, *pavc;
87787 struct anon_vma *root = NULL;
87788 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
87789 * the corresponding VMA in the parent process is attached to.
87790 * Returns 0 on success, non-zero on failure.
87791 */
87792 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
87793 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
87794 {
87795 struct anon_vma_chain *avc;
87796 struct anon_vma *anon_vma;
87797 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
87798 void __init anon_vma_init(void)
87799 {
87800 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
87801 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
87802 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
87803 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
87804 + anon_vma_ctor);
87805 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
87806 + SLAB_PANIC|SLAB_NO_SANITIZE);
87807 }
87808
87809 /*
87810 diff --git a/mm/shmem.c b/mm/shmem.c
87811 index 5e6a842..b41916e 100644
87812 --- a/mm/shmem.c
87813 +++ b/mm/shmem.c
87814 @@ -33,7 +33,7 @@
87815 #include <linux/swap.h>
87816 #include <linux/aio.h>
87817
87818 -static struct vfsmount *shm_mnt;
87819 +struct vfsmount *shm_mnt;
87820
87821 #ifdef CONFIG_SHMEM
87822 /*
87823 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
87824 #define BOGO_DIRENT_SIZE 20
87825
87826 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
87827 -#define SHORT_SYMLINK_LEN 128
87828 +#define SHORT_SYMLINK_LEN 64
87829
87830 /*
87831 * shmem_fallocate and shmem_writepage communicate via inode->i_private
87832 @@ -2203,6 +2203,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
87833 static int shmem_xattr_validate(const char *name)
87834 {
87835 struct { const char *prefix; size_t len; } arr[] = {
87836 +
87837 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
87838 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
87839 +#endif
87840 +
87841 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
87842 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
87843 };
87844 @@ -2258,6 +2263,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
87845 if (err)
87846 return err;
87847
87848 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
87849 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
87850 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
87851 + return -EOPNOTSUPP;
87852 + if (size > 8)
87853 + return -EINVAL;
87854 + }
87855 +#endif
87856 +
87857 return simple_xattr_set(&info->xattrs, name, value, size, flags);
87858 }
87859
87860 @@ -2570,8 +2584,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
87861 int err = -ENOMEM;
87862
87863 /* Round up to L1_CACHE_BYTES to resist false sharing */
87864 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
87865 - L1_CACHE_BYTES), GFP_KERNEL);
87866 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
87867 if (!sbinfo)
87868 return -ENOMEM;
87869
87870 diff --git a/mm/slab.c b/mm/slab.c
87871 index bd88411..2d46fd6 100644
87872 --- a/mm/slab.c
87873 +++ b/mm/slab.c
87874 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
87875 if ((x)->max_freeable < i) \
87876 (x)->max_freeable = i; \
87877 } while (0)
87878 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
87879 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
87880 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
87881 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
87882 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
87883 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
87884 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
87885 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
87886 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
87887 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
87888 #else
87889 #define STATS_INC_ACTIVE(x) do { } while (0)
87890 #define STATS_DEC_ACTIVE(x) do { } while (0)
87891 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
87892 #define STATS_INC_ALLOCMISS(x) do { } while (0)
87893 #define STATS_INC_FREEHIT(x) do { } while (0)
87894 #define STATS_INC_FREEMISS(x) do { } while (0)
87895 +#define STATS_INC_SANITIZED(x) do { } while (0)
87896 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
87897 #endif
87898
87899 #if DEBUG
87900 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
87901 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
87902 */
87903 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
87904 - const struct slab *slab, void *obj)
87905 + const struct slab *slab, const void *obj)
87906 {
87907 u32 offset = (obj - slab->s_mem);
87908 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
87909 @@ -1384,7 +1388,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
87910 return notifier_from_errno(err);
87911 }
87912
87913 -static struct notifier_block __cpuinitdata cpucache_notifier = {
87914 +static struct notifier_block cpucache_notifier = {
87915 &cpuup_callback, NULL, 0
87916 };
87917
87918 @@ -1565,12 +1569,12 @@ void __init kmem_cache_init(void)
87919 */
87920
87921 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
87922 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
87923 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
87924
87925 if (INDEX_AC != INDEX_NODE)
87926 kmalloc_caches[INDEX_NODE] =
87927 create_kmalloc_cache("kmalloc-node",
87928 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
87929 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
87930
87931 slab_early_init = 0;
87932
87933 @@ -3583,6 +3587,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
87934 struct array_cache *ac = cpu_cache_get(cachep);
87935
87936 check_irq_off();
87937 +
87938 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
87939 + if (pax_sanitize_slab) {
87940 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
87941 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
87942 +
87943 + if (cachep->ctor)
87944 + cachep->ctor(objp);
87945 +
87946 + STATS_INC_SANITIZED(cachep);
87947 + } else
87948 + STATS_INC_NOT_SANITIZED(cachep);
87949 + }
87950 +#endif
87951 +
87952 kmemleak_free_recursive(objp, cachep->flags);
87953 objp = cache_free_debugcheck(cachep, objp, caller);
87954
87955 @@ -3800,6 +3819,7 @@ void kfree(const void *objp)
87956
87957 if (unlikely(ZERO_OR_NULL_PTR(objp)))
87958 return;
87959 + VM_BUG_ON(!virt_addr_valid(objp));
87960 local_irq_save(flags);
87961 kfree_debugcheck(objp);
87962 c = virt_to_cache(objp);
87963 @@ -4241,14 +4261,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
87964 }
87965 /* cpu stats */
87966 {
87967 - unsigned long allochit = atomic_read(&cachep->allochit);
87968 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
87969 - unsigned long freehit = atomic_read(&cachep->freehit);
87970 - unsigned long freemiss = atomic_read(&cachep->freemiss);
87971 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
87972 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
87973 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
87974 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
87975
87976 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
87977 allochit, allocmiss, freehit, freemiss);
87978 }
87979 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
87980 + {
87981 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
87982 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
87983 +
87984 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
87985 + }
87986 +#endif
87987 #endif
87988 }
87989
87990 @@ -4476,13 +4504,71 @@ static const struct file_operations proc_slabstats_operations = {
87991 static int __init slab_proc_init(void)
87992 {
87993 #ifdef CONFIG_DEBUG_SLAB_LEAK
87994 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
87995 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
87996 #endif
87997 return 0;
87998 }
87999 module_init(slab_proc_init);
88000 #endif
88001
88002 +bool is_usercopy_object(const void *ptr)
88003 +{
88004 + struct page *page;
88005 + struct kmem_cache *cachep;
88006 +
88007 + if (ZERO_OR_NULL_PTR(ptr))
88008 + return false;
88009 +
88010 + if (!slab_is_available())
88011 + return false;
88012 +
88013 + if (!virt_addr_valid(ptr))
88014 + return false;
88015 +
88016 + page = virt_to_head_page(ptr);
88017 +
88018 + if (!PageSlab(page))
88019 + return false;
88020 +
88021 + cachep = page->slab_cache;
88022 + return cachep->flags & SLAB_USERCOPY;
88023 +}
88024 +
88025 +#ifdef CONFIG_PAX_USERCOPY
88026 +const char *check_heap_object(const void *ptr, unsigned long n)
88027 +{
88028 + struct page *page;
88029 + struct kmem_cache *cachep;
88030 + struct slab *slabp;
88031 + unsigned int objnr;
88032 + unsigned long offset;
88033 +
88034 + if (ZERO_OR_NULL_PTR(ptr))
88035 + return "<null>";
88036 +
88037 + if (!virt_addr_valid(ptr))
88038 + return NULL;
88039 +
88040 + page = virt_to_head_page(ptr);
88041 +
88042 + if (!PageSlab(page))
88043 + return NULL;
88044 +
88045 + cachep = page->slab_cache;
88046 + if (!(cachep->flags & SLAB_USERCOPY))
88047 + return cachep->name;
88048 +
88049 + slabp = page->slab_page;
88050 + objnr = obj_to_index(cachep, slabp, ptr);
88051 + BUG_ON(objnr >= cachep->num);
88052 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
88053 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
88054 + return NULL;
88055 +
88056 + return cachep->name;
88057 +}
88058 +#endif
88059 +
88060 /**
88061 * ksize - get the actual amount of memory allocated for a given object
88062 * @objp: Pointer to the object
88063 diff --git a/mm/slab.h b/mm/slab.h
88064 index f96b49e..db1d204 100644
88065 --- a/mm/slab.h
88066 +++ b/mm/slab.h
88067 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
88068 /* The slab cache that manages slab cache information */
88069 extern struct kmem_cache *kmem_cache;
88070
88071 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88072 +#ifdef CONFIG_X86_64
88073 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
88074 +#else
88075 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
88076 +#endif
88077 +extern bool pax_sanitize_slab;
88078 +#endif
88079 +
88080 unsigned long calculate_alignment(unsigned long flags,
88081 unsigned long align, unsigned long size);
88082
88083 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
88084
88085 /* Legal flag mask for kmem_cache_create(), for various configurations */
88086 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
88087 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
88088 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
88089 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
88090
88091 #if defined(CONFIG_DEBUG_SLAB)
88092 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
88093 @@ -229,6 +239,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
88094 return s;
88095
88096 page = virt_to_head_page(x);
88097 +
88098 + BUG_ON(!PageSlab(page));
88099 +
88100 cachep = page->slab_cache;
88101 if (slab_equal_or_root(cachep, s))
88102 return cachep;
88103 diff --git a/mm/slab_common.c b/mm/slab_common.c
88104 index 2d41450..4efe6ee 100644
88105 --- a/mm/slab_common.c
88106 +++ b/mm/slab_common.c
88107 @@ -22,11 +22,22 @@
88108
88109 #include "slab.h"
88110
88111 -enum slab_state slab_state;
88112 +enum slab_state slab_state __read_only;
88113 LIST_HEAD(slab_caches);
88114 DEFINE_MUTEX(slab_mutex);
88115 struct kmem_cache *kmem_cache;
88116
88117 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88118 +bool pax_sanitize_slab __read_only = true;
88119 +static int __init pax_sanitize_slab_setup(char *str)
88120 +{
88121 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
88122 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
88123 + return 1;
88124 +}
88125 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
88126 +#endif
88127 +
88128 #ifdef CONFIG_DEBUG_VM
88129 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
88130 size_t size)
88131 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
88132
88133 err = __kmem_cache_create(s, flags);
88134 if (!err) {
88135 - s->refcount = 1;
88136 + atomic_set(&s->refcount, 1);
88137 list_add(&s->list, &slab_caches);
88138 memcg_cache_list_add(memcg, s);
88139 } else {
88140 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
88141
88142 get_online_cpus();
88143 mutex_lock(&slab_mutex);
88144 - s->refcount--;
88145 - if (!s->refcount) {
88146 + if (atomic_dec_and_test(&s->refcount)) {
88147 list_del(&s->list);
88148
88149 if (!__kmem_cache_shutdown(s)) {
88150 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
88151 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
88152 name, size, err);
88153
88154 - s->refcount = -1; /* Exempt from merging for now */
88155 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
88156 }
88157
88158 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
88159 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
88160
88161 create_boot_cache(s, name, size, flags);
88162 list_add(&s->list, &slab_caches);
88163 - s->refcount = 1;
88164 + atomic_set(&s->refcount, 1);
88165 return s;
88166 }
88167
88168 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
88169 EXPORT_SYMBOL(kmalloc_dma_caches);
88170 #endif
88171
88172 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88173 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
88174 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
88175 +#endif
88176 +
88177 /*
88178 * Conversion table for small slabs sizes / 8 to the index in the
88179 * kmalloc array. This is necessary for slabs < 192 since we have non power
88180 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
88181 return kmalloc_dma_caches[index];
88182
88183 #endif
88184 +
88185 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88186 + if (unlikely((flags & GFP_USERCOPY)))
88187 + return kmalloc_usercopy_caches[index];
88188 +
88189 +#endif
88190 +
88191 return kmalloc_caches[index];
88192 }
88193
88194 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
88195 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
88196 if (!kmalloc_caches[i]) {
88197 kmalloc_caches[i] = create_kmalloc_cache(NULL,
88198 - 1 << i, flags);
88199 + 1 << i, SLAB_USERCOPY | flags);
88200 }
88201
88202 /*
88203 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
88204 * earlier power of two caches
88205 */
88206 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
88207 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
88208 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
88209
88210 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
88211 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
88212 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
88213 }
88214
88215 /* Kmalloc array is now usable */
88216 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
88217 }
88218 }
88219 #endif
88220 +
88221 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88222 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
88223 + struct kmem_cache *s = kmalloc_caches[i];
88224 +
88225 + if (s) {
88226 + int size = kmalloc_size(i);
88227 + char *n = kasprintf(GFP_NOWAIT,
88228 + "usercopy-kmalloc-%d", size);
88229 +
88230 + BUG_ON(!n);
88231 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
88232 + size, SLAB_USERCOPY | flags);
88233 + }
88234 + }
88235 +#endif
88236 +
88237 }
88238 #endif /* !CONFIG_SLOB */
88239
88240 @@ -516,6 +555,9 @@ void print_slabinfo_header(struct seq_file *m)
88241 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
88242 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
88243 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
88244 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88245 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
88246 +#endif
88247 #endif
88248 seq_putc(m, '\n');
88249 }
88250 diff --git a/mm/slob.c b/mm/slob.c
88251 index eeed4a0..bb0e9ab 100644
88252 --- a/mm/slob.c
88253 +++ b/mm/slob.c
88254 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
88255 /*
88256 * Return the size of a slob block.
88257 */
88258 -static slobidx_t slob_units(slob_t *s)
88259 +static slobidx_t slob_units(const slob_t *s)
88260 {
88261 if (s->units > 0)
88262 return s->units;
88263 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
88264 /*
88265 * Return the next free slob block pointer after this one.
88266 */
88267 -static slob_t *slob_next(slob_t *s)
88268 +static slob_t *slob_next(const slob_t *s)
88269 {
88270 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
88271 slobidx_t next;
88272 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
88273 /*
88274 * Returns true if s is the last free block in its page.
88275 */
88276 -static int slob_last(slob_t *s)
88277 +static int slob_last(const slob_t *s)
88278 {
88279 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
88280 }
88281
88282 -static void *slob_new_pages(gfp_t gfp, int order, int node)
88283 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
88284 {
88285 - void *page;
88286 + struct page *page;
88287
88288 #ifdef CONFIG_NUMA
88289 if (node != NUMA_NO_NODE)
88290 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
88291 if (!page)
88292 return NULL;
88293
88294 - return page_address(page);
88295 + __SetPageSlab(page);
88296 + return page;
88297 }
88298
88299 -static void slob_free_pages(void *b, int order)
88300 +static void slob_free_pages(struct page *sp, int order)
88301 {
88302 if (current->reclaim_state)
88303 current->reclaim_state->reclaimed_slab += 1 << order;
88304 - free_pages((unsigned long)b, order);
88305 + __ClearPageSlab(sp);
88306 + page_mapcount_reset(sp);
88307 + sp->private = 0;
88308 + __free_pages(sp, order);
88309 }
88310
88311 /*
88312 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
88313
88314 /* Not enough space: must allocate a new page */
88315 if (!b) {
88316 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
88317 - if (!b)
88318 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
88319 + if (!sp)
88320 return NULL;
88321 - sp = virt_to_page(b);
88322 - __SetPageSlab(sp);
88323 + b = page_address(sp);
88324
88325 spin_lock_irqsave(&slob_lock, flags);
88326 sp->units = SLOB_UNITS(PAGE_SIZE);
88327 sp->freelist = b;
88328 + sp->private = 0;
88329 INIT_LIST_HEAD(&sp->list);
88330 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
88331 set_slob_page_free(sp, slob_list);
88332 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
88333 if (slob_page_free(sp))
88334 clear_slob_page_free(sp);
88335 spin_unlock_irqrestore(&slob_lock, flags);
88336 - __ClearPageSlab(sp);
88337 - page_mapcount_reset(sp);
88338 - slob_free_pages(b, 0);
88339 + slob_free_pages(sp, 0);
88340 return;
88341 }
88342
88343 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88344 + if (pax_sanitize_slab)
88345 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
88346 +#endif
88347 +
88348 if (!slob_page_free(sp)) {
88349 /* This slob page is about to become partially free. Easy! */
88350 sp->units = units;
88351 @@ -424,11 +431,10 @@ out:
88352 */
88353
88354 static __always_inline void *
88355 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
88356 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
88357 {
88358 - unsigned int *m;
88359 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
88360 - void *ret;
88361 + slob_t *m;
88362 + void *ret = NULL;
88363
88364 gfp &= gfp_allowed_mask;
88365
88366 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
88367
88368 if (!m)
88369 return NULL;
88370 - *m = size;
88371 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
88372 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
88373 + m[0].units = size;
88374 + m[1].units = align;
88375 ret = (void *)m + align;
88376
88377 trace_kmalloc_node(caller, ret,
88378 size, size + align, gfp, node);
88379 } else {
88380 unsigned int order = get_order(size);
88381 + struct page *page;
88382
88383 if (likely(order))
88384 gfp |= __GFP_COMP;
88385 - ret = slob_new_pages(gfp, order, node);
88386 + page = slob_new_pages(gfp, order, node);
88387 + if (page) {
88388 + ret = page_address(page);
88389 + page->private = size;
88390 + }
88391
88392 trace_kmalloc_node(caller, ret,
88393 size, PAGE_SIZE << order, gfp, node);
88394 }
88395
88396 - kmemleak_alloc(ret, size, 1, gfp);
88397 + return ret;
88398 +}
88399 +
88400 +static __always_inline void *
88401 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
88402 +{
88403 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
88404 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
88405 +
88406 + if (!ZERO_OR_NULL_PTR(ret))
88407 + kmemleak_alloc(ret, size, 1, gfp);
88408 return ret;
88409 }
88410
88411 @@ -493,34 +517,112 @@ void kfree(const void *block)
88412 return;
88413 kmemleak_free(block);
88414
88415 + VM_BUG_ON(!virt_addr_valid(block));
88416 sp = virt_to_page(block);
88417 - if (PageSlab(sp)) {
88418 + VM_BUG_ON(!PageSlab(sp));
88419 + if (!sp->private) {
88420 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
88421 - unsigned int *m = (unsigned int *)(block - align);
88422 - slob_free(m, *m + align);
88423 - } else
88424 + slob_t *m = (slob_t *)(block - align);
88425 + slob_free(m, m[0].units + align);
88426 + } else {
88427 + __ClearPageSlab(sp);
88428 + page_mapcount_reset(sp);
88429 + sp->private = 0;
88430 __free_pages(sp, compound_order(sp));
88431 + }
88432 }
88433 EXPORT_SYMBOL(kfree);
88434
88435 +bool is_usercopy_object(const void *ptr)
88436 +{
88437 + if (!slab_is_available())
88438 + return false;
88439 +
88440 + // PAX: TODO
88441 +
88442 + return false;
88443 +}
88444 +
88445 +#ifdef CONFIG_PAX_USERCOPY
88446 +const char *check_heap_object(const void *ptr, unsigned long n)
88447 +{
88448 + struct page *page;
88449 + const slob_t *free;
88450 + const void *base;
88451 + unsigned long flags;
88452 +
88453 + if (ZERO_OR_NULL_PTR(ptr))
88454 + return "<null>";
88455 +
88456 + if (!virt_addr_valid(ptr))
88457 + return NULL;
88458 +
88459 + page = virt_to_head_page(ptr);
88460 + if (!PageSlab(page))
88461 + return NULL;
88462 +
88463 + if (page->private) {
88464 + base = page;
88465 + if (base <= ptr && n <= page->private - (ptr - base))
88466 + return NULL;
88467 + return "<slob>";
88468 + }
88469 +
88470 + /* some tricky double walking to find the chunk */
88471 + spin_lock_irqsave(&slob_lock, flags);
88472 + base = (void *)((unsigned long)ptr & PAGE_MASK);
88473 + free = page->freelist;
88474 +
88475 + while (!slob_last(free) && (void *)free <= ptr) {
88476 + base = free + slob_units(free);
88477 + free = slob_next(free);
88478 + }
88479 +
88480 + while (base < (void *)free) {
88481 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
88482 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
88483 + int offset;
88484 +
88485 + if (ptr < base + align)
88486 + break;
88487 +
88488 + offset = ptr - base - align;
88489 + if (offset >= m) {
88490 + base += size;
88491 + continue;
88492 + }
88493 +
88494 + if (n > m - offset)
88495 + break;
88496 +
88497 + spin_unlock_irqrestore(&slob_lock, flags);
88498 + return NULL;
88499 + }
88500 +
88501 + spin_unlock_irqrestore(&slob_lock, flags);
88502 + return "<slob>";
88503 +}
88504 +#endif
88505 +
88506 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
88507 size_t ksize(const void *block)
88508 {
88509 struct page *sp;
88510 int align;
88511 - unsigned int *m;
88512 + slob_t *m;
88513
88514 BUG_ON(!block);
88515 if (unlikely(block == ZERO_SIZE_PTR))
88516 return 0;
88517
88518 sp = virt_to_page(block);
88519 - if (unlikely(!PageSlab(sp)))
88520 - return PAGE_SIZE << compound_order(sp);
88521 + VM_BUG_ON(!PageSlab(sp));
88522 + if (sp->private)
88523 + return sp->private;
88524
88525 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
88526 - m = (unsigned int *)(block - align);
88527 - return SLOB_UNITS(*m) * SLOB_UNIT;
88528 + m = (slob_t *)(block - align);
88529 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
88530 }
88531 EXPORT_SYMBOL(ksize);
88532
88533 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
88534
88535 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
88536 {
88537 - void *b;
88538 + void *b = NULL;
88539
88540 flags &= gfp_allowed_mask;
88541
88542 lockdep_trace_alloc(flags);
88543
88544 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88545 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
88546 +#else
88547 if (c->size < PAGE_SIZE) {
88548 b = slob_alloc(c->size, flags, c->align, node);
88549 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
88550 SLOB_UNITS(c->size) * SLOB_UNIT,
88551 flags, node);
88552 } else {
88553 - b = slob_new_pages(flags, get_order(c->size), node);
88554 + struct page *sp;
88555 +
88556 + sp = slob_new_pages(flags, get_order(c->size), node);
88557 + if (sp) {
88558 + b = page_address(sp);
88559 + sp->private = c->size;
88560 + }
88561 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
88562 PAGE_SIZE << get_order(c->size),
88563 flags, node);
88564 }
88565 +#endif
88566
88567 if (c->ctor)
88568 c->ctor(b);
88569 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
88570
88571 static void __kmem_cache_free(void *b, int size)
88572 {
88573 - if (size < PAGE_SIZE)
88574 + struct page *sp;
88575 +
88576 + sp = virt_to_page(b);
88577 + BUG_ON(!PageSlab(sp));
88578 + if (!sp->private)
88579 slob_free(b, size);
88580 else
88581 - slob_free_pages(b, get_order(size));
88582 + slob_free_pages(sp, get_order(size));
88583 }
88584
88585 static void kmem_rcu_free(struct rcu_head *head)
88586 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
88587
88588 void kmem_cache_free(struct kmem_cache *c, void *b)
88589 {
88590 + int size = c->size;
88591 +
88592 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88593 + if (size + c->align < PAGE_SIZE) {
88594 + size += c->align;
88595 + b -= c->align;
88596 + }
88597 +#endif
88598 +
88599 kmemleak_free_recursive(b, c->flags);
88600 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
88601 struct slob_rcu *slob_rcu;
88602 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
88603 - slob_rcu->size = c->size;
88604 + slob_rcu = b + (size - sizeof(struct slob_rcu));
88605 + slob_rcu->size = size;
88606 call_rcu(&slob_rcu->head, kmem_rcu_free);
88607 } else {
88608 - __kmem_cache_free(b, c->size);
88609 + __kmem_cache_free(b, size);
88610 }
88611
88612 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88613 + trace_kfree(_RET_IP_, b);
88614 +#else
88615 trace_kmem_cache_free(_RET_IP_, b);
88616 +#endif
88617 +
88618 }
88619 EXPORT_SYMBOL(kmem_cache_free);
88620
88621 diff --git a/mm/slub.c b/mm/slub.c
88622 index 57707f0..7857bd3 100644
88623 --- a/mm/slub.c
88624 +++ b/mm/slub.c
88625 @@ -198,7 +198,7 @@ struct track {
88626
88627 enum track_item { TRACK_ALLOC, TRACK_FREE };
88628
88629 -#ifdef CONFIG_SYSFS
88630 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88631 static int sysfs_slab_add(struct kmem_cache *);
88632 static int sysfs_slab_alias(struct kmem_cache *, const char *);
88633 static void sysfs_slab_remove(struct kmem_cache *);
88634 @@ -519,7 +519,7 @@ static void print_track(const char *s, struct track *t)
88635 if (!t->addr)
88636 return;
88637
88638 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
88639 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
88640 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
88641 #ifdef CONFIG_STACKTRACE
88642 {
88643 @@ -2594,6 +2594,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
88644
88645 slab_free_hook(s, x);
88646
88647 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88648 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
88649 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
88650 + if (s->ctor)
88651 + s->ctor(x);
88652 + }
88653 +#endif
88654 +
88655 redo:
88656 /*
88657 * Determine the currently cpus per cpu slab.
88658 @@ -2661,7 +2669,7 @@ static int slub_min_objects;
88659 * Merge control. If this is set then no merging of slab caches will occur.
88660 * (Could be removed. This was introduced to pacify the merge skeptics.)
88661 */
88662 -static int slub_nomerge;
88663 +static int slub_nomerge = 1;
88664
88665 /*
88666 * Calculate the order of allocation given an slab object size.
88667 @@ -2938,6 +2946,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
88668 s->inuse = size;
88669
88670 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
88671 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88672 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
88673 +#endif
88674 s->ctor)) {
88675 /*
88676 * Relocate free pointer after the object if it is not
88677 @@ -3283,6 +3294,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
88678 EXPORT_SYMBOL(__kmalloc_node);
88679 #endif
88680
88681 +bool is_usercopy_object(const void *ptr)
88682 +{
88683 + struct page *page;
88684 + struct kmem_cache *s;
88685 +
88686 + if (ZERO_OR_NULL_PTR(ptr))
88687 + return false;
88688 +
88689 + if (!slab_is_available())
88690 + return false;
88691 +
88692 + if (!virt_addr_valid(ptr))
88693 + return false;
88694 +
88695 + page = virt_to_head_page(ptr);
88696 +
88697 + if (!PageSlab(page))
88698 + return false;
88699 +
88700 + s = page->slab_cache;
88701 + return s->flags & SLAB_USERCOPY;
88702 +}
88703 +
88704 +#ifdef CONFIG_PAX_USERCOPY
88705 +const char *check_heap_object(const void *ptr, unsigned long n)
88706 +{
88707 + struct page *page;
88708 + struct kmem_cache *s;
88709 + unsigned long offset;
88710 +
88711 + if (ZERO_OR_NULL_PTR(ptr))
88712 + return "<null>";
88713 +
88714 + if (!virt_addr_valid(ptr))
88715 + return NULL;
88716 +
88717 + page = virt_to_head_page(ptr);
88718 +
88719 + if (!PageSlab(page))
88720 + return NULL;
88721 +
88722 + s = page->slab_cache;
88723 + if (!(s->flags & SLAB_USERCOPY))
88724 + return s->name;
88725 +
88726 + offset = (ptr - page_address(page)) % s->size;
88727 + if (offset <= s->object_size && n <= s->object_size - offset)
88728 + return NULL;
88729 +
88730 + return s->name;
88731 +}
88732 +#endif
88733 +
88734 size_t ksize(const void *object)
88735 {
88736 struct page *page;
88737 @@ -3347,6 +3411,7 @@ void kfree(const void *x)
88738 if (unlikely(ZERO_OR_NULL_PTR(x)))
88739 return;
88740
88741 + VM_BUG_ON(!virt_addr_valid(x));
88742 page = virt_to_head_page(x);
88743 if (unlikely(!PageSlab(page))) {
88744 BUG_ON(!PageCompound(page));
88745 @@ -3652,7 +3717,7 @@ static int slab_unmergeable(struct kmem_cache *s)
88746 /*
88747 * We may have set a slab to be unmergeable during bootstrap.
88748 */
88749 - if (s->refcount < 0)
88750 + if (atomic_read(&s->refcount) < 0)
88751 return 1;
88752
88753 return 0;
88754 @@ -3710,7 +3775,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
88755
88756 s = find_mergeable(memcg, size, align, flags, name, ctor);
88757 if (s) {
88758 - s->refcount++;
88759 + atomic_inc(&s->refcount);
88760 /*
88761 * Adjust the object sizes so that we clear
88762 * the complete object on kzalloc.
88763 @@ -3719,7 +3784,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
88764 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
88765
88766 if (sysfs_slab_alias(s, name)) {
88767 - s->refcount--;
88768 + atomic_dec(&s->refcount);
88769 s = NULL;
88770 }
88771 }
88772 @@ -3781,7 +3846,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
88773 return NOTIFY_OK;
88774 }
88775
88776 -static struct notifier_block __cpuinitdata slab_notifier = {
88777 +static struct notifier_block slab_notifier = {
88778 .notifier_call = slab_cpuup_callback
88779 };
88780
88781 @@ -3839,7 +3904,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
88782 }
88783 #endif
88784
88785 -#ifdef CONFIG_SYSFS
88786 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88787 static int count_inuse(struct page *page)
88788 {
88789 return page->inuse;
88790 @@ -4226,12 +4291,12 @@ static void resiliency_test(void)
88791 validate_slab_cache(kmalloc_caches[9]);
88792 }
88793 #else
88794 -#ifdef CONFIG_SYSFS
88795 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88796 static void resiliency_test(void) {};
88797 #endif
88798 #endif
88799
88800 -#ifdef CONFIG_SYSFS
88801 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88802 enum slab_stat_type {
88803 SL_ALL, /* All slabs */
88804 SL_PARTIAL, /* Only partially allocated slabs */
88805 @@ -4475,7 +4540,7 @@ SLAB_ATTR_RO(ctor);
88806
88807 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
88808 {
88809 - return sprintf(buf, "%d\n", s->refcount - 1);
88810 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
88811 }
88812 SLAB_ATTR_RO(aliases);
88813
88814 @@ -4563,6 +4628,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
88815 SLAB_ATTR_RO(cache_dma);
88816 #endif
88817
88818 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88819 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
88820 +{
88821 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
88822 +}
88823 +SLAB_ATTR_RO(usercopy);
88824 +#endif
88825 +
88826 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
88827 {
88828 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
88829 @@ -4897,6 +4970,9 @@ static struct attribute *slab_attrs[] = {
88830 #ifdef CONFIG_ZONE_DMA
88831 &cache_dma_attr.attr,
88832 #endif
88833 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88834 + &usercopy_attr.attr,
88835 +#endif
88836 #ifdef CONFIG_NUMA
88837 &remote_node_defrag_ratio_attr.attr,
88838 #endif
88839 @@ -5128,6 +5204,7 @@ static char *create_unique_id(struct kmem_cache *s)
88840 return name;
88841 }
88842
88843 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88844 static int sysfs_slab_add(struct kmem_cache *s)
88845 {
88846 int err;
88847 @@ -5151,7 +5228,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
88848 }
88849
88850 s->kobj.kset = slab_kset;
88851 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
88852 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
88853 if (err) {
88854 kobject_put(&s->kobj);
88855 return err;
88856 @@ -5185,6 +5262,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
88857 kobject_del(&s->kobj);
88858 kobject_put(&s->kobj);
88859 }
88860 +#endif
88861
88862 /*
88863 * Need to buffer aliases during bootup until sysfs becomes
88864 @@ -5198,6 +5276,7 @@ struct saved_alias {
88865
88866 static struct saved_alias *alias_list;
88867
88868 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88869 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
88870 {
88871 struct saved_alias *al;
88872 @@ -5220,6 +5299,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
88873 alias_list = al;
88874 return 0;
88875 }
88876 +#endif
88877
88878 static int __init slab_sysfs_init(void)
88879 {
88880 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
88881 index 27eeab3..7c3f7f2 100644
88882 --- a/mm/sparse-vmemmap.c
88883 +++ b/mm/sparse-vmemmap.c
88884 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
88885 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
88886 if (!p)
88887 return NULL;
88888 - pud_populate(&init_mm, pud, p);
88889 + pud_populate_kernel(&init_mm, pud, p);
88890 }
88891 return pud;
88892 }
88893 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
88894 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
88895 if (!p)
88896 return NULL;
88897 - pgd_populate(&init_mm, pgd, p);
88898 + pgd_populate_kernel(&init_mm, pgd, p);
88899 }
88900 return pgd;
88901 }
88902 diff --git a/mm/sparse.c b/mm/sparse.c
88903 index 1c91f0d3..485470a 100644
88904 --- a/mm/sparse.c
88905 +++ b/mm/sparse.c
88906 @@ -761,7 +761,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
88907
88908 for (i = 0; i < PAGES_PER_SECTION; i++) {
88909 if (PageHWPoison(&memmap[i])) {
88910 - atomic_long_sub(1, &num_poisoned_pages);
88911 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
88912 ClearPageHWPoison(&memmap[i]);
88913 }
88914 }
88915 diff --git a/mm/swap.c b/mm/swap.c
88916 index dfd7d71..ccdf688 100644
88917 --- a/mm/swap.c
88918 +++ b/mm/swap.c
88919 @@ -31,6 +31,7 @@
88920 #include <linux/memcontrol.h>
88921 #include <linux/gfp.h>
88922 #include <linux/uio.h>
88923 +#include <linux/hugetlb.h>
88924
88925 #include "internal.h"
88926
88927 @@ -73,6 +74,8 @@ static void __put_compound_page(struct page *page)
88928
88929 __page_cache_release(page);
88930 dtor = get_compound_page_dtor(page);
88931 + if (!PageHuge(page))
88932 + BUG_ON(dtor != free_compound_page);
88933 (*dtor)(page);
88934 }
88935
88936 diff --git a/mm/swapfile.c b/mm/swapfile.c
88937 index 746af55b..7ac94ae 100644
88938 --- a/mm/swapfile.c
88939 +++ b/mm/swapfile.c
88940 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
88941
88942 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
88943 /* Activity counter to indicate that a swapon or swapoff has occurred */
88944 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
88945 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
88946
88947 static inline unsigned char swap_count(unsigned char ent)
88948 {
88949 @@ -1684,7 +1684,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
88950 }
88951 filp_close(swap_file, NULL);
88952 err = 0;
88953 - atomic_inc(&proc_poll_event);
88954 + atomic_inc_unchecked(&proc_poll_event);
88955 wake_up_interruptible(&proc_poll_wait);
88956
88957 out_dput:
88958 @@ -1701,8 +1701,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
88959
88960 poll_wait(file, &proc_poll_wait, wait);
88961
88962 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
88963 - seq->poll_event = atomic_read(&proc_poll_event);
88964 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
88965 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
88966 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
88967 }
88968
88969 @@ -1800,7 +1800,7 @@ static int swaps_open(struct inode *inode, struct file *file)
88970 return ret;
88971
88972 seq = file->private_data;
88973 - seq->poll_event = atomic_read(&proc_poll_event);
88974 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
88975 return 0;
88976 }
88977
88978 @@ -2143,7 +2143,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
88979 (frontswap_map) ? "FS" : "");
88980
88981 mutex_unlock(&swapon_mutex);
88982 - atomic_inc(&proc_poll_event);
88983 + atomic_inc_unchecked(&proc_poll_event);
88984 wake_up_interruptible(&proc_poll_wait);
88985
88986 if (S_ISREG(inode->i_mode))
88987 diff --git a/mm/util.c b/mm/util.c
88988 index ab1424d..7c5bd5a 100644
88989 --- a/mm/util.c
88990 +++ b/mm/util.c
88991 @@ -294,6 +294,12 @@ done:
88992 void arch_pick_mmap_layout(struct mm_struct *mm)
88993 {
88994 mm->mmap_base = TASK_UNMAPPED_BASE;
88995 +
88996 +#ifdef CONFIG_PAX_RANDMMAP
88997 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88998 + mm->mmap_base += mm->delta_mmap;
88999 +#endif
89000 +
89001 mm->get_unmapped_area = arch_get_unmapped_area;
89002 mm->unmap_area = arch_unmap_area;
89003 }
89004 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
89005 index d365724..6cae7c2 100644
89006 --- a/mm/vmalloc.c
89007 +++ b/mm/vmalloc.c
89008 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
89009
89010 pte = pte_offset_kernel(pmd, addr);
89011 do {
89012 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
89013 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
89014 +
89015 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
89016 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
89017 + BUG_ON(!pte_exec(*pte));
89018 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
89019 + continue;
89020 + }
89021 +#endif
89022 +
89023 + {
89024 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
89025 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
89026 + }
89027 } while (pte++, addr += PAGE_SIZE, addr != end);
89028 }
89029
89030 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
89031 pte = pte_alloc_kernel(pmd, addr);
89032 if (!pte)
89033 return -ENOMEM;
89034 +
89035 + pax_open_kernel();
89036 do {
89037 struct page *page = pages[*nr];
89038
89039 - if (WARN_ON(!pte_none(*pte)))
89040 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
89041 + if (pgprot_val(prot) & _PAGE_NX)
89042 +#endif
89043 +
89044 + if (!pte_none(*pte)) {
89045 + pax_close_kernel();
89046 + WARN_ON(1);
89047 return -EBUSY;
89048 - if (WARN_ON(!page))
89049 + }
89050 + if (!page) {
89051 + pax_close_kernel();
89052 + WARN_ON(1);
89053 return -ENOMEM;
89054 + }
89055 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
89056 (*nr)++;
89057 } while (pte++, addr += PAGE_SIZE, addr != end);
89058 + pax_close_kernel();
89059 return 0;
89060 }
89061
89062 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
89063 pmd_t *pmd;
89064 unsigned long next;
89065
89066 - pmd = pmd_alloc(&init_mm, pud, addr);
89067 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
89068 if (!pmd)
89069 return -ENOMEM;
89070 do {
89071 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
89072 pud_t *pud;
89073 unsigned long next;
89074
89075 - pud = pud_alloc(&init_mm, pgd, addr);
89076 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
89077 if (!pud)
89078 return -ENOMEM;
89079 do {
89080 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
89081 if (addr >= MODULES_VADDR && addr < MODULES_END)
89082 return 1;
89083 #endif
89084 +
89085 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
89086 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
89087 + return 1;
89088 +#endif
89089 +
89090 return is_vmalloc_addr(x);
89091 }
89092
89093 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
89094
89095 if (!pgd_none(*pgd)) {
89096 pud_t *pud = pud_offset(pgd, addr);
89097 +#ifdef CONFIG_X86
89098 + if (!pud_large(*pud))
89099 +#endif
89100 if (!pud_none(*pud)) {
89101 pmd_t *pmd = pmd_offset(pud, addr);
89102 +#ifdef CONFIG_X86
89103 + if (!pmd_large(*pmd))
89104 +#endif
89105 if (!pmd_none(*pmd)) {
89106 pte_t *ptep, pte;
89107
89108 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
89109 * Allocate a region of KVA of the specified size and alignment, within the
89110 * vstart and vend.
89111 */
89112 -static struct vmap_area *alloc_vmap_area(unsigned long size,
89113 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
89114 unsigned long align,
89115 unsigned long vstart, unsigned long vend,
89116 int node, gfp_t gfp_mask)
89117 @@ -1337,6 +1373,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
89118 struct vm_struct *area;
89119
89120 BUG_ON(in_interrupt());
89121 +
89122 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
89123 + if (flags & VM_KERNEXEC) {
89124 + if (start != VMALLOC_START || end != VMALLOC_END)
89125 + return NULL;
89126 + start = (unsigned long)MODULES_EXEC_VADDR;
89127 + end = (unsigned long)MODULES_EXEC_END;
89128 + }
89129 +#endif
89130 +
89131 if (flags & VM_IOREMAP) {
89132 int bit = fls(size);
89133
89134 @@ -1581,6 +1627,11 @@ void *vmap(struct page **pages, unsigned int count,
89135 if (count > totalram_pages)
89136 return NULL;
89137
89138 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
89139 + if (!(pgprot_val(prot) & _PAGE_NX))
89140 + flags |= VM_KERNEXEC;
89141 +#endif
89142 +
89143 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
89144 __builtin_return_address(0));
89145 if (!area)
89146 @@ -1682,6 +1733,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
89147 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
89148 goto fail;
89149
89150 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
89151 + if (!(pgprot_val(prot) & _PAGE_NX))
89152 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
89153 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
89154 + else
89155 +#endif
89156 +
89157 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
89158 start, end, node, gfp_mask, caller);
89159 if (!area)
89160 @@ -1858,10 +1916,9 @@ EXPORT_SYMBOL(vzalloc_node);
89161 * For tight control over page level allocator and protection flags
89162 * use __vmalloc() instead.
89163 */
89164 -
89165 void *vmalloc_exec(unsigned long size)
89166 {
89167 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
89168 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
89169 NUMA_NO_NODE, __builtin_return_address(0));
89170 }
89171
89172 @@ -2168,6 +2225,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
89173 unsigned long uaddr = vma->vm_start;
89174 unsigned long usize = vma->vm_end - vma->vm_start;
89175
89176 + BUG_ON(vma->vm_mirror);
89177 +
89178 if ((PAGE_SIZE-1) & (unsigned long)addr)
89179 return -EINVAL;
89180
89181 @@ -2629,7 +2688,11 @@ static int s_show(struct seq_file *m, void *p)
89182 v->addr, v->addr + v->size, v->size);
89183
89184 if (v->caller)
89185 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89186 + seq_printf(m, " %pK", v->caller);
89187 +#else
89188 seq_printf(m, " %pS", v->caller);
89189 +#endif
89190
89191 if (v->nr_pages)
89192 seq_printf(m, " pages=%d", v->nr_pages);
89193 diff --git a/mm/vmstat.c b/mm/vmstat.c
89194 index f42745e..62f8346 100644
89195 --- a/mm/vmstat.c
89196 +++ b/mm/vmstat.c
89197 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
89198 *
89199 * vm_stat contains the global counters
89200 */
89201 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
89202 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
89203 EXPORT_SYMBOL(vm_stat);
89204
89205 #ifdef CONFIG_SMP
89206 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
89207 v = p->vm_stat_diff[i];
89208 p->vm_stat_diff[i] = 0;
89209 local_irq_restore(flags);
89210 - atomic_long_add(v, &zone->vm_stat[i]);
89211 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
89212 global_diff[i] += v;
89213 #ifdef CONFIG_NUMA
89214 /* 3 seconds idle till flush */
89215 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
89216
89217 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
89218 if (global_diff[i])
89219 - atomic_long_add(global_diff[i], &vm_stat[i]);
89220 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
89221 }
89222
89223 /*
89224 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
89225 if (pset->vm_stat_diff[i]) {
89226 int v = pset->vm_stat_diff[i];
89227 pset->vm_stat_diff[i] = 0;
89228 - atomic_long_add(v, &zone->vm_stat[i]);
89229 - atomic_long_add(v, &vm_stat[i]);
89230 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
89231 + atomic_long_add_unchecked(v, &vm_stat[i]);
89232 }
89233 }
89234 #endif
89235 @@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
89236 return NOTIFY_OK;
89237 }
89238
89239 -static struct notifier_block __cpuinitdata vmstat_notifier =
89240 +static struct notifier_block vmstat_notifier =
89241 { &vmstat_cpuup_callback, NULL, 0 };
89242 #endif
89243
89244 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
89245 start_cpu_timer(cpu);
89246 #endif
89247 #ifdef CONFIG_PROC_FS
89248 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
89249 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
89250 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
89251 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
89252 + {
89253 + mode_t gr_mode = S_IRUGO;
89254 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
89255 + gr_mode = S_IRUSR;
89256 +#endif
89257 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
89258 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
89259 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
89260 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
89261 +#else
89262 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
89263 +#endif
89264 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
89265 + }
89266 #endif
89267 return 0;
89268 }
89269 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
89270 index 9424f37..6aabf19 100644
89271 --- a/net/8021q/vlan.c
89272 +++ b/net/8021q/vlan.c
89273 @@ -469,7 +469,7 @@ out:
89274 return NOTIFY_DONE;
89275 }
89276
89277 -static struct notifier_block vlan_notifier_block __read_mostly = {
89278 +static struct notifier_block vlan_notifier_block = {
89279 .notifier_call = vlan_device_event,
89280 };
89281
89282 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
89283 err = -EPERM;
89284 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
89285 break;
89286 - if ((args.u.name_type >= 0) &&
89287 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
89288 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
89289 struct vlan_net *vn;
89290
89291 vn = net_generic(net, vlan_net_id);
89292 diff --git a/net/9p/mod.c b/net/9p/mod.c
89293 index 6ab36ae..6f1841b 100644
89294 --- a/net/9p/mod.c
89295 +++ b/net/9p/mod.c
89296 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
89297 void v9fs_register_trans(struct p9_trans_module *m)
89298 {
89299 spin_lock(&v9fs_trans_lock);
89300 - list_add_tail(&m->list, &v9fs_trans_list);
89301 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
89302 spin_unlock(&v9fs_trans_lock);
89303 }
89304 EXPORT_SYMBOL(v9fs_register_trans);
89305 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
89306 void v9fs_unregister_trans(struct p9_trans_module *m)
89307 {
89308 spin_lock(&v9fs_trans_lock);
89309 - list_del_init(&m->list);
89310 + pax_list_del_init((struct list_head *)&m->list);
89311 spin_unlock(&v9fs_trans_lock);
89312 }
89313 EXPORT_SYMBOL(v9fs_unregister_trans);
89314 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
89315 index 02efb25..41541a9 100644
89316 --- a/net/9p/trans_fd.c
89317 +++ b/net/9p/trans_fd.c
89318 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
89319 oldfs = get_fs();
89320 set_fs(get_ds());
89321 /* The cast to a user pointer is valid due to the set_fs() */
89322 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
89323 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
89324 set_fs(oldfs);
89325
89326 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
89327 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
89328 index 876fbe8..8bbea9f 100644
89329 --- a/net/atm/atm_misc.c
89330 +++ b/net/atm/atm_misc.c
89331 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
89332 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
89333 return 1;
89334 atm_return(vcc, truesize);
89335 - atomic_inc(&vcc->stats->rx_drop);
89336 + atomic_inc_unchecked(&vcc->stats->rx_drop);
89337 return 0;
89338 }
89339 EXPORT_SYMBOL(atm_charge);
89340 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
89341 }
89342 }
89343 atm_return(vcc, guess);
89344 - atomic_inc(&vcc->stats->rx_drop);
89345 + atomic_inc_unchecked(&vcc->stats->rx_drop);
89346 return NULL;
89347 }
89348 EXPORT_SYMBOL(atm_alloc_charge);
89349 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
89350
89351 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
89352 {
89353 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
89354 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
89355 __SONET_ITEMS
89356 #undef __HANDLE_ITEM
89357 }
89358 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
89359
89360 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
89361 {
89362 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
89363 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
89364 __SONET_ITEMS
89365 #undef __HANDLE_ITEM
89366 }
89367 diff --git a/net/atm/lec.h b/net/atm/lec.h
89368 index 4149db1..f2ab682 100644
89369 --- a/net/atm/lec.h
89370 +++ b/net/atm/lec.h
89371 @@ -48,7 +48,7 @@ struct lane2_ops {
89372 const u8 *tlvs, u32 sizeoftlvs);
89373 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
89374 const u8 *tlvs, u32 sizeoftlvs);
89375 -};
89376 +} __no_const;
89377
89378 /*
89379 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
89380 diff --git a/net/atm/proc.c b/net/atm/proc.c
89381 index bbb6461..cf04016 100644
89382 --- a/net/atm/proc.c
89383 +++ b/net/atm/proc.c
89384 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
89385 const struct k_atm_aal_stats *stats)
89386 {
89387 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
89388 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
89389 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
89390 - atomic_read(&stats->rx_drop));
89391 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
89392 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
89393 + atomic_read_unchecked(&stats->rx_drop));
89394 }
89395
89396 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
89397 diff --git a/net/atm/resources.c b/net/atm/resources.c
89398 index 0447d5d..3cf4728 100644
89399 --- a/net/atm/resources.c
89400 +++ b/net/atm/resources.c
89401 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
89402 static void copy_aal_stats(struct k_atm_aal_stats *from,
89403 struct atm_aal_stats *to)
89404 {
89405 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
89406 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
89407 __AAL_STAT_ITEMS
89408 #undef __HANDLE_ITEM
89409 }
89410 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
89411 static void subtract_aal_stats(struct k_atm_aal_stats *from,
89412 struct atm_aal_stats *to)
89413 {
89414 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
89415 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
89416 __AAL_STAT_ITEMS
89417 #undef __HANDLE_ITEM
89418 }
89419 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
89420 index d5744b7..506bae3 100644
89421 --- a/net/ax25/sysctl_net_ax25.c
89422 +++ b/net/ax25/sysctl_net_ax25.c
89423 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
89424 {
89425 char path[sizeof("net/ax25/") + IFNAMSIZ];
89426 int k;
89427 - struct ctl_table *table;
89428 + ctl_table_no_const *table;
89429
89430 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
89431 if (!table)
89432 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
89433 index f680ee1..97e3542 100644
89434 --- a/net/batman-adv/bat_iv_ogm.c
89435 +++ b/net/batman-adv/bat_iv_ogm.c
89436 @@ -79,7 +79,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
89437
89438 /* randomize initial seqno to avoid collision */
89439 get_random_bytes(&random_seqno, sizeof(random_seqno));
89440 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
89441 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
89442
89443 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
89444 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
89445 @@ -627,9 +627,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
89446 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
89447
89448 /* change sequence number to network order */
89449 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
89450 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
89451 batadv_ogm_packet->seqno = htonl(seqno);
89452 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
89453 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
89454
89455 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
89456 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
89457 @@ -1037,7 +1037,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
89458 return;
89459
89460 /* could be changed by schedule_own_packet() */
89461 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
89462 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
89463
89464 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
89465 has_directlink_flag = 1;
89466 diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
89467 index de27b31..7058bfe 100644
89468 --- a/net/batman-adv/bridge_loop_avoidance.c
89469 +++ b/net/batman-adv/bridge_loop_avoidance.c
89470 @@ -1522,6 +1522,8 @@ out:
89471 * in these cases, the skb is further handled by this function and
89472 * returns 1, otherwise it returns 0 and the caller shall further
89473 * process the skb.
89474 + *
89475 + * This call might reallocate skb data.
89476 */
89477 int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid)
89478 {
89479 diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
89480 index f105219..7614af3 100644
89481 --- a/net/batman-adv/gateway_client.c
89482 +++ b/net/batman-adv/gateway_client.c
89483 @@ -508,6 +508,7 @@ out:
89484 return 0;
89485 }
89486
89487 +/* this call might reallocate skb data */
89488 static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
89489 {
89490 int ret = false;
89491 @@ -568,6 +569,7 @@ out:
89492 return ret;
89493 }
89494
89495 +/* this call might reallocate skb data */
89496 bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
89497 {
89498 struct ethhdr *ethhdr;
89499 @@ -619,6 +621,12 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
89500
89501 if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr)))
89502 return false;
89503 +
89504 + /* skb->data might have been reallocated by pskb_may_pull() */
89505 + ethhdr = (struct ethhdr *)skb->data;
89506 + if (ntohs(ethhdr->h_proto) == ETH_P_8021Q)
89507 + ethhdr = (struct ethhdr *)(skb->data + VLAN_HLEN);
89508 +
89509 udphdr = (struct udphdr *)(skb->data + *header_len);
89510 *header_len += sizeof(*udphdr);
89511
89512 @@ -634,12 +642,14 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
89513 return true;
89514 }
89515
89516 +/* this call might reallocate skb data */
89517 bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
89518 - struct sk_buff *skb, struct ethhdr *ethhdr)
89519 + struct sk_buff *skb)
89520 {
89521 struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL;
89522 struct batadv_orig_node *orig_dst_node = NULL;
89523 struct batadv_gw_node *curr_gw = NULL;
89524 + struct ethhdr *ethhdr;
89525 bool ret, out_of_range = false;
89526 unsigned int header_len = 0;
89527 uint8_t curr_tq_avg;
89528 @@ -648,6 +658,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
89529 if (!ret)
89530 goto out;
89531
89532 + ethhdr = (struct ethhdr *)skb->data;
89533 orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
89534 ethhdr->h_dest);
89535 if (!orig_dst_node)
89536 diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h
89537 index 039902d..1037d75 100644
89538 --- a/net/batman-adv/gateway_client.h
89539 +++ b/net/batman-adv/gateway_client.h
89540 @@ -34,7 +34,6 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv,
89541 void batadv_gw_node_purge(struct batadv_priv *bat_priv);
89542 int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
89543 bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
89544 -bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
89545 - struct sk_buff *skb, struct ethhdr *ethhdr);
89546 +bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb);
89547
89548 #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
89549 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
89550 index 522243a..b48c0ef 100644
89551 --- a/net/batman-adv/hard-interface.c
89552 +++ b/net/batman-adv/hard-interface.c
89553 @@ -401,7 +401,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
89554 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
89555 dev_add_pack(&hard_iface->batman_adv_ptype);
89556
89557 - atomic_set(&hard_iface->frag_seqno, 1);
89558 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
89559 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
89560 hard_iface->net_dev->name);
89561
89562 @@ -550,7 +550,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
89563 /* This can't be called via a bat_priv callback because
89564 * we have no bat_priv yet.
89565 */
89566 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
89567 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
89568 hard_iface->bat_iv.ogm_buff = NULL;
89569
89570 return hard_iface;
89571 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
89572 index 819dfb0..226bacd 100644
89573 --- a/net/batman-adv/soft-interface.c
89574 +++ b/net/batman-adv/soft-interface.c
89575 @@ -180,6 +180,9 @@ static int batadv_interface_tx(struct sk_buff *skb,
89576 if (batadv_bla_tx(bat_priv, skb, vid))
89577 goto dropped;
89578
89579 + /* skb->data might have been reallocated by batadv_bla_tx() */
89580 + ethhdr = (struct ethhdr *)skb->data;
89581 +
89582 /* Register the client MAC in the transtable */
89583 if (!is_multicast_ether_addr(ethhdr->h_source))
89584 batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
89585 @@ -220,6 +223,10 @@ static int batadv_interface_tx(struct sk_buff *skb,
89586 default:
89587 break;
89588 }
89589 +
89590 + /* reminder: ethhdr might have become unusable from here on
89591 + * (batadv_gw_is_dhcp_target() might have reallocated skb data)
89592 + */
89593 }
89594
89595 /* ethernet packet should be broadcasted */
89596 @@ -253,7 +260,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
89597 primary_if->net_dev->dev_addr, ETH_ALEN);
89598
89599 /* set broadcast sequence number */
89600 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
89601 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
89602 bcast_packet->seqno = htonl(seqno);
89603
89604 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
89605 @@ -266,7 +273,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
89606 /* unicast packet */
89607 } else {
89608 if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_OFF) {
89609 - ret = batadv_gw_out_of_range(bat_priv, skb, ethhdr);
89610 + ret = batadv_gw_out_of_range(bat_priv, skb);
89611 if (ret)
89612 goto dropped;
89613 }
89614 @@ -472,7 +479,7 @@ static int batadv_softif_init_late(struct net_device *dev)
89615 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
89616
89617 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
89618 - atomic_set(&bat_priv->bcast_seqno, 1);
89619 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
89620 atomic_set(&bat_priv->tt.vn, 0);
89621 atomic_set(&bat_priv->tt.local_changes, 0);
89622 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
89623 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
89624 index aba8364..50fcbb8 100644
89625 --- a/net/batman-adv/types.h
89626 +++ b/net/batman-adv/types.h
89627 @@ -51,7 +51,7 @@
89628 struct batadv_hard_iface_bat_iv {
89629 unsigned char *ogm_buff;
89630 int ogm_buff_len;
89631 - atomic_t ogm_seqno;
89632 + atomic_unchecked_t ogm_seqno;
89633 };
89634
89635 /**
89636 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
89637 int16_t if_num;
89638 char if_status;
89639 struct net_device *net_dev;
89640 - atomic_t frag_seqno;
89641 + atomic_unchecked_t frag_seqno;
89642 struct kobject *hardif_obj;
89643 atomic_t refcount;
89644 struct packet_type batman_adv_ptype;
89645 @@ -558,7 +558,7 @@ struct batadv_priv {
89646 #ifdef CONFIG_BATMAN_ADV_DEBUG
89647 atomic_t log_level;
89648 #endif
89649 - atomic_t bcast_seqno;
89650 + atomic_unchecked_t bcast_seqno;
89651 atomic_t bcast_queue_left;
89652 atomic_t batman_queue_left;
89653 char num_ifaces;
89654 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
89655 index 0bb3b59..0e3052e 100644
89656 --- a/net/batman-adv/unicast.c
89657 +++ b/net/batman-adv/unicast.c
89658 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
89659 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
89660 frag2->flags = large_tail;
89661
89662 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
89663 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
89664 frag1->seqno = htons(seqno - 1);
89665 frag2->seqno = htons(seqno);
89666
89667 @@ -326,7 +326,9 @@ static bool batadv_unicast_push_and_fill_skb(struct sk_buff *skb, int hdr_size,
89668 * @skb: the skb containing the payload to encapsulate
89669 * @orig_node: the destination node
89670 *
89671 - * Returns false if the payload could not be encapsulated or true otherwise
89672 + * Returns false if the payload could not be encapsulated or true otherwise.
89673 + *
89674 + * This call might reallocate skb data.
89675 */
89676 static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
89677 struct batadv_orig_node *orig_node)
89678 @@ -343,7 +345,9 @@ static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
89679 * @orig_node: the destination node
89680 * @packet_subtype: the batman 4addr packet subtype to use
89681 *
89682 - * Returns false if the payload could not be encapsulated or true otherwise
89683 + * Returns false if the payload could not be encapsulated or true otherwise.
89684 + *
89685 + * This call might reallocate skb data.
89686 */
89687 bool batadv_unicast_4addr_prepare_skb(struct batadv_priv *bat_priv,
89688 struct sk_buff *skb,
89689 @@ -401,7 +405,7 @@ int batadv_unicast_generic_send_skb(struct batadv_priv *bat_priv,
89690 struct batadv_neigh_node *neigh_node;
89691 int data_len = skb->len;
89692 int ret = NET_RX_DROP;
89693 - unsigned int dev_mtu;
89694 + unsigned int dev_mtu, header_len;
89695
89696 /* get routing information */
89697 if (is_multicast_ether_addr(ethhdr->h_dest)) {
89698 @@ -429,10 +433,12 @@ find_router:
89699 switch (packet_type) {
89700 case BATADV_UNICAST:
89701 batadv_unicast_prepare_skb(skb, orig_node);
89702 + header_len = sizeof(struct batadv_unicast_packet);
89703 break;
89704 case BATADV_UNICAST_4ADDR:
89705 batadv_unicast_4addr_prepare_skb(bat_priv, skb, orig_node,
89706 packet_subtype);
89707 + header_len = sizeof(struct batadv_unicast_4addr_packet);
89708 break;
89709 default:
89710 /* this function supports UNICAST and UNICAST_4ADDR only. It
89711 @@ -441,6 +447,7 @@ find_router:
89712 goto out;
89713 }
89714
89715 + ethhdr = (struct ethhdr *)(skb->data + header_len);
89716 unicast_packet = (struct batadv_unicast_packet *)skb->data;
89717
89718 /* inform the destination node that we are still missing a correct route
89719 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
89720 index ace5e55..a65a1c0 100644
89721 --- a/net/bluetooth/hci_core.c
89722 +++ b/net/bluetooth/hci_core.c
89723 @@ -2211,16 +2211,16 @@ int hci_register_dev(struct hci_dev *hdev)
89724 list_add(&hdev->list, &hci_dev_list);
89725 write_unlock(&hci_dev_list_lock);
89726
89727 - hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
89728 - WQ_MEM_RECLAIM, 1);
89729 + hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
89730 + WQ_MEM_RECLAIM, 1, hdev->name);
89731 if (!hdev->workqueue) {
89732 error = -ENOMEM;
89733 goto err;
89734 }
89735
89736 - hdev->req_workqueue = alloc_workqueue(hdev->name,
89737 + hdev->req_workqueue = alloc_workqueue("%s",
89738 WQ_HIGHPRI | WQ_UNBOUND |
89739 - WQ_MEM_RECLAIM, 1);
89740 + WQ_MEM_RECLAIM, 1, hdev->name);
89741 if (!hdev->req_workqueue) {
89742 destroy_workqueue(hdev->workqueue);
89743 error = -ENOMEM;
89744 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
89745 index 9bd7d95..6c4884f 100644
89746 --- a/net/bluetooth/hci_sock.c
89747 +++ b/net/bluetooth/hci_sock.c
89748 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
89749 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
89750 }
89751
89752 - len = min_t(unsigned int, len, sizeof(uf));
89753 + len = min((size_t)len, sizeof(uf));
89754 if (copy_from_user(&uf, optval, len)) {
89755 err = -EFAULT;
89756 break;
89757 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
89758 index 68843a2..30e9342 100644
89759 --- a/net/bluetooth/l2cap_core.c
89760 +++ b/net/bluetooth/l2cap_core.c
89761 @@ -3507,8 +3507,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
89762 break;
89763
89764 case L2CAP_CONF_RFC:
89765 - if (olen == sizeof(rfc))
89766 - memcpy(&rfc, (void *)val, olen);
89767 + if (olen != sizeof(rfc))
89768 + break;
89769 +
89770 + memcpy(&rfc, (void *)val, olen);
89771
89772 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
89773 rfc.mode != chan->mode)
89774 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
89775 index 36fed40..be2eeb2 100644
89776 --- a/net/bluetooth/l2cap_sock.c
89777 +++ b/net/bluetooth/l2cap_sock.c
89778 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
89779 struct sock *sk = sock->sk;
89780 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
89781 struct l2cap_options opts;
89782 - int len, err = 0;
89783 + int err = 0;
89784 + size_t len = optlen;
89785 u32 opt;
89786
89787 BT_DBG("sk %p", sk);
89788 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
89789 opts.max_tx = chan->max_tx;
89790 opts.txwin_size = chan->tx_win;
89791
89792 - len = min_t(unsigned int, sizeof(opts), optlen);
89793 + len = min(sizeof(opts), len);
89794 if (copy_from_user((char *) &opts, optval, len)) {
89795 err = -EFAULT;
89796 break;
89797 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
89798 struct bt_security sec;
89799 struct bt_power pwr;
89800 struct l2cap_conn *conn;
89801 - int len, err = 0;
89802 + int err = 0;
89803 + size_t len = optlen;
89804 u32 opt;
89805
89806 BT_DBG("sk %p", sk);
89807 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
89808
89809 sec.level = BT_SECURITY_LOW;
89810
89811 - len = min_t(unsigned int, sizeof(sec), optlen);
89812 + len = min(sizeof(sec), len);
89813 if (copy_from_user((char *) &sec, optval, len)) {
89814 err = -EFAULT;
89815 break;
89816 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
89817
89818 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
89819
89820 - len = min_t(unsigned int, sizeof(pwr), optlen);
89821 + len = min(sizeof(pwr), len);
89822 if (copy_from_user((char *) &pwr, optval, len)) {
89823 err = -EFAULT;
89824 break;
89825 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
89826 index 30b3721..c1bd0a0 100644
89827 --- a/net/bluetooth/rfcomm/sock.c
89828 +++ b/net/bluetooth/rfcomm/sock.c
89829 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
89830 struct sock *sk = sock->sk;
89831 struct bt_security sec;
89832 int err = 0;
89833 - size_t len;
89834 + size_t len = optlen;
89835 u32 opt;
89836
89837 BT_DBG("sk %p", sk);
89838 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
89839
89840 sec.level = BT_SECURITY_LOW;
89841
89842 - len = min_t(unsigned int, sizeof(sec), optlen);
89843 + len = min(sizeof(sec), len);
89844 if (copy_from_user((char *) &sec, optval, len)) {
89845 err = -EFAULT;
89846 break;
89847 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
89848 index b6e44ad..5b0d514 100644
89849 --- a/net/bluetooth/rfcomm/tty.c
89850 +++ b/net/bluetooth/rfcomm/tty.c
89851 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
89852 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
89853
89854 spin_lock_irqsave(&dev->port.lock, flags);
89855 - if (dev->port.count > 0) {
89856 + if (atomic_read(&dev->port.count) > 0) {
89857 spin_unlock_irqrestore(&dev->port.lock, flags);
89858 return;
89859 }
89860 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
89861 return -ENODEV;
89862
89863 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
89864 - dev->channel, dev->port.count);
89865 + dev->channel, atomic_read(&dev->port.count));
89866
89867 spin_lock_irqsave(&dev->port.lock, flags);
89868 - if (++dev->port.count > 1) {
89869 + if (atomic_inc_return(&dev->port.count) > 1) {
89870 spin_unlock_irqrestore(&dev->port.lock, flags);
89871 return 0;
89872 }
89873 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
89874 return;
89875
89876 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
89877 - dev->port.count);
89878 + atomic_read(&dev->port.count));
89879
89880 spin_lock_irqsave(&dev->port.lock, flags);
89881 - if (!--dev->port.count) {
89882 + if (!atomic_dec_return(&dev->port.count)) {
89883 spin_unlock_irqrestore(&dev->port.lock, flags);
89884 if (dev->tty_dev->parent)
89885 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
89886 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
89887 index 3d110c4..4e1b2eb 100644
89888 --- a/net/bridge/netfilter/ebtables.c
89889 +++ b/net/bridge/netfilter/ebtables.c
89890 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
89891 tmp.valid_hooks = t->table->valid_hooks;
89892 }
89893 mutex_unlock(&ebt_mutex);
89894 - if (copy_to_user(user, &tmp, *len) != 0){
89895 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
89896 BUGPRINT("c2u Didn't work\n");
89897 ret = -EFAULT;
89898 break;
89899 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
89900 goto out;
89901 tmp.valid_hooks = t->valid_hooks;
89902
89903 - if (copy_to_user(user, &tmp, *len) != 0) {
89904 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
89905 ret = -EFAULT;
89906 break;
89907 }
89908 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
89909 tmp.entries_size = t->table->entries_size;
89910 tmp.valid_hooks = t->table->valid_hooks;
89911
89912 - if (copy_to_user(user, &tmp, *len) != 0) {
89913 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
89914 ret = -EFAULT;
89915 break;
89916 }
89917 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
89918 index 2bd4b58..0dc30a1 100644
89919 --- a/net/caif/cfctrl.c
89920 +++ b/net/caif/cfctrl.c
89921 @@ -10,6 +10,7 @@
89922 #include <linux/spinlock.h>
89923 #include <linux/slab.h>
89924 #include <linux/pkt_sched.h>
89925 +#include <linux/sched.h>
89926 #include <net/caif/caif_layer.h>
89927 #include <net/caif/cfpkt.h>
89928 #include <net/caif/cfctrl.h>
89929 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
89930 memset(&dev_info, 0, sizeof(dev_info));
89931 dev_info.id = 0xff;
89932 cfsrvl_init(&this->serv, 0, &dev_info, false);
89933 - atomic_set(&this->req_seq_no, 1);
89934 - atomic_set(&this->rsp_seq_no, 1);
89935 + atomic_set_unchecked(&this->req_seq_no, 1);
89936 + atomic_set_unchecked(&this->rsp_seq_no, 1);
89937 this->serv.layer.receive = cfctrl_recv;
89938 sprintf(this->serv.layer.name, "ctrl");
89939 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
89940 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
89941 struct cfctrl_request_info *req)
89942 {
89943 spin_lock_bh(&ctrl->info_list_lock);
89944 - atomic_inc(&ctrl->req_seq_no);
89945 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
89946 + atomic_inc_unchecked(&ctrl->req_seq_no);
89947 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
89948 list_add_tail(&req->list, &ctrl->list);
89949 spin_unlock_bh(&ctrl->info_list_lock);
89950 }
89951 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
89952 if (p != first)
89953 pr_warn("Requests are not received in order\n");
89954
89955 - atomic_set(&ctrl->rsp_seq_no,
89956 + atomic_set_unchecked(&ctrl->rsp_seq_no,
89957 p->sequence_no);
89958 list_del(&p->list);
89959 goto out;
89960 diff --git a/net/can/af_can.c b/net/can/af_can.c
89961 index c4e5085..aa9efdf 100644
89962 --- a/net/can/af_can.c
89963 +++ b/net/can/af_can.c
89964 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
89965 };
89966
89967 /* notifier block for netdevice event */
89968 -static struct notifier_block can_netdev_notifier __read_mostly = {
89969 +static struct notifier_block can_netdev_notifier = {
89970 .notifier_call = can_notifier,
89971 };
89972
89973 diff --git a/net/can/gw.c b/net/can/gw.c
89974 index 3ee690e..00d581b 100644
89975 --- a/net/can/gw.c
89976 +++ b/net/can/gw.c
89977 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
89978 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
89979
89980 static HLIST_HEAD(cgw_list);
89981 -static struct notifier_block notifier;
89982
89983 static struct kmem_cache *cgw_cache __read_mostly;
89984
89985 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
89986 return err;
89987 }
89988
89989 +static struct notifier_block notifier = {
89990 + .notifier_call = cgw_notifier
89991 +};
89992 +
89993 static __init int cgw_module_init(void)
89994 {
89995 /* sanitize given module parameter */
89996 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
89997 return -ENOMEM;
89998
89999 /* set notifier */
90000 - notifier.notifier_call = cgw_notifier;
90001 register_netdevice_notifier(&notifier);
90002
90003 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
90004 diff --git a/net/compat.c b/net/compat.c
90005 index f0a1ba6..0541331 100644
90006 --- a/net/compat.c
90007 +++ b/net/compat.c
90008 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
90009 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
90010 __get_user(kmsg->msg_flags, &umsg->msg_flags))
90011 return -EFAULT;
90012 - kmsg->msg_name = compat_ptr(tmp1);
90013 - kmsg->msg_iov = compat_ptr(tmp2);
90014 - kmsg->msg_control = compat_ptr(tmp3);
90015 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
90016 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
90017 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
90018 return 0;
90019 }
90020
90021 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
90022
90023 if (kern_msg->msg_namelen) {
90024 if (mode == VERIFY_READ) {
90025 - int err = move_addr_to_kernel(kern_msg->msg_name,
90026 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
90027 kern_msg->msg_namelen,
90028 kern_address);
90029 if (err < 0)
90030 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
90031 kern_msg->msg_name = NULL;
90032
90033 tot_len = iov_from_user_compat_to_kern(kern_iov,
90034 - (struct compat_iovec __user *)kern_msg->msg_iov,
90035 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
90036 kern_msg->msg_iovlen);
90037 if (tot_len >= 0)
90038 kern_msg->msg_iov = kern_iov;
90039 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
90040
90041 #define CMSG_COMPAT_FIRSTHDR(msg) \
90042 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
90043 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
90044 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
90045 (struct compat_cmsghdr __user *)NULL)
90046
90047 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
90048 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
90049 (ucmlen) <= (unsigned long) \
90050 ((mhdr)->msg_controllen - \
90051 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
90052 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
90053
90054 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
90055 struct compat_cmsghdr __user *cmsg, int cmsg_len)
90056 {
90057 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
90058 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
90059 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
90060 msg->msg_controllen)
90061 return NULL;
90062 return (struct compat_cmsghdr __user *)ptr;
90063 @@ -219,7 +219,7 @@ Efault:
90064
90065 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
90066 {
90067 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
90068 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
90069 struct compat_cmsghdr cmhdr;
90070 struct compat_timeval ctv;
90071 struct compat_timespec cts[3];
90072 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
90073
90074 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
90075 {
90076 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
90077 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
90078 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
90079 int fdnum = scm->fp->count;
90080 struct file **fp = scm->fp->fp;
90081 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
90082 return -EFAULT;
90083 old_fs = get_fs();
90084 set_fs(KERNEL_DS);
90085 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
90086 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
90087 set_fs(old_fs);
90088
90089 return err;
90090 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
90091 len = sizeof(ktime);
90092 old_fs = get_fs();
90093 set_fs(KERNEL_DS);
90094 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
90095 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
90096 set_fs(old_fs);
90097
90098 if (!err) {
90099 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
90100 case MCAST_JOIN_GROUP:
90101 case MCAST_LEAVE_GROUP:
90102 {
90103 - struct compat_group_req __user *gr32 = (void *)optval;
90104 + struct compat_group_req __user *gr32 = (void __user *)optval;
90105 struct group_req __user *kgr =
90106 compat_alloc_user_space(sizeof(struct group_req));
90107 u32 interface;
90108 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
90109 case MCAST_BLOCK_SOURCE:
90110 case MCAST_UNBLOCK_SOURCE:
90111 {
90112 - struct compat_group_source_req __user *gsr32 = (void *)optval;
90113 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
90114 struct group_source_req __user *kgsr = compat_alloc_user_space(
90115 sizeof(struct group_source_req));
90116 u32 interface;
90117 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
90118 }
90119 case MCAST_MSFILTER:
90120 {
90121 - struct compat_group_filter __user *gf32 = (void *)optval;
90122 + struct compat_group_filter __user *gf32 = (void __user *)optval;
90123 struct group_filter __user *kgf;
90124 u32 interface, fmode, numsrc;
90125
90126 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
90127 char __user *optval, int __user *optlen,
90128 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
90129 {
90130 - struct compat_group_filter __user *gf32 = (void *)optval;
90131 + struct compat_group_filter __user *gf32 = (void __user *)optval;
90132 struct group_filter __user *kgf;
90133 int __user *koptlen;
90134 u32 interface, fmode, numsrc;
90135 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
90136
90137 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
90138 return -EINVAL;
90139 - if (copy_from_user(a, args, nas[call]))
90140 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
90141 return -EFAULT;
90142 a0 = a[0];
90143 a1 = a[1];
90144 diff --git a/net/core/datagram.c b/net/core/datagram.c
90145 index b71423d..0360434 100644
90146 --- a/net/core/datagram.c
90147 +++ b/net/core/datagram.c
90148 @@ -295,7 +295,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
90149 }
90150
90151 kfree_skb(skb);
90152 - atomic_inc(&sk->sk_drops);
90153 + atomic_inc_unchecked(&sk->sk_drops);
90154 sk_mem_reclaim_partial(sk);
90155
90156 return err;
90157 diff --git a/net/core/dev.c b/net/core/dev.c
90158 index 7ddbb31..3902452 100644
90159 --- a/net/core/dev.c
90160 +++ b/net/core/dev.c
90161 @@ -1649,7 +1649,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
90162 {
90163 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
90164 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
90165 - atomic_long_inc(&dev->rx_dropped);
90166 + atomic_long_inc_unchecked(&dev->rx_dropped);
90167 kfree_skb(skb);
90168 return NET_RX_DROP;
90169 }
90170 @@ -1658,7 +1658,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
90171 skb_orphan(skb);
90172
90173 if (unlikely(!is_skb_forwardable(dev, skb))) {
90174 - atomic_long_inc(&dev->rx_dropped);
90175 + atomic_long_inc_unchecked(&dev->rx_dropped);
90176 kfree_skb(skb);
90177 return NET_RX_DROP;
90178 }
90179 @@ -2404,7 +2404,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
90180
90181 struct dev_gso_cb {
90182 void (*destructor)(struct sk_buff *skb);
90183 -};
90184 +} __no_const;
90185
90186 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
90187
90188 @@ -3139,7 +3139,7 @@ enqueue:
90189
90190 local_irq_restore(flags);
90191
90192 - atomic_long_inc(&skb->dev->rx_dropped);
90193 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
90194 kfree_skb(skb);
90195 return NET_RX_DROP;
90196 }
90197 @@ -3211,7 +3211,7 @@ int netif_rx_ni(struct sk_buff *skb)
90198 }
90199 EXPORT_SYMBOL(netif_rx_ni);
90200
90201 -static void net_tx_action(struct softirq_action *h)
90202 +static void net_tx_action(void)
90203 {
90204 struct softnet_data *sd = &__get_cpu_var(softnet_data);
90205
90206 @@ -3545,7 +3545,7 @@ ncls:
90207 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
90208 } else {
90209 drop:
90210 - atomic_long_inc(&skb->dev->rx_dropped);
90211 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
90212 kfree_skb(skb);
90213 /* Jamal, now you will not able to escape explaining
90214 * me how you were going to use this. :-)
90215 @@ -4153,7 +4153,7 @@ void netif_napi_del(struct napi_struct *napi)
90216 }
90217 EXPORT_SYMBOL(netif_napi_del);
90218
90219 -static void net_rx_action(struct softirq_action *h)
90220 +static void net_rx_action(void)
90221 {
90222 struct softnet_data *sd = &__get_cpu_var(softnet_data);
90223 unsigned long time_limit = jiffies + 2;
90224 @@ -5590,7 +5590,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
90225 } else {
90226 netdev_stats_to_stats64(storage, &dev->stats);
90227 }
90228 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
90229 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
90230 return storage;
90231 }
90232 EXPORT_SYMBOL(dev_get_stats);
90233 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
90234 index 5b7d0e1..cb960fc 100644
90235 --- a/net/core/dev_ioctl.c
90236 +++ b/net/core/dev_ioctl.c
90237 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
90238 if (no_module && capable(CAP_NET_ADMIN))
90239 no_module = request_module("netdev-%s", name);
90240 if (no_module && capable(CAP_SYS_MODULE)) {
90241 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
90242 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
90243 +#else
90244 if (!request_module("%s", name))
90245 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
90246 name);
90247 +#endif
90248 }
90249 }
90250 EXPORT_SYMBOL(dev_load);
90251 diff --git a/net/core/ethtool.c b/net/core/ethtool.c
90252 index ce91766..3b71cdb 100644
90253 --- a/net/core/ethtool.c
90254 +++ b/net/core/ethtool.c
90255 @@ -1319,10 +1319,19 @@ static int ethtool_get_dump_data(struct net_device *dev,
90256 if (ret)
90257 return ret;
90258
90259 - len = (tmp.len > dump.len) ? dump.len : tmp.len;
90260 + len = min(tmp.len, dump.len);
90261 if (!len)
90262 return -EFAULT;
90263
90264 + /* Don't ever let the driver think there's more space available
90265 + * than it requested with .get_dump_flag().
90266 + */
90267 + dump.len = len;
90268 +
90269 + /* Always allocate enough space to hold the whole thing so that the
90270 + * driver does not need to check the length and bother with partial
90271 + * dumping.
90272 + */
90273 data = vzalloc(tmp.len);
90274 if (!data)
90275 return -ENOMEM;
90276 @@ -1330,6 +1339,16 @@ static int ethtool_get_dump_data(struct net_device *dev,
90277 if (ret)
90278 goto out;
90279
90280 + /* There are two sane possibilities:
90281 + * 1. The driver's .get_dump_data() does not touch dump.len.
90282 + * 2. Or it may set dump.len to how much it really writes, which
90283 + * should be tmp.len (or len if it can do a partial dump).
90284 + * In any case respond to userspace with the actual length of data
90285 + * it's receiving.
90286 + */
90287 + WARN_ON(dump.len != len && dump.len != tmp.len);
90288 + dump.len = len;
90289 +
90290 if (copy_to_user(useraddr, &dump, sizeof(dump))) {
90291 ret = -EFAULT;
90292 goto out;
90293 diff --git a/net/core/flow.c b/net/core/flow.c
90294 index 7102f16..146b4bd 100644
90295 --- a/net/core/flow.c
90296 +++ b/net/core/flow.c
90297 @@ -61,7 +61,7 @@ struct flow_cache {
90298 struct timer_list rnd_timer;
90299 };
90300
90301 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
90302 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
90303 EXPORT_SYMBOL(flow_cache_genid);
90304 static struct flow_cache flow_cache_global;
90305 static struct kmem_cache *flow_cachep __read_mostly;
90306 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
90307
90308 static int flow_entry_valid(struct flow_cache_entry *fle)
90309 {
90310 - if (atomic_read(&flow_cache_genid) != fle->genid)
90311 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
90312 return 0;
90313 if (fle->object && !fle->object->ops->check(fle->object))
90314 return 0;
90315 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
90316 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
90317 fcp->hash_count++;
90318 }
90319 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
90320 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
90321 flo = fle->object;
90322 if (!flo)
90323 goto ret_object;
90324 @@ -279,7 +279,7 @@ nocache:
90325 }
90326 flo = resolver(net, key, family, dir, flo, ctx);
90327 if (fle) {
90328 - fle->genid = atomic_read(&flow_cache_genid);
90329 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
90330 if (!IS_ERR(flo))
90331 fle->object = flo;
90332 else
90333 diff --git a/net/core/iovec.c b/net/core/iovec.c
90334 index de178e4..1dabd8b 100644
90335 --- a/net/core/iovec.c
90336 +++ b/net/core/iovec.c
90337 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
90338 if (m->msg_namelen) {
90339 if (mode == VERIFY_READ) {
90340 void __user *namep;
90341 - namep = (void __user __force *) m->msg_name;
90342 + namep = (void __force_user *) m->msg_name;
90343 err = move_addr_to_kernel(namep, m->msg_namelen,
90344 address);
90345 if (err < 0)
90346 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
90347 }
90348
90349 size = m->msg_iovlen * sizeof(struct iovec);
90350 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
90351 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
90352 return -EFAULT;
90353
90354 m->msg_iov = iov;
90355 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
90356 index ce90b02..8752627 100644
90357 --- a/net/core/neighbour.c
90358 +++ b/net/core/neighbour.c
90359 @@ -2771,7 +2771,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
90360 size_t *lenp, loff_t *ppos)
90361 {
90362 int size, ret;
90363 - ctl_table tmp = *ctl;
90364 + ctl_table_no_const tmp = *ctl;
90365
90366 tmp.extra1 = &zero;
90367 tmp.extra2 = &unres_qlen_max;
90368 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
90369 index 569d355..79cf2d0 100644
90370 --- a/net/core/net-procfs.c
90371 +++ b/net/core/net-procfs.c
90372 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
90373 else
90374 seq_printf(seq, "%04x", ntohs(pt->type));
90375
90376 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90377 + seq_printf(seq, " %-8s %pf\n",
90378 + pt->dev ? pt->dev->name : "", NULL);
90379 +#else
90380 seq_printf(seq, " %-8s %pf\n",
90381 pt->dev ? pt->dev->name : "", pt->func);
90382 +#endif
90383 }
90384
90385 return 0;
90386 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
90387 index 981fed3..536af34 100644
90388 --- a/net/core/net-sysfs.c
90389 +++ b/net/core/net-sysfs.c
90390 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
90391 }
90392 EXPORT_SYMBOL(netdev_class_remove_file);
90393
90394 -int netdev_kobject_init(void)
90395 +int __init netdev_kobject_init(void)
90396 {
90397 kobj_ns_type_register(&net_ns_type_operations);
90398 return class_register(&net_class);
90399 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
90400 index f9765203..9feaef8 100644
90401 --- a/net/core/net_namespace.c
90402 +++ b/net/core/net_namespace.c
90403 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
90404 int error;
90405 LIST_HEAD(net_exit_list);
90406
90407 - list_add_tail(&ops->list, list);
90408 + pax_list_add_tail((struct list_head *)&ops->list, list);
90409 if (ops->init || (ops->id && ops->size)) {
90410 for_each_net(net) {
90411 error = ops_init(ops, net);
90412 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
90413
90414 out_undo:
90415 /* If I have an error cleanup all namespaces I initialized */
90416 - list_del(&ops->list);
90417 + pax_list_del((struct list_head *)&ops->list);
90418 ops_exit_list(ops, &net_exit_list);
90419 ops_free_list(ops, &net_exit_list);
90420 return error;
90421 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
90422 struct net *net;
90423 LIST_HEAD(net_exit_list);
90424
90425 - list_del(&ops->list);
90426 + pax_list_del((struct list_head *)&ops->list);
90427 for_each_net(net)
90428 list_add_tail(&net->exit_list, &net_exit_list);
90429 ops_exit_list(ops, &net_exit_list);
90430 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
90431 mutex_lock(&net_mutex);
90432 error = register_pernet_operations(&pernet_list, ops);
90433 if (!error && (first_device == &pernet_list))
90434 - first_device = &ops->list;
90435 + first_device = (struct list_head *)&ops->list;
90436 mutex_unlock(&net_mutex);
90437 return error;
90438 }
90439 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
90440 index a08bd2b..c59bd7c 100644
90441 --- a/net/core/rtnetlink.c
90442 +++ b/net/core/rtnetlink.c
90443 @@ -58,7 +58,7 @@ struct rtnl_link {
90444 rtnl_doit_func doit;
90445 rtnl_dumpit_func dumpit;
90446 rtnl_calcit_func calcit;
90447 -};
90448 +} __no_const;
90449
90450 static DEFINE_MUTEX(rtnl_mutex);
90451
90452 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
90453 if (rtnl_link_ops_get(ops->kind))
90454 return -EEXIST;
90455
90456 - if (!ops->dellink)
90457 - ops->dellink = unregister_netdevice_queue;
90458 + if (!ops->dellink) {
90459 + pax_open_kernel();
90460 + *(void **)&ops->dellink = unregister_netdevice_queue;
90461 + pax_close_kernel();
90462 + }
90463
90464 - list_add_tail(&ops->list, &link_ops);
90465 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
90466 return 0;
90467 }
90468 EXPORT_SYMBOL_GPL(__rtnl_link_register);
90469 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
90470 for_each_net(net) {
90471 __rtnl_kill_links(net, ops);
90472 }
90473 - list_del(&ops->list);
90474 + pax_list_del((struct list_head *)&ops->list);
90475 }
90476 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
90477
90478 @@ -2374,7 +2377,7 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb)
90479 struct nlattr *extfilt;
90480 u32 filter_mask = 0;
90481
90482 - extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct rtgenmsg),
90483 + extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct ifinfomsg),
90484 IFLA_EXT_MASK);
90485 if (extfilt)
90486 filter_mask = nla_get_u32(extfilt);
90487 diff --git a/net/core/scm.c b/net/core/scm.c
90488 index 03795d0..eaf7368 100644
90489 --- a/net/core/scm.c
90490 +++ b/net/core/scm.c
90491 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
90492 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
90493 {
90494 struct cmsghdr __user *cm
90495 - = (__force struct cmsghdr __user *)msg->msg_control;
90496 + = (struct cmsghdr __force_user *)msg->msg_control;
90497 struct cmsghdr cmhdr;
90498 int cmlen = CMSG_LEN(len);
90499 int err;
90500 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
90501 err = -EFAULT;
90502 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
90503 goto out;
90504 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
90505 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
90506 goto out;
90507 cmlen = CMSG_SPACE(len);
90508 if (msg->msg_controllen < cmlen)
90509 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
90510 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
90511 {
90512 struct cmsghdr __user *cm
90513 - = (__force struct cmsghdr __user*)msg->msg_control;
90514 + = (struct cmsghdr __force_user *)msg->msg_control;
90515
90516 int fdmax = 0;
90517 int fdnum = scm->fp->count;
90518 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
90519 if (fdnum < fdmax)
90520 fdmax = fdnum;
90521
90522 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
90523 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
90524 i++, cmfptr++)
90525 {
90526 struct socket *sock;
90527 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
90528 index 1c1738c..4cab7f0 100644
90529 --- a/net/core/skbuff.c
90530 +++ b/net/core/skbuff.c
90531 @@ -3087,13 +3087,15 @@ void __init skb_init(void)
90532 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
90533 sizeof(struct sk_buff),
90534 0,
90535 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
90536 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
90537 + SLAB_NO_SANITIZE,
90538 NULL);
90539 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
90540 (2*sizeof(struct sk_buff)) +
90541 sizeof(atomic_t),
90542 0,
90543 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
90544 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
90545 + SLAB_NO_SANITIZE,
90546 NULL);
90547 }
90548
90549 diff --git a/net/core/sock.c b/net/core/sock.c
90550 index d6d024c..6ea7ab4 100644
90551 --- a/net/core/sock.c
90552 +++ b/net/core/sock.c
90553 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
90554 struct sk_buff_head *list = &sk->sk_receive_queue;
90555
90556 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
90557 - atomic_inc(&sk->sk_drops);
90558 + atomic_inc_unchecked(&sk->sk_drops);
90559 trace_sock_rcvqueue_full(sk, skb);
90560 return -ENOMEM;
90561 }
90562 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
90563 return err;
90564
90565 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
90566 - atomic_inc(&sk->sk_drops);
90567 + atomic_inc_unchecked(&sk->sk_drops);
90568 return -ENOBUFS;
90569 }
90570
90571 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
90572 skb_dst_force(skb);
90573
90574 spin_lock_irqsave(&list->lock, flags);
90575 - skb->dropcount = atomic_read(&sk->sk_drops);
90576 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
90577 __skb_queue_tail(list, skb);
90578 spin_unlock_irqrestore(&list->lock, flags);
90579
90580 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
90581 skb->dev = NULL;
90582
90583 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
90584 - atomic_inc(&sk->sk_drops);
90585 + atomic_inc_unchecked(&sk->sk_drops);
90586 goto discard_and_relse;
90587 }
90588 if (nested)
90589 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
90590 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
90591 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
90592 bh_unlock_sock(sk);
90593 - atomic_inc(&sk->sk_drops);
90594 + atomic_inc_unchecked(&sk->sk_drops);
90595 goto discard_and_relse;
90596 }
90597
90598 @@ -933,12 +933,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
90599 struct timeval tm;
90600 } v;
90601
90602 - int lv = sizeof(int);
90603 - int len;
90604 + unsigned int lv = sizeof(int);
90605 + unsigned int len;
90606
90607 if (get_user(len, optlen))
90608 return -EFAULT;
90609 - if (len < 0)
90610 + if (len > INT_MAX)
90611 return -EINVAL;
90612
90613 memset(&v, 0, sizeof(v));
90614 @@ -1090,11 +1090,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
90615
90616 case SO_PEERNAME:
90617 {
90618 - char address[128];
90619 + char address[_K_SS_MAXSIZE];
90620
90621 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
90622 return -ENOTCONN;
90623 - if (lv < len)
90624 + if (lv < len || sizeof address < len)
90625 return -EINVAL;
90626 if (copy_to_user(optval, address, len))
90627 return -EFAULT;
90628 @@ -1161,7 +1161,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
90629
90630 if (len > lv)
90631 len = lv;
90632 - if (copy_to_user(optval, &v, len))
90633 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
90634 return -EFAULT;
90635 lenout:
90636 if (put_user(len, optlen))
90637 @@ -2277,7 +2277,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
90638 */
90639 smp_wmb();
90640 atomic_set(&sk->sk_refcnt, 1);
90641 - atomic_set(&sk->sk_drops, 0);
90642 + atomic_set_unchecked(&sk->sk_drops, 0);
90643 }
90644 EXPORT_SYMBOL(sock_init_data);
90645
90646 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
90647 index a0e9cf6..ef7f9ed 100644
90648 --- a/net/core/sock_diag.c
90649 +++ b/net/core/sock_diag.c
90650 @@ -9,26 +9,33 @@
90651 #include <linux/inet_diag.h>
90652 #include <linux/sock_diag.h>
90653
90654 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
90655 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
90656 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
90657 static DEFINE_MUTEX(sock_diag_table_mutex);
90658
90659 int sock_diag_check_cookie(void *sk, __u32 *cookie)
90660 {
90661 +#ifndef CONFIG_GRKERNSEC_HIDESYM
90662 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
90663 cookie[1] != INET_DIAG_NOCOOKIE) &&
90664 ((u32)(unsigned long)sk != cookie[0] ||
90665 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
90666 return -ESTALE;
90667 else
90668 +#endif
90669 return 0;
90670 }
90671 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
90672
90673 void sock_diag_save_cookie(void *sk, __u32 *cookie)
90674 {
90675 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90676 + cookie[0] = 0;
90677 + cookie[1] = 0;
90678 +#else
90679 cookie[0] = (u32)(unsigned long)sk;
90680 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
90681 +#endif
90682 }
90683 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
90684
90685 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
90686 mutex_lock(&sock_diag_table_mutex);
90687 if (sock_diag_handlers[hndl->family])
90688 err = -EBUSY;
90689 - else
90690 + else {
90691 + pax_open_kernel();
90692 sock_diag_handlers[hndl->family] = hndl;
90693 + pax_close_kernel();
90694 + }
90695 mutex_unlock(&sock_diag_table_mutex);
90696
90697 return err;
90698 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
90699
90700 mutex_lock(&sock_diag_table_mutex);
90701 BUG_ON(sock_diag_handlers[family] != hnld);
90702 + pax_open_kernel();
90703 sock_diag_handlers[family] = NULL;
90704 + pax_close_kernel();
90705 mutex_unlock(&sock_diag_table_mutex);
90706 }
90707 EXPORT_SYMBOL_GPL(sock_diag_unregister);
90708 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
90709 index cfdb46a..cef55e1 100644
90710 --- a/net/core/sysctl_net_core.c
90711 +++ b/net/core/sysctl_net_core.c
90712 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
90713 {
90714 unsigned int orig_size, size;
90715 int ret, i;
90716 - ctl_table tmp = {
90717 + ctl_table_no_const tmp = {
90718 .data = &size,
90719 .maxlen = sizeof(size),
90720 .mode = table->mode
90721 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
90722
90723 static __net_init int sysctl_core_net_init(struct net *net)
90724 {
90725 - struct ctl_table *tbl;
90726 + ctl_table_no_const *tbl = NULL;
90727
90728 net->core.sysctl_somaxconn = SOMAXCONN;
90729
90730 - tbl = netns_core_table;
90731 if (!net_eq(net, &init_net)) {
90732 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
90733 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
90734 if (tbl == NULL)
90735 goto err_dup;
90736
90737 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
90738 if (net->user_ns != &init_user_ns) {
90739 tbl[0].procname = NULL;
90740 }
90741 - }
90742 -
90743 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
90744 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
90745 + } else
90746 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
90747 if (net->core.sysctl_hdr == NULL)
90748 goto err_reg;
90749
90750 return 0;
90751
90752 err_reg:
90753 - if (tbl != netns_core_table)
90754 - kfree(tbl);
90755 + kfree(tbl);
90756 err_dup:
90757 return -ENOMEM;
90758 }
90759 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
90760 kfree(tbl);
90761 }
90762
90763 -static __net_initdata struct pernet_operations sysctl_core_ops = {
90764 +static __net_initconst struct pernet_operations sysctl_core_ops = {
90765 .init = sysctl_core_net_init,
90766 .exit = sysctl_core_net_exit,
90767 };
90768 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
90769 index c21f200..bc4565b 100644
90770 --- a/net/decnet/af_decnet.c
90771 +++ b/net/decnet/af_decnet.c
90772 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
90773 .sysctl_rmem = sysctl_decnet_rmem,
90774 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
90775 .obj_size = sizeof(struct dn_sock),
90776 + .slab_flags = SLAB_USERCOPY,
90777 };
90778
90779 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
90780 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
90781 index a55eecc..dd8428c 100644
90782 --- a/net/decnet/sysctl_net_decnet.c
90783 +++ b/net/decnet/sysctl_net_decnet.c
90784 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
90785
90786 if (len > *lenp) len = *lenp;
90787
90788 - if (copy_to_user(buffer, addr, len))
90789 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
90790 return -EFAULT;
90791
90792 *lenp = len;
90793 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
90794
90795 if (len > *lenp) len = *lenp;
90796
90797 - if (copy_to_user(buffer, devname, len))
90798 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
90799 return -EFAULT;
90800
90801 *lenp = len;
90802 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
90803 index d01be2a..8976537 100644
90804 --- a/net/ipv4/af_inet.c
90805 +++ b/net/ipv4/af_inet.c
90806 @@ -1703,13 +1703,9 @@ static int __init inet_init(void)
90807
90808 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
90809
90810 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
90811 - if (!sysctl_local_reserved_ports)
90812 - goto out;
90813 -
90814 rc = proto_register(&tcp_prot, 1);
90815 if (rc)
90816 - goto out_free_reserved_ports;
90817 + goto out;
90818
90819 rc = proto_register(&udp_prot, 1);
90820 if (rc)
90821 @@ -1818,8 +1814,6 @@ out_unregister_udp_proto:
90822 proto_unregister(&udp_prot);
90823 out_unregister_tcp_proto:
90824 proto_unregister(&tcp_prot);
90825 -out_free_reserved_ports:
90826 - kfree(sysctl_local_reserved_ports);
90827 goto out;
90828 }
90829
90830 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
90831 index 2e7f194..0fa4d6d 100644
90832 --- a/net/ipv4/ah4.c
90833 +++ b/net/ipv4/ah4.c
90834 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
90835 return;
90836
90837 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
90838 - atomic_inc(&flow_cache_genid);
90839 + atomic_inc_unchecked(&flow_cache_genid);
90840 rt_genid_bump(net);
90841
90842 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
90843 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
90844 index dfc39d4..0d4fa52 100644
90845 --- a/net/ipv4/devinet.c
90846 +++ b/net/ipv4/devinet.c
90847 @@ -771,7 +771,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
90848 ci = nla_data(tb[IFA_CACHEINFO]);
90849 if (!ci->ifa_valid || ci->ifa_prefered > ci->ifa_valid) {
90850 err = -EINVAL;
90851 - goto errout;
90852 + goto errout_free;
90853 }
90854 *pvalid_lft = ci->ifa_valid;
90855 *pprefered_lft = ci->ifa_prefered;
90856 @@ -779,6 +779,8 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
90857
90858 return ifa;
90859
90860 +errout_free:
90861 + inet_free_ifa(ifa);
90862 errout:
90863 return ERR_PTR(err);
90864 }
90865 @@ -1529,7 +1531,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
90866 idx = 0;
90867 head = &net->dev_index_head[h];
90868 rcu_read_lock();
90869 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
90870 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
90871 net->dev_base_seq;
90872 hlist_for_each_entry_rcu(dev, head, index_hlist) {
90873 if (idx < s_idx)
90874 @@ -1840,7 +1842,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
90875 idx = 0;
90876 head = &net->dev_index_head[h];
90877 rcu_read_lock();
90878 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
90879 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
90880 net->dev_base_seq;
90881 hlist_for_each_entry_rcu(dev, head, index_hlist) {
90882 if (idx < s_idx)
90883 @@ -2065,7 +2067,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
90884 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
90885 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
90886
90887 -static struct devinet_sysctl_table {
90888 +static const struct devinet_sysctl_table {
90889 struct ctl_table_header *sysctl_header;
90890 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
90891 } devinet_sysctl = {
90892 @@ -2183,7 +2185,7 @@ static __net_init int devinet_init_net(struct net *net)
90893 int err;
90894 struct ipv4_devconf *all, *dflt;
90895 #ifdef CONFIG_SYSCTL
90896 - struct ctl_table *tbl = ctl_forward_entry;
90897 + ctl_table_no_const *tbl = NULL;
90898 struct ctl_table_header *forw_hdr;
90899 #endif
90900
90901 @@ -2201,7 +2203,7 @@ static __net_init int devinet_init_net(struct net *net)
90902 goto err_alloc_dflt;
90903
90904 #ifdef CONFIG_SYSCTL
90905 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
90906 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
90907 if (tbl == NULL)
90908 goto err_alloc_ctl;
90909
90910 @@ -2221,7 +2223,10 @@ static __net_init int devinet_init_net(struct net *net)
90911 goto err_reg_dflt;
90912
90913 err = -ENOMEM;
90914 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
90915 + if (!net_eq(net, &init_net))
90916 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
90917 + else
90918 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
90919 if (forw_hdr == NULL)
90920 goto err_reg_ctl;
90921 net->ipv4.forw_hdr = forw_hdr;
90922 @@ -2237,8 +2242,7 @@ err_reg_ctl:
90923 err_reg_dflt:
90924 __devinet_sysctl_unregister(all);
90925 err_reg_all:
90926 - if (tbl != ctl_forward_entry)
90927 - kfree(tbl);
90928 + kfree(tbl);
90929 err_alloc_ctl:
90930 #endif
90931 if (dflt != &ipv4_devconf_dflt)
90932 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
90933 index 4cfe34d..d2fac8a 100644
90934 --- a/net/ipv4/esp4.c
90935 +++ b/net/ipv4/esp4.c
90936 @@ -477,7 +477,7 @@ static u32 esp4_get_mtu(struct xfrm_state *x, int mtu)
90937 }
90938
90939 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
90940 - net_adj) & ~(align - 1)) + (net_adj - 2);
90941 + net_adj) & ~(align - 1)) + net_adj - 2;
90942 }
90943
90944 static void esp4_err(struct sk_buff *skb, u32 info)
90945 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
90946 return;
90947
90948 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
90949 - atomic_inc(&flow_cache_genid);
90950 + atomic_inc_unchecked(&flow_cache_genid);
90951 rt_genid_bump(net);
90952
90953 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
90954 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
90955 index c7629a2..b62d139 100644
90956 --- a/net/ipv4/fib_frontend.c
90957 +++ b/net/ipv4/fib_frontend.c
90958 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
90959 #ifdef CONFIG_IP_ROUTE_MULTIPATH
90960 fib_sync_up(dev);
90961 #endif
90962 - atomic_inc(&net->ipv4.dev_addr_genid);
90963 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
90964 rt_cache_flush(dev_net(dev));
90965 break;
90966 case NETDEV_DOWN:
90967 fib_del_ifaddr(ifa, NULL);
90968 - atomic_inc(&net->ipv4.dev_addr_genid);
90969 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
90970 if (ifa->ifa_dev->ifa_list == NULL) {
90971 /* Last address was deleted from this interface.
90972 * Disable IP.
90973 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
90974 #ifdef CONFIG_IP_ROUTE_MULTIPATH
90975 fib_sync_up(dev);
90976 #endif
90977 - atomic_inc(&net->ipv4.dev_addr_genid);
90978 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
90979 rt_cache_flush(net);
90980 break;
90981 case NETDEV_DOWN:
90982 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
90983 index 8f6cb7a..34507f9 100644
90984 --- a/net/ipv4/fib_semantics.c
90985 +++ b/net/ipv4/fib_semantics.c
90986 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
90987 nh->nh_saddr = inet_select_addr(nh->nh_dev,
90988 nh->nh_gw,
90989 nh->nh_parent->fib_scope);
90990 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
90991 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
90992
90993 return nh->nh_saddr;
90994 }
90995 diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
90996 index 49616fe..6e8a13d 100644
90997 --- a/net/ipv4/fib_trie.c
90998 +++ b/net/ipv4/fib_trie.c
90999 @@ -71,7 +71,6 @@
91000 #include <linux/init.h>
91001 #include <linux/list.h>
91002 #include <linux/slab.h>
91003 -#include <linux/prefetch.h>
91004 #include <linux/export.h>
91005 #include <net/net_namespace.h>
91006 #include <net/ip.h>
91007 @@ -1761,10 +1760,8 @@ static struct leaf *leaf_walk_rcu(struct tnode *p, struct rt_trie_node *c)
91008 if (!c)
91009 continue;
91010
91011 - if (IS_LEAF(c)) {
91012 - prefetch(rcu_dereference_rtnl(p->child[idx]));
91013 + if (IS_LEAF(c))
91014 return (struct leaf *) c;
91015 - }
91016
91017 /* Rescan start scanning in new node */
91018 p = (struct tnode *) c;
91019 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
91020 index 6acb541..9ea617d 100644
91021 --- a/net/ipv4/inet_connection_sock.c
91022 +++ b/net/ipv4/inet_connection_sock.c
91023 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
91024 .range = { 32768, 61000 },
91025 };
91026
91027 -unsigned long *sysctl_local_reserved_ports;
91028 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
91029 EXPORT_SYMBOL(sysctl_local_reserved_ports);
91030
91031 void inet_get_local_port_range(int *low, int *high)
91032 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
91033 index 6af375a..c493c74 100644
91034 --- a/net/ipv4/inet_hashtables.c
91035 +++ b/net/ipv4/inet_hashtables.c
91036 @@ -18,12 +18,15 @@
91037 #include <linux/sched.h>
91038 #include <linux/slab.h>
91039 #include <linux/wait.h>
91040 +#include <linux/security.h>
91041
91042 #include <net/inet_connection_sock.h>
91043 #include <net/inet_hashtables.h>
91044 #include <net/secure_seq.h>
91045 #include <net/ip.h>
91046
91047 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
91048 +
91049 /*
91050 * Allocate and initialize a new local port bind bucket.
91051 * The bindhash mutex for snum's hash chain must be held here.
91052 @@ -554,6 +557,8 @@ ok:
91053 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
91054 spin_unlock(&head->lock);
91055
91056 + gr_update_task_in_ip_table(current, inet_sk(sk));
91057 +
91058 if (tw) {
91059 inet_twsk_deschedule(tw, death_row);
91060 while (twrefcnt) {
91061 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
91062 index 000e3d2..5472da3 100644
91063 --- a/net/ipv4/inetpeer.c
91064 +++ b/net/ipv4/inetpeer.c
91065 @@ -503,8 +503,8 @@ relookup:
91066 if (p) {
91067 p->daddr = *daddr;
91068 atomic_set(&p->refcnt, 1);
91069 - atomic_set(&p->rid, 0);
91070 - atomic_set(&p->ip_id_count,
91071 + atomic_set_unchecked(&p->rid, 0);
91072 + atomic_set_unchecked(&p->ip_id_count,
91073 (daddr->family == AF_INET) ?
91074 secure_ip_id(daddr->addr.a4) :
91075 secure_ipv6_id(daddr->addr.a6));
91076 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
91077 index b66910a..cfe416e 100644
91078 --- a/net/ipv4/ip_fragment.c
91079 +++ b/net/ipv4/ip_fragment.c
91080 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
91081 return 0;
91082
91083 start = qp->rid;
91084 - end = atomic_inc_return(&peer->rid);
91085 + end = atomic_inc_return_unchecked(&peer->rid);
91086 qp->rid = end;
91087
91088 rc = qp->q.fragments && (end - start) > max;
91089 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
91090
91091 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
91092 {
91093 - struct ctl_table *table;
91094 + ctl_table_no_const *table = NULL;
91095 struct ctl_table_header *hdr;
91096
91097 - table = ip4_frags_ns_ctl_table;
91098 if (!net_eq(net, &init_net)) {
91099 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
91100 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
91101 if (table == NULL)
91102 goto err_alloc;
91103
91104 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
91105 /* Don't export sysctls to unprivileged users */
91106 if (net->user_ns != &init_user_ns)
91107 table[0].procname = NULL;
91108 - }
91109 + hdr = register_net_sysctl(net, "net/ipv4", table);
91110 + } else
91111 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
91112
91113 - hdr = register_net_sysctl(net, "net/ipv4", table);
91114 if (hdr == NULL)
91115 goto err_reg;
91116
91117 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
91118 return 0;
91119
91120 err_reg:
91121 - if (!net_eq(net, &init_net))
91122 - kfree(table);
91123 + kfree(table);
91124 err_alloc:
91125 return -ENOMEM;
91126 }
91127 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
91128 index 855004f..9644112 100644
91129 --- a/net/ipv4/ip_gre.c
91130 +++ b/net/ipv4/ip_gre.c
91131 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
91132 module_param(log_ecn_error, bool, 0644);
91133 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
91134
91135 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
91136 +static struct rtnl_link_ops ipgre_link_ops;
91137 static int ipgre_tunnel_init(struct net_device *dev);
91138
91139 static int ipgre_net_id __read_mostly;
91140 @@ -572,7 +572,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
91141 if (daddr)
91142 memcpy(&iph->daddr, daddr, 4);
91143 if (iph->daddr)
91144 - return t->hlen;
91145 + return t->hlen + sizeof(*iph);
91146
91147 return -(t->hlen + sizeof(*iph));
91148 }
91149 @@ -919,7 +919,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
91150 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
91151 };
91152
91153 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
91154 +static struct rtnl_link_ops ipgre_link_ops = {
91155 .kind = "gre",
91156 .maxtype = IFLA_GRE_MAX,
91157 .policy = ipgre_policy,
91158 @@ -933,7 +933,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
91159 .fill_info = ipgre_fill_info,
91160 };
91161
91162 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
91163 +static struct rtnl_link_ops ipgre_tap_ops = {
91164 .kind = "gretap",
91165 .maxtype = IFLA_GRE_MAX,
91166 .policy = ipgre_policy,
91167 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
91168 index d9c4f11..02b82dbc 100644
91169 --- a/net/ipv4/ip_sockglue.c
91170 +++ b/net/ipv4/ip_sockglue.c
91171 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
91172 len = min_t(unsigned int, len, opt->optlen);
91173 if (put_user(len, optlen))
91174 return -EFAULT;
91175 - if (copy_to_user(optval, opt->__data, len))
91176 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
91177 + copy_to_user(optval, opt->__data, len))
91178 return -EFAULT;
91179 return 0;
91180 }
91181 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
91182 if (sk->sk_type != SOCK_STREAM)
91183 return -ENOPROTOOPT;
91184
91185 - msg.msg_control = optval;
91186 + msg.msg_control = (void __force_kernel *)optval;
91187 msg.msg_controllen = len;
91188 msg.msg_flags = flags;
91189
91190 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
91191 index 17cc0ff..63856c4 100644
91192 --- a/net/ipv4/ip_vti.c
91193 +++ b/net/ipv4/ip_vti.c
91194 @@ -47,7 +47,7 @@
91195 #define HASH_SIZE 16
91196 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
91197
91198 -static struct rtnl_link_ops vti_link_ops __read_mostly;
91199 +static struct rtnl_link_ops vti_link_ops;
91200
91201 static int vti_net_id __read_mostly;
91202 struct vti_net {
91203 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
91204 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
91205 };
91206
91207 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
91208 +static struct rtnl_link_ops vti_link_ops = {
91209 .kind = "vti",
91210 .maxtype = IFLA_VTI_MAX,
91211 .policy = vti_policy,
91212 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
91213 index 59cb8c7..a72160c 100644
91214 --- a/net/ipv4/ipcomp.c
91215 +++ b/net/ipv4/ipcomp.c
91216 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
91217 return;
91218
91219 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
91220 - atomic_inc(&flow_cache_genid);
91221 + atomic_inc_unchecked(&flow_cache_genid);
91222 rt_genid_bump(net);
91223
91224 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
91225 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
91226 index efa1138..20dbba0 100644
91227 --- a/net/ipv4/ipconfig.c
91228 +++ b/net/ipv4/ipconfig.c
91229 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
91230
91231 mm_segment_t oldfs = get_fs();
91232 set_fs(get_ds());
91233 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
91234 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
91235 set_fs(oldfs);
91236 return res;
91237 }
91238 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
91239
91240 mm_segment_t oldfs = get_fs();
91241 set_fs(get_ds());
91242 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
91243 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
91244 set_fs(oldfs);
91245 return res;
91246 }
91247 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
91248
91249 mm_segment_t oldfs = get_fs();
91250 set_fs(get_ds());
91251 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
91252 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
91253 set_fs(oldfs);
91254 return res;
91255 }
91256 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
91257 index 7cfc456..e726868 100644
91258 --- a/net/ipv4/ipip.c
91259 +++ b/net/ipv4/ipip.c
91260 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
91261 static int ipip_net_id __read_mostly;
91262
91263 static int ipip_tunnel_init(struct net_device *dev);
91264 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
91265 +static struct rtnl_link_ops ipip_link_ops;
91266
91267 static int ipip_err(struct sk_buff *skb, u32 info)
91268 {
91269 @@ -406,7 +406,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
91270 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
91271 };
91272
91273 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
91274 +static struct rtnl_link_ops ipip_link_ops = {
91275 .kind = "ipip",
91276 .maxtype = IFLA_IPTUN_MAX,
91277 .policy = ipip_policy,
91278 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
91279 index 85a4f21..1beb1f5 100644
91280 --- a/net/ipv4/netfilter/arp_tables.c
91281 +++ b/net/ipv4/netfilter/arp_tables.c
91282 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
91283 #endif
91284
91285 static int get_info(struct net *net, void __user *user,
91286 - const int *len, int compat)
91287 + int len, int compat)
91288 {
91289 char name[XT_TABLE_MAXNAMELEN];
91290 struct xt_table *t;
91291 int ret;
91292
91293 - if (*len != sizeof(struct arpt_getinfo)) {
91294 - duprintf("length %u != %Zu\n", *len,
91295 + if (len != sizeof(struct arpt_getinfo)) {
91296 + duprintf("length %u != %Zu\n", len,
91297 sizeof(struct arpt_getinfo));
91298 return -EINVAL;
91299 }
91300 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
91301 info.size = private->size;
91302 strcpy(info.name, name);
91303
91304 - if (copy_to_user(user, &info, *len) != 0)
91305 + if (copy_to_user(user, &info, len) != 0)
91306 ret = -EFAULT;
91307 else
91308 ret = 0;
91309 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
91310
91311 switch (cmd) {
91312 case ARPT_SO_GET_INFO:
91313 - ret = get_info(sock_net(sk), user, len, 1);
91314 + ret = get_info(sock_net(sk), user, *len, 1);
91315 break;
91316 case ARPT_SO_GET_ENTRIES:
91317 ret = compat_get_entries(sock_net(sk), user, len);
91318 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
91319
91320 switch (cmd) {
91321 case ARPT_SO_GET_INFO:
91322 - ret = get_info(sock_net(sk), user, len, 0);
91323 + ret = get_info(sock_net(sk), user, *len, 0);
91324 break;
91325
91326 case ARPT_SO_GET_ENTRIES:
91327 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
91328 index d23118d..6ad7277 100644
91329 --- a/net/ipv4/netfilter/ip_tables.c
91330 +++ b/net/ipv4/netfilter/ip_tables.c
91331 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
91332 #endif
91333
91334 static int get_info(struct net *net, void __user *user,
91335 - const int *len, int compat)
91336 + int len, int compat)
91337 {
91338 char name[XT_TABLE_MAXNAMELEN];
91339 struct xt_table *t;
91340 int ret;
91341
91342 - if (*len != sizeof(struct ipt_getinfo)) {
91343 - duprintf("length %u != %zu\n", *len,
91344 + if (len != sizeof(struct ipt_getinfo)) {
91345 + duprintf("length %u != %zu\n", len,
91346 sizeof(struct ipt_getinfo));
91347 return -EINVAL;
91348 }
91349 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
91350 info.size = private->size;
91351 strcpy(info.name, name);
91352
91353 - if (copy_to_user(user, &info, *len) != 0)
91354 + if (copy_to_user(user, &info, len) != 0)
91355 ret = -EFAULT;
91356 else
91357 ret = 0;
91358 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91359
91360 switch (cmd) {
91361 case IPT_SO_GET_INFO:
91362 - ret = get_info(sock_net(sk), user, len, 1);
91363 + ret = get_info(sock_net(sk), user, *len, 1);
91364 break;
91365 case IPT_SO_GET_ENTRIES:
91366 ret = compat_get_entries(sock_net(sk), user, len);
91367 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91368
91369 switch (cmd) {
91370 case IPT_SO_GET_INFO:
91371 - ret = get_info(sock_net(sk), user, len, 0);
91372 + ret = get_info(sock_net(sk), user, *len, 0);
91373 break;
91374
91375 case IPT_SO_GET_ENTRIES:
91376 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
91377 index 7d93d62..cbbf2a3 100644
91378 --- a/net/ipv4/ping.c
91379 +++ b/net/ipv4/ping.c
91380 @@ -843,7 +843,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
91381 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
91382 0, sock_i_ino(sp),
91383 atomic_read(&sp->sk_refcnt), sp,
91384 - atomic_read(&sp->sk_drops), len);
91385 + atomic_read_unchecked(&sp->sk_drops), len);
91386 }
91387
91388 static int ping_seq_show(struct seq_file *seq, void *v)
91389 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
91390 index dd44e0a..06dcca4 100644
91391 --- a/net/ipv4/raw.c
91392 +++ b/net/ipv4/raw.c
91393 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
91394 int raw_rcv(struct sock *sk, struct sk_buff *skb)
91395 {
91396 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
91397 - atomic_inc(&sk->sk_drops);
91398 + atomic_inc_unchecked(&sk->sk_drops);
91399 kfree_skb(skb);
91400 return NET_RX_DROP;
91401 }
91402 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
91403
91404 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
91405 {
91406 + struct icmp_filter filter;
91407 +
91408 if (optlen > sizeof(struct icmp_filter))
91409 optlen = sizeof(struct icmp_filter);
91410 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
91411 + if (copy_from_user(&filter, optval, optlen))
91412 return -EFAULT;
91413 + raw_sk(sk)->filter = filter;
91414 return 0;
91415 }
91416
91417 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
91418 {
91419 int len, ret = -EFAULT;
91420 + struct icmp_filter filter;
91421
91422 if (get_user(len, optlen))
91423 goto out;
91424 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
91425 if (len > sizeof(struct icmp_filter))
91426 len = sizeof(struct icmp_filter);
91427 ret = -EFAULT;
91428 - if (put_user(len, optlen) ||
91429 - copy_to_user(optval, &raw_sk(sk)->filter, len))
91430 + filter = raw_sk(sk)->filter;
91431 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
91432 goto out;
91433 ret = 0;
91434 out: return ret;
91435 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
91436 0, 0L, 0,
91437 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
91438 0, sock_i_ino(sp),
91439 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
91440 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
91441 }
91442
91443 static int raw_seq_show(struct seq_file *seq, void *v)
91444 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
91445 index d35bbf0..faa3ab8 100644
91446 --- a/net/ipv4/route.c
91447 +++ b/net/ipv4/route.c
91448 @@ -2558,34 +2558,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
91449 .maxlen = sizeof(int),
91450 .mode = 0200,
91451 .proc_handler = ipv4_sysctl_rtcache_flush,
91452 + .extra1 = &init_net,
91453 },
91454 { },
91455 };
91456
91457 static __net_init int sysctl_route_net_init(struct net *net)
91458 {
91459 - struct ctl_table *tbl;
91460 + ctl_table_no_const *tbl = NULL;
91461
91462 - tbl = ipv4_route_flush_table;
91463 if (!net_eq(net, &init_net)) {
91464 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
91465 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
91466 if (tbl == NULL)
91467 goto err_dup;
91468
91469 /* Don't export sysctls to unprivileged users */
91470 if (net->user_ns != &init_user_ns)
91471 tbl[0].procname = NULL;
91472 - }
91473 - tbl[0].extra1 = net;
91474 + tbl[0].extra1 = net;
91475 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
91476 + } else
91477 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
91478
91479 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
91480 if (net->ipv4.route_hdr == NULL)
91481 goto err_reg;
91482 return 0;
91483
91484 err_reg:
91485 - if (tbl != ipv4_route_flush_table)
91486 - kfree(tbl);
91487 + kfree(tbl);
91488 err_dup:
91489 return -ENOMEM;
91490 }
91491 @@ -2608,7 +2608,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
91492
91493 static __net_init int rt_genid_init(struct net *net)
91494 {
91495 - atomic_set(&net->rt_genid, 0);
91496 + atomic_set_unchecked(&net->rt_genid, 0);
91497 get_random_bytes(&net->ipv4.dev_addr_genid,
91498 sizeof(net->ipv4.dev_addr_genid));
91499 return 0;
91500 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
91501 index 3f25e75..3ae0f4d 100644
91502 --- a/net/ipv4/sysctl_net_ipv4.c
91503 +++ b/net/ipv4/sysctl_net_ipv4.c
91504 @@ -57,7 +57,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
91505 {
91506 int ret;
91507 int range[2];
91508 - ctl_table tmp = {
91509 + ctl_table_no_const tmp = {
91510 .data = &range,
91511 .maxlen = sizeof(range),
91512 .mode = table->mode,
91513 @@ -110,7 +110,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
91514 int ret;
91515 gid_t urange[2];
91516 kgid_t low, high;
91517 - ctl_table tmp = {
91518 + ctl_table_no_const tmp = {
91519 .data = &urange,
91520 .maxlen = sizeof(urange),
91521 .mode = table->mode,
91522 @@ -141,7 +141,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
91523 void __user *buffer, size_t *lenp, loff_t *ppos)
91524 {
91525 char val[TCP_CA_NAME_MAX];
91526 - ctl_table tbl = {
91527 + ctl_table_no_const tbl = {
91528 .data = val,
91529 .maxlen = TCP_CA_NAME_MAX,
91530 };
91531 @@ -160,7 +160,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
91532 void __user *buffer, size_t *lenp,
91533 loff_t *ppos)
91534 {
91535 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
91536 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
91537 int ret;
91538
91539 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
91540 @@ -177,7 +177,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
91541 void __user *buffer, size_t *lenp,
91542 loff_t *ppos)
91543 {
91544 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
91545 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
91546 int ret;
91547
91548 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
91549 @@ -203,15 +203,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
91550 struct mem_cgroup *memcg;
91551 #endif
91552
91553 - ctl_table tmp = {
91554 + ctl_table_no_const tmp = {
91555 .data = &vec,
91556 .maxlen = sizeof(vec),
91557 .mode = ctl->mode,
91558 };
91559
91560 if (!write) {
91561 - ctl->data = &net->ipv4.sysctl_tcp_mem;
91562 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
91563 + ctl_table_no_const tcp_mem = *ctl;
91564 +
91565 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
91566 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
91567 }
91568
91569 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
91570 @@ -238,7 +240,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
91571 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
91572 size_t *lenp, loff_t *ppos)
91573 {
91574 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
91575 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
91576 struct tcp_fastopen_context *ctxt;
91577 int ret;
91578 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
91579 @@ -481,7 +483,7 @@ static struct ctl_table ipv4_table[] = {
91580 },
91581 {
91582 .procname = "ip_local_reserved_ports",
91583 - .data = NULL, /* initialized in sysctl_ipv4_init */
91584 + .data = sysctl_local_reserved_ports,
91585 .maxlen = 65536,
91586 .mode = 0644,
91587 .proc_handler = proc_do_large_bitmap,
91588 @@ -846,11 +848,10 @@ static struct ctl_table ipv4_net_table[] = {
91589
91590 static __net_init int ipv4_sysctl_init_net(struct net *net)
91591 {
91592 - struct ctl_table *table;
91593 + ctl_table_no_const *table = NULL;
91594
91595 - table = ipv4_net_table;
91596 if (!net_eq(net, &init_net)) {
91597 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
91598 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
91599 if (table == NULL)
91600 goto err_alloc;
91601
91602 @@ -885,15 +886,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
91603
91604 tcp_init_mem(net);
91605
91606 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
91607 + if (!net_eq(net, &init_net))
91608 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
91609 + else
91610 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
91611 if (net->ipv4.ipv4_hdr == NULL)
91612 goto err_reg;
91613
91614 return 0;
91615
91616 err_reg:
91617 - if (!net_eq(net, &init_net))
91618 - kfree(table);
91619 + kfree(table);
91620 err_alloc:
91621 return -ENOMEM;
91622 }
91623 @@ -915,16 +918,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
91624 static __init int sysctl_ipv4_init(void)
91625 {
91626 struct ctl_table_header *hdr;
91627 - struct ctl_table *i;
91628 -
91629 - for (i = ipv4_table; i->procname; i++) {
91630 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
91631 - i->data = sysctl_local_reserved_ports;
91632 - break;
91633 - }
91634 - }
91635 - if (!i->procname)
91636 - return -EINVAL;
91637
91638 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
91639 if (hdr == NULL)
91640 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
91641 index 9c62257..651cc27 100644
91642 --- a/net/ipv4/tcp_input.c
91643 +++ b/net/ipv4/tcp_input.c
91644 @@ -4436,7 +4436,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
91645 * simplifies code)
91646 */
91647 static void
91648 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
91649 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
91650 struct sk_buff *head, struct sk_buff *tail,
91651 u32 start, u32 end)
91652 {
91653 @@ -5522,6 +5522,7 @@ discard:
91654 tcp_paws_reject(&tp->rx_opt, 0))
91655 goto discard_and_undo;
91656
91657 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
91658 if (th->syn) {
91659 /* We see SYN without ACK. It is attempt of
91660 * simultaneous connect with crossed SYNs.
91661 @@ -5572,6 +5573,7 @@ discard:
91662 goto discard;
91663 #endif
91664 }
91665 +#endif
91666 /* "fifth, if neither of the SYN or RST bits is set then
91667 * drop the segment and return."
91668 */
91669 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
91670 goto discard;
91671
91672 if (th->syn) {
91673 - if (th->fin)
91674 + if (th->fin || th->urg || th->psh)
91675 goto discard;
91676 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
91677 return 1;
91678 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
91679 index 7999fc5..c812f42 100644
91680 --- a/net/ipv4/tcp_ipv4.c
91681 +++ b/net/ipv4/tcp_ipv4.c
91682 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
91683 EXPORT_SYMBOL(sysctl_tcp_low_latency);
91684
91685
91686 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91687 +extern int grsec_enable_blackhole;
91688 +#endif
91689 +
91690 #ifdef CONFIG_TCP_MD5SIG
91691 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
91692 __be32 daddr, __be32 saddr, const struct tcphdr *th);
91693 @@ -1855,6 +1859,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
91694 return 0;
91695
91696 reset:
91697 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91698 + if (!grsec_enable_blackhole)
91699 +#endif
91700 tcp_v4_send_reset(rsk, skb);
91701 discard:
91702 kfree_skb(skb);
91703 @@ -2000,12 +2007,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
91704 TCP_SKB_CB(skb)->sacked = 0;
91705
91706 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
91707 - if (!sk)
91708 + if (!sk) {
91709 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91710 + ret = 1;
91711 +#endif
91712 goto no_tcp_socket;
91713 -
91714 + }
91715 process:
91716 - if (sk->sk_state == TCP_TIME_WAIT)
91717 + if (sk->sk_state == TCP_TIME_WAIT) {
91718 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91719 + ret = 2;
91720 +#endif
91721 goto do_time_wait;
91722 + }
91723
91724 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
91725 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
91726 @@ -2058,6 +2072,10 @@ csum_error:
91727 bad_packet:
91728 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
91729 } else {
91730 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91731 + if (!grsec_enable_blackhole || (ret == 1 &&
91732 + (skb->dev->flags & IFF_LOOPBACK)))
91733 +#endif
91734 tcp_v4_send_reset(NULL, skb);
91735 }
91736
91737 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
91738 index 0f01788..d52a859 100644
91739 --- a/net/ipv4/tcp_minisocks.c
91740 +++ b/net/ipv4/tcp_minisocks.c
91741 @@ -27,6 +27,10 @@
91742 #include <net/inet_common.h>
91743 #include <net/xfrm.h>
91744
91745 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91746 +extern int grsec_enable_blackhole;
91747 +#endif
91748 +
91749 int sysctl_tcp_syncookies __read_mostly = 1;
91750 EXPORT_SYMBOL(sysctl_tcp_syncookies);
91751
91752 @@ -717,7 +721,10 @@ embryonic_reset:
91753 * avoid becoming vulnerable to outside attack aiming at
91754 * resetting legit local connections.
91755 */
91756 - req->rsk_ops->send_reset(sk, skb);
91757 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91758 + if (!grsec_enable_blackhole)
91759 +#endif
91760 + req->rsk_ops->send_reset(sk, skb);
91761 } else if (fastopen) { /* received a valid RST pkt */
91762 reqsk_fastopen_remove(sk, req, true);
91763 tcp_reset(sk);
91764 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
91765 index d4943f6..e7a74a5 100644
91766 --- a/net/ipv4/tcp_probe.c
91767 +++ b/net/ipv4/tcp_probe.c
91768 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
91769 if (cnt + width >= len)
91770 break;
91771
91772 - if (copy_to_user(buf + cnt, tbuf, width))
91773 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
91774 return -EFAULT;
91775 cnt += width;
91776 }
91777 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
91778 index 4b85e6f..22f9ac9 100644
91779 --- a/net/ipv4/tcp_timer.c
91780 +++ b/net/ipv4/tcp_timer.c
91781 @@ -22,6 +22,10 @@
91782 #include <linux/gfp.h>
91783 #include <net/tcp.h>
91784
91785 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91786 +extern int grsec_lastack_retries;
91787 +#endif
91788 +
91789 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
91790 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
91791 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
91792 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
91793 }
91794 }
91795
91796 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91797 + if ((sk->sk_state == TCP_LAST_ACK) &&
91798 + (grsec_lastack_retries > 0) &&
91799 + (grsec_lastack_retries < retry_until))
91800 + retry_until = grsec_lastack_retries;
91801 +#endif
91802 +
91803 if (retransmits_timed_out(sk, retry_until,
91804 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
91805 /* Has it gone just too far? */
91806 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
91807 index 93b731d..5a2dd92 100644
91808 --- a/net/ipv4/udp.c
91809 +++ b/net/ipv4/udp.c
91810 @@ -87,6 +87,7 @@
91811 #include <linux/types.h>
91812 #include <linux/fcntl.h>
91813 #include <linux/module.h>
91814 +#include <linux/security.h>
91815 #include <linux/socket.h>
91816 #include <linux/sockios.h>
91817 #include <linux/igmp.h>
91818 @@ -111,6 +112,10 @@
91819 #include <trace/events/skb.h>
91820 #include "udp_impl.h"
91821
91822 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91823 +extern int grsec_enable_blackhole;
91824 +#endif
91825 +
91826 struct udp_table udp_table __read_mostly;
91827 EXPORT_SYMBOL(udp_table);
91828
91829 @@ -594,6 +599,9 @@ found:
91830 return s;
91831 }
91832
91833 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
91834 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
91835 +
91836 /*
91837 * This routine is called by the ICMP module when it gets some
91838 * sort of error condition. If err < 0 then the socket should
91839 @@ -890,9 +898,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
91840 dport = usin->sin_port;
91841 if (dport == 0)
91842 return -EINVAL;
91843 +
91844 + err = gr_search_udp_sendmsg(sk, usin);
91845 + if (err)
91846 + return err;
91847 } else {
91848 if (sk->sk_state != TCP_ESTABLISHED)
91849 return -EDESTADDRREQ;
91850 +
91851 + err = gr_search_udp_sendmsg(sk, NULL);
91852 + if (err)
91853 + return err;
91854 +
91855 daddr = inet->inet_daddr;
91856 dport = inet->inet_dport;
91857 /* Open fast path for connected socket.
91858 @@ -1136,7 +1153,7 @@ static unsigned int first_packet_length(struct sock *sk)
91859 IS_UDPLITE(sk));
91860 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
91861 IS_UDPLITE(sk));
91862 - atomic_inc(&sk->sk_drops);
91863 + atomic_inc_unchecked(&sk->sk_drops);
91864 __skb_unlink(skb, rcvq);
91865 __skb_queue_tail(&list_kill, skb);
91866 }
91867 @@ -1222,6 +1239,10 @@ try_again:
91868 if (!skb)
91869 goto out;
91870
91871 + err = gr_search_udp_recvmsg(sk, skb);
91872 + if (err)
91873 + goto out_free;
91874 +
91875 ulen = skb->len - sizeof(struct udphdr);
91876 copied = len;
91877 if (copied > ulen)
91878 @@ -1255,7 +1276,7 @@ try_again:
91879 if (unlikely(err)) {
91880 trace_kfree_skb(skb, udp_recvmsg);
91881 if (!peeked) {
91882 - atomic_inc(&sk->sk_drops);
91883 + atomic_inc_unchecked(&sk->sk_drops);
91884 UDP_INC_STATS_USER(sock_net(sk),
91885 UDP_MIB_INERRORS, is_udplite);
91886 }
91887 @@ -1542,7 +1563,7 @@ csum_error:
91888 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
91889 drop:
91890 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
91891 - atomic_inc(&sk->sk_drops);
91892 + atomic_inc_unchecked(&sk->sk_drops);
91893 kfree_skb(skb);
91894 return -1;
91895 }
91896 @@ -1561,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
91897 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
91898
91899 if (!skb1) {
91900 - atomic_inc(&sk->sk_drops);
91901 + atomic_inc_unchecked(&sk->sk_drops);
91902 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
91903 IS_UDPLITE(sk));
91904 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
91905 @@ -1730,6 +1751,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
91906 goto csum_error;
91907
91908 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
91909 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91910 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
91911 +#endif
91912 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
91913
91914 /*
91915 @@ -2160,7 +2184,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
91916 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
91917 0, sock_i_ino(sp),
91918 atomic_read(&sp->sk_refcnt), sp,
91919 - atomic_read(&sp->sk_drops), len);
91920 + atomic_read_unchecked(&sp->sk_drops), len);
91921 }
91922
91923 int udp4_seq_show(struct seq_file *seq, void *v)
91924 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
91925 index 9a459be..086b866 100644
91926 --- a/net/ipv4/xfrm4_policy.c
91927 +++ b/net/ipv4/xfrm4_policy.c
91928 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
91929
91930 static int __net_init xfrm4_net_init(struct net *net)
91931 {
91932 - struct ctl_table *table;
91933 + ctl_table_no_const *table = NULL;
91934 struct ctl_table_header *hdr;
91935
91936 - table = xfrm4_policy_table;
91937 if (!net_eq(net, &init_net)) {
91938 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
91939 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
91940 if (!table)
91941 goto err_alloc;
91942
91943 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
91944 - }
91945 -
91946 - hdr = register_net_sysctl(net, "net/ipv4", table);
91947 + hdr = register_net_sysctl(net, "net/ipv4", table);
91948 + } else
91949 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
91950 if (!hdr)
91951 goto err_reg;
91952
91953 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
91954 return 0;
91955
91956 err_reg:
91957 - if (!net_eq(net, &init_net))
91958 - kfree(table);
91959 + kfree(table);
91960 err_alloc:
91961 return -ENOMEM;
91962 }
91963 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
91964 index fb8c94c..fb18024 100644
91965 --- a/net/ipv6/addrconf.c
91966 +++ b/net/ipv6/addrconf.c
91967 @@ -621,7 +621,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
91968 idx = 0;
91969 head = &net->dev_index_head[h];
91970 rcu_read_lock();
91971 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
91972 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
91973 net->dev_base_seq;
91974 hlist_for_each_entry_rcu(dev, head, index_hlist) {
91975 if (idx < s_idx)
91976 @@ -2380,7 +2380,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
91977 p.iph.ihl = 5;
91978 p.iph.protocol = IPPROTO_IPV6;
91979 p.iph.ttl = 64;
91980 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
91981 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
91982
91983 if (ops->ndo_do_ioctl) {
91984 mm_segment_t oldfs = get_fs();
91985 @@ -4002,7 +4002,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
91986 s_ip_idx = ip_idx = cb->args[2];
91987
91988 rcu_read_lock();
91989 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
91990 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
91991 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
91992 idx = 0;
91993 head = &net->dev_index_head[h];
91994 @@ -4587,7 +4587,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
91995 dst_free(&ifp->rt->dst);
91996 break;
91997 }
91998 - atomic_inc(&net->ipv6.dev_addr_genid);
91999 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
92000 }
92001
92002 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
92003 @@ -4607,7 +4607,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
92004 int *valp = ctl->data;
92005 int val = *valp;
92006 loff_t pos = *ppos;
92007 - ctl_table lctl;
92008 + ctl_table_no_const lctl;
92009 int ret;
92010
92011 /*
92012 @@ -4689,7 +4689,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
92013 int *valp = ctl->data;
92014 int val = *valp;
92015 loff_t pos = *ppos;
92016 - ctl_table lctl;
92017 + ctl_table_no_const lctl;
92018 int ret;
92019
92020 /*
92021 diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
92022 index 40ffd72..aeac0dc 100644
92023 --- a/net/ipv6/esp6.c
92024 +++ b/net/ipv6/esp6.c
92025 @@ -425,7 +425,7 @@ static u32 esp6_get_mtu(struct xfrm_state *x, int mtu)
92026 net_adj = 0;
92027
92028 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
92029 - net_adj) & ~(align - 1)) + (net_adj - 2);
92030 + net_adj) & ~(align - 1)) + net_adj - 2;
92031 }
92032
92033 static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
92034 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
92035 index b4ff0a4..db9b764 100644
92036 --- a/net/ipv6/icmp.c
92037 +++ b/net/ipv6/icmp.c
92038 @@ -980,7 +980,7 @@ ctl_table ipv6_icmp_table_template[] = {
92039
92040 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
92041 {
92042 - struct ctl_table *table;
92043 + ctl_table_no_const *table;
92044
92045 table = kmemdup(ipv6_icmp_table_template,
92046 sizeof(ipv6_icmp_table_template),
92047 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
92048 index ecd6073..58162ae 100644
92049 --- a/net/ipv6/ip6_gre.c
92050 +++ b/net/ipv6/ip6_gre.c
92051 @@ -74,7 +74,7 @@ struct ip6gre_net {
92052 struct net_device *fb_tunnel_dev;
92053 };
92054
92055 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
92056 +static struct rtnl_link_ops ip6gre_link_ops;
92057 static int ip6gre_tunnel_init(struct net_device *dev);
92058 static void ip6gre_tunnel_setup(struct net_device *dev);
92059 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
92060 @@ -1283,7 +1283,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
92061 }
92062
92063
92064 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
92065 +static struct inet6_protocol ip6gre_protocol = {
92066 .handler = ip6gre_rcv,
92067 .err_handler = ip6gre_err,
92068 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
92069 @@ -1617,7 +1617,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
92070 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
92071 };
92072
92073 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
92074 +static struct rtnl_link_ops ip6gre_link_ops = {
92075 .kind = "ip6gre",
92076 .maxtype = IFLA_GRE_MAX,
92077 .policy = ip6gre_policy,
92078 @@ -1630,7 +1630,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
92079 .fill_info = ip6gre_fill_info,
92080 };
92081
92082 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
92083 +static struct rtnl_link_ops ip6gre_tap_ops = {
92084 .kind = "ip6gretap",
92085 .maxtype = IFLA_GRE_MAX,
92086 .policy = ip6gre_policy,
92087 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
92088 index 1e55866..b398dab 100644
92089 --- a/net/ipv6/ip6_tunnel.c
92090 +++ b/net/ipv6/ip6_tunnel.c
92091 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
92092
92093 static int ip6_tnl_dev_init(struct net_device *dev);
92094 static void ip6_tnl_dev_setup(struct net_device *dev);
92095 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
92096 +static struct rtnl_link_ops ip6_link_ops;
92097
92098 static int ip6_tnl_net_id __read_mostly;
92099 struct ip6_tnl_net {
92100 @@ -1672,7 +1672,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
92101 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
92102 };
92103
92104 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
92105 +static struct rtnl_link_ops ip6_link_ops = {
92106 .kind = "ip6tnl",
92107 .maxtype = IFLA_IPTUN_MAX,
92108 .policy = ip6_tnl_policy,
92109 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
92110 index d1e2e8e..51c19ae 100644
92111 --- a/net/ipv6/ipv6_sockglue.c
92112 +++ b/net/ipv6/ipv6_sockglue.c
92113 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
92114 if (sk->sk_type != SOCK_STREAM)
92115 return -ENOPROTOOPT;
92116
92117 - msg.msg_control = optval;
92118 + msg.msg_control = (void __force_kernel *)optval;
92119 msg.msg_controllen = len;
92120 msg.msg_flags = flags;
92121
92122 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
92123 index 44400c2..8e11f52 100644
92124 --- a/net/ipv6/netfilter/ip6_tables.c
92125 +++ b/net/ipv6/netfilter/ip6_tables.c
92126 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
92127 #endif
92128
92129 static int get_info(struct net *net, void __user *user,
92130 - const int *len, int compat)
92131 + int len, int compat)
92132 {
92133 char name[XT_TABLE_MAXNAMELEN];
92134 struct xt_table *t;
92135 int ret;
92136
92137 - if (*len != sizeof(struct ip6t_getinfo)) {
92138 - duprintf("length %u != %zu\n", *len,
92139 + if (len != sizeof(struct ip6t_getinfo)) {
92140 + duprintf("length %u != %zu\n", len,
92141 sizeof(struct ip6t_getinfo));
92142 return -EINVAL;
92143 }
92144 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
92145 info.size = private->size;
92146 strcpy(info.name, name);
92147
92148 - if (copy_to_user(user, &info, *len) != 0)
92149 + if (copy_to_user(user, &info, len) != 0)
92150 ret = -EFAULT;
92151 else
92152 ret = 0;
92153 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92154
92155 switch (cmd) {
92156 case IP6T_SO_GET_INFO:
92157 - ret = get_info(sock_net(sk), user, len, 1);
92158 + ret = get_info(sock_net(sk), user, *len, 1);
92159 break;
92160 case IP6T_SO_GET_ENTRIES:
92161 ret = compat_get_entries(sock_net(sk), user, len);
92162 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92163
92164 switch (cmd) {
92165 case IP6T_SO_GET_INFO:
92166 - ret = get_info(sock_net(sk), user, len, 0);
92167 + ret = get_info(sock_net(sk), user, *len, 0);
92168 break;
92169
92170 case IP6T_SO_GET_ENTRIES:
92171 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
92172 index dffdc1a..ccc6678 100644
92173 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
92174 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
92175 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
92176
92177 static int nf_ct_frag6_sysctl_register(struct net *net)
92178 {
92179 - struct ctl_table *table;
92180 + ctl_table_no_const *table = NULL;
92181 struct ctl_table_header *hdr;
92182
92183 - table = nf_ct_frag6_sysctl_table;
92184 if (!net_eq(net, &init_net)) {
92185 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
92186 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
92187 GFP_KERNEL);
92188 if (table == NULL)
92189 goto err_alloc;
92190 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
92191 table[0].data = &net->nf_frag.frags.timeout;
92192 table[1].data = &net->nf_frag.frags.low_thresh;
92193 table[2].data = &net->nf_frag.frags.high_thresh;
92194 - }
92195 -
92196 - hdr = register_net_sysctl(net, "net/netfilter", table);
92197 + hdr = register_net_sysctl(net, "net/netfilter", table);
92198 + } else
92199 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
92200 if (hdr == NULL)
92201 goto err_reg;
92202
92203 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
92204 return 0;
92205
92206 err_reg:
92207 - if (!net_eq(net, &init_net))
92208 - kfree(table);
92209 + kfree(table);
92210 err_alloc:
92211 return -ENOMEM;
92212 }
92213 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
92214 index eedff8c..6e13a47 100644
92215 --- a/net/ipv6/raw.c
92216 +++ b/net/ipv6/raw.c
92217 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
92218 {
92219 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
92220 skb_checksum_complete(skb)) {
92221 - atomic_inc(&sk->sk_drops);
92222 + atomic_inc_unchecked(&sk->sk_drops);
92223 kfree_skb(skb);
92224 return NET_RX_DROP;
92225 }
92226 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
92227 struct raw6_sock *rp = raw6_sk(sk);
92228
92229 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
92230 - atomic_inc(&sk->sk_drops);
92231 + atomic_inc_unchecked(&sk->sk_drops);
92232 kfree_skb(skb);
92233 return NET_RX_DROP;
92234 }
92235 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
92236
92237 if (inet->hdrincl) {
92238 if (skb_checksum_complete(skb)) {
92239 - atomic_inc(&sk->sk_drops);
92240 + atomic_inc_unchecked(&sk->sk_drops);
92241 kfree_skb(skb);
92242 return NET_RX_DROP;
92243 }
92244 @@ -602,7 +602,7 @@ out:
92245 return err;
92246 }
92247
92248 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
92249 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
92250 struct flowi6 *fl6, struct dst_entry **dstp,
92251 unsigned int flags)
92252 {
92253 @@ -914,12 +914,15 @@ do_confirm:
92254 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
92255 char __user *optval, int optlen)
92256 {
92257 + struct icmp6_filter filter;
92258 +
92259 switch (optname) {
92260 case ICMPV6_FILTER:
92261 if (optlen > sizeof(struct icmp6_filter))
92262 optlen = sizeof(struct icmp6_filter);
92263 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
92264 + if (copy_from_user(&filter, optval, optlen))
92265 return -EFAULT;
92266 + raw6_sk(sk)->filter = filter;
92267 return 0;
92268 default:
92269 return -ENOPROTOOPT;
92270 @@ -932,6 +935,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
92271 char __user *optval, int __user *optlen)
92272 {
92273 int len;
92274 + struct icmp6_filter filter;
92275
92276 switch (optname) {
92277 case ICMPV6_FILTER:
92278 @@ -943,7 +947,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
92279 len = sizeof(struct icmp6_filter);
92280 if (put_user(len, optlen))
92281 return -EFAULT;
92282 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
92283 + filter = raw6_sk(sk)->filter;
92284 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
92285 return -EFAULT;
92286 return 0;
92287 default:
92288 @@ -1251,7 +1256,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
92289 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
92290 0,
92291 sock_i_ino(sp),
92292 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
92293 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
92294 }
92295
92296 static int raw6_seq_show(struct seq_file *seq, void *v)
92297 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
92298 index 790d9f4..68ae078 100644
92299 --- a/net/ipv6/reassembly.c
92300 +++ b/net/ipv6/reassembly.c
92301 @@ -621,12 +621,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
92302
92303 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
92304 {
92305 - struct ctl_table *table;
92306 + ctl_table_no_const *table = NULL;
92307 struct ctl_table_header *hdr;
92308
92309 - table = ip6_frags_ns_ctl_table;
92310 if (!net_eq(net, &init_net)) {
92311 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
92312 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
92313 if (table == NULL)
92314 goto err_alloc;
92315
92316 @@ -637,9 +636,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
92317 /* Don't export sysctls to unprivileged users */
92318 if (net->user_ns != &init_user_ns)
92319 table[0].procname = NULL;
92320 - }
92321 + hdr = register_net_sysctl(net, "net/ipv6", table);
92322 + } else
92323 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
92324
92325 - hdr = register_net_sysctl(net, "net/ipv6", table);
92326 if (hdr == NULL)
92327 goto err_reg;
92328
92329 @@ -647,8 +647,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
92330 return 0;
92331
92332 err_reg:
92333 - if (!net_eq(net, &init_net))
92334 - kfree(table);
92335 + kfree(table);
92336 err_alloc:
92337 return -ENOMEM;
92338 }
92339 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
92340 index bacce6c..9d1741a 100644
92341 --- a/net/ipv6/route.c
92342 +++ b/net/ipv6/route.c
92343 @@ -2903,7 +2903,7 @@ ctl_table ipv6_route_table_template[] = {
92344
92345 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
92346 {
92347 - struct ctl_table *table;
92348 + ctl_table_no_const *table;
92349
92350 table = kmemdup(ipv6_route_table_template,
92351 sizeof(ipv6_route_table_template),
92352 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
92353 index 60df36d..f3ab7c8 100644
92354 --- a/net/ipv6/sit.c
92355 +++ b/net/ipv6/sit.c
92356 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
92357 static void ipip6_dev_free(struct net_device *dev);
92358 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
92359 __be32 *v4dst);
92360 -static struct rtnl_link_ops sit_link_ops __read_mostly;
92361 +static struct rtnl_link_ops sit_link_ops;
92362
92363 static int sit_net_id __read_mostly;
92364 struct sit_net {
92365 @@ -1453,7 +1453,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
92366 #endif
92367 };
92368
92369 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
92370 +static struct rtnl_link_ops sit_link_ops = {
92371 .kind = "sit",
92372 .maxtype = IFLA_IPTUN_MAX,
92373 .policy = ipip6_policy,
92374 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
92375 index e85c48b..b8268d3 100644
92376 --- a/net/ipv6/sysctl_net_ipv6.c
92377 +++ b/net/ipv6/sysctl_net_ipv6.c
92378 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
92379
92380 static int __net_init ipv6_sysctl_net_init(struct net *net)
92381 {
92382 - struct ctl_table *ipv6_table;
92383 + ctl_table_no_const *ipv6_table;
92384 struct ctl_table *ipv6_route_table;
92385 struct ctl_table *ipv6_icmp_table;
92386 int err;
92387 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
92388 index 0a17ed9..2526cc3 100644
92389 --- a/net/ipv6/tcp_ipv6.c
92390 +++ b/net/ipv6/tcp_ipv6.c
92391 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
92392 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
92393 }
92394
92395 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92396 +extern int grsec_enable_blackhole;
92397 +#endif
92398 +
92399 static void tcp_v6_hash(struct sock *sk)
92400 {
92401 if (sk->sk_state != TCP_CLOSE) {
92402 @@ -1398,6 +1402,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
92403 return 0;
92404
92405 reset:
92406 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92407 + if (!grsec_enable_blackhole)
92408 +#endif
92409 tcp_v6_send_reset(sk, skb);
92410 discard:
92411 if (opt_skb)
92412 @@ -1480,12 +1487,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
92413 TCP_SKB_CB(skb)->sacked = 0;
92414
92415 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
92416 - if (!sk)
92417 + if (!sk) {
92418 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92419 + ret = 1;
92420 +#endif
92421 goto no_tcp_socket;
92422 + }
92423
92424 process:
92425 - if (sk->sk_state == TCP_TIME_WAIT)
92426 + if (sk->sk_state == TCP_TIME_WAIT) {
92427 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92428 + ret = 2;
92429 +#endif
92430 goto do_time_wait;
92431 + }
92432
92433 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
92434 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
92435 @@ -1536,6 +1551,10 @@ csum_error:
92436 bad_packet:
92437 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
92438 } else {
92439 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92440 + if (!grsec_enable_blackhole || (ret == 1 &&
92441 + (skb->dev->flags & IFF_LOOPBACK)))
92442 +#endif
92443 tcp_v6_send_reset(NULL, skb);
92444 }
92445
92446 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
92447 index e7b28f9..d09c290 100644
92448 --- a/net/ipv6/udp.c
92449 +++ b/net/ipv6/udp.c
92450 @@ -52,6 +52,10 @@
92451 #include <trace/events/skb.h>
92452 #include "udp_impl.h"
92453
92454 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92455 +extern int grsec_enable_blackhole;
92456 +#endif
92457 +
92458 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
92459 {
92460 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
92461 @@ -419,7 +423,7 @@ try_again:
92462 if (unlikely(err)) {
92463 trace_kfree_skb(skb, udpv6_recvmsg);
92464 if (!peeked) {
92465 - atomic_inc(&sk->sk_drops);
92466 + atomic_inc_unchecked(&sk->sk_drops);
92467 if (is_udp4)
92468 UDP_INC_STATS_USER(sock_net(sk),
92469 UDP_MIB_INERRORS,
92470 @@ -665,7 +669,7 @@ csum_error:
92471 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
92472 drop:
92473 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
92474 - atomic_inc(&sk->sk_drops);
92475 + atomic_inc_unchecked(&sk->sk_drops);
92476 kfree_skb(skb);
92477 return -1;
92478 }
92479 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
92480 if (likely(skb1 == NULL))
92481 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
92482 if (!skb1) {
92483 - atomic_inc(&sk->sk_drops);
92484 + atomic_inc_unchecked(&sk->sk_drops);
92485 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
92486 IS_UDPLITE(sk));
92487 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
92488 @@ -860,6 +864,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
92489 goto csum_error;
92490
92491 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
92492 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92493 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
92494 +#endif
92495 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
92496
92497 kfree_skb(skb);
92498 @@ -1392,7 +1399,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
92499 0,
92500 sock_i_ino(sp),
92501 atomic_read(&sp->sk_refcnt), sp,
92502 - atomic_read(&sp->sk_drops));
92503 + atomic_read_unchecked(&sp->sk_drops));
92504 }
92505
92506 int udp6_seq_show(struct seq_file *seq, void *v)
92507 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
92508 index 23ed03d..465a71d 100644
92509 --- a/net/ipv6/xfrm6_policy.c
92510 +++ b/net/ipv6/xfrm6_policy.c
92511 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
92512
92513 static int __net_init xfrm6_net_init(struct net *net)
92514 {
92515 - struct ctl_table *table;
92516 + ctl_table_no_const *table = NULL;
92517 struct ctl_table_header *hdr;
92518
92519 - table = xfrm6_policy_table;
92520 if (!net_eq(net, &init_net)) {
92521 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
92522 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
92523 if (!table)
92524 goto err_alloc;
92525
92526 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
92527 - }
92528 + hdr = register_net_sysctl(net, "net/ipv6", table);
92529 + } else
92530 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
92531
92532 - hdr = register_net_sysctl(net, "net/ipv6", table);
92533 if (!hdr)
92534 goto err_reg;
92535
92536 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
92537 return 0;
92538
92539 err_reg:
92540 - if (!net_eq(net, &init_net))
92541 - kfree(table);
92542 + kfree(table);
92543 err_alloc:
92544 return -ENOMEM;
92545 }
92546 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
92547 index 41ac7938..75e3bb1 100644
92548 --- a/net/irda/ircomm/ircomm_tty.c
92549 +++ b/net/irda/ircomm/ircomm_tty.c
92550 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
92551 add_wait_queue(&port->open_wait, &wait);
92552
92553 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
92554 - __FILE__, __LINE__, tty->driver->name, port->count);
92555 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
92556
92557 spin_lock_irqsave(&port->lock, flags);
92558 if (!tty_hung_up_p(filp))
92559 - port->count--;
92560 + atomic_dec(&port->count);
92561 port->blocked_open++;
92562 spin_unlock_irqrestore(&port->lock, flags);
92563
92564 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
92565 }
92566
92567 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
92568 - __FILE__, __LINE__, tty->driver->name, port->count);
92569 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
92570
92571 schedule();
92572 }
92573 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
92574
92575 spin_lock_irqsave(&port->lock, flags);
92576 if (!tty_hung_up_p(filp))
92577 - port->count++;
92578 + atomic_inc(&port->count);
92579 port->blocked_open--;
92580 spin_unlock_irqrestore(&port->lock, flags);
92581
92582 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
92583 - __FILE__, __LINE__, tty->driver->name, port->count);
92584 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
92585
92586 if (!retval)
92587 port->flags |= ASYNC_NORMAL_ACTIVE;
92588 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
92589
92590 /* ++ is not atomic, so this should be protected - Jean II */
92591 spin_lock_irqsave(&self->port.lock, flags);
92592 - self->port.count++;
92593 + atomic_inc(&self->port.count);
92594 spin_unlock_irqrestore(&self->port.lock, flags);
92595 tty_port_tty_set(&self->port, tty);
92596
92597 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
92598 - self->line, self->port.count);
92599 + self->line, atomic_read(&self->port.count));
92600
92601 /* Not really used by us, but lets do it anyway */
92602 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
92603 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
92604 tty_kref_put(port->tty);
92605 }
92606 port->tty = NULL;
92607 - port->count = 0;
92608 + atomic_set(&port->count, 0);
92609 spin_unlock_irqrestore(&port->lock, flags);
92610
92611 wake_up_interruptible(&port->open_wait);
92612 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
92613 seq_putc(m, '\n');
92614
92615 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
92616 - seq_printf(m, "Open count: %d\n", self->port.count);
92617 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
92618 seq_printf(m, "Max data size: %d\n", self->max_data_size);
92619 seq_printf(m, "Max header size: %d\n", self->max_header_size);
92620
92621 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
92622 index ae69165..c8b82d8 100644
92623 --- a/net/iucv/af_iucv.c
92624 +++ b/net/iucv/af_iucv.c
92625 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
92626
92627 write_lock_bh(&iucv_sk_list.lock);
92628
92629 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
92630 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
92631 while (__iucv_get_sock_by_name(name)) {
92632 sprintf(name, "%08x",
92633 - atomic_inc_return(&iucv_sk_list.autobind_name));
92634 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
92635 }
92636
92637 write_unlock_bh(&iucv_sk_list.lock);
92638 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
92639 index 4fe76ff..426a904 100644
92640 --- a/net/iucv/iucv.c
92641 +++ b/net/iucv/iucv.c
92642 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
92643 return NOTIFY_OK;
92644 }
92645
92646 -static struct notifier_block __refdata iucv_cpu_notifier = {
92647 +static struct notifier_block iucv_cpu_notifier = {
92648 .notifier_call = iucv_cpu_notify,
92649 };
92650
92651 diff --git a/net/key/af_key.c b/net/key/af_key.c
92652 index ab8bd2c..cd2d641 100644
92653 --- a/net/key/af_key.c
92654 +++ b/net/key/af_key.c
92655 @@ -3048,10 +3048,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
92656 static u32 get_acqseq(void)
92657 {
92658 u32 res;
92659 - static atomic_t acqseq;
92660 + static atomic_unchecked_t acqseq;
92661
92662 do {
92663 - res = atomic_inc_return(&acqseq);
92664 + res = atomic_inc_return_unchecked(&acqseq);
92665 } while (!res);
92666 return res;
92667 }
92668 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
92669 index ae36f8e..09d42ac 100644
92670 --- a/net/mac80211/cfg.c
92671 +++ b/net/mac80211/cfg.c
92672 @@ -806,7 +806,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
92673 ret = ieee80211_vif_use_channel(sdata, chandef,
92674 IEEE80211_CHANCTX_EXCLUSIVE);
92675 }
92676 - } else if (local->open_count == local->monitors) {
92677 + } else if (local_read(&local->open_count) == local->monitors) {
92678 local->_oper_chandef = *chandef;
92679 ieee80211_hw_config(local, 0);
92680 }
92681 @@ -2922,7 +2922,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
92682 else
92683 local->probe_req_reg--;
92684
92685 - if (!local->open_count)
92686 + if (!local_read(&local->open_count))
92687 break;
92688
92689 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
92690 @@ -3385,8 +3385,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
92691 if (chanctx_conf) {
92692 *chandef = chanctx_conf->def;
92693 ret = 0;
92694 - } else if (local->open_count > 0 &&
92695 - local->open_count == local->monitors &&
92696 + } else if (local_read(&local->open_count) > 0 &&
92697 + local_read(&local->open_count) == local->monitors &&
92698 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
92699 if (local->use_chanctx)
92700 *chandef = local->monitor_chandef;
92701 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
92702 index 9ca8e32..48e4a9b 100644
92703 --- a/net/mac80211/ieee80211_i.h
92704 +++ b/net/mac80211/ieee80211_i.h
92705 @@ -28,6 +28,7 @@
92706 #include <net/ieee80211_radiotap.h>
92707 #include <net/cfg80211.h>
92708 #include <net/mac80211.h>
92709 +#include <asm/local.h>
92710 #include "key.h"
92711 #include "sta_info.h"
92712 #include "debug.h"
92713 @@ -891,7 +892,7 @@ struct ieee80211_local {
92714 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
92715 spinlock_t queue_stop_reason_lock;
92716
92717 - int open_count;
92718 + local_t open_count;
92719 int monitors, cooked_mntrs;
92720 /* number of interfaces with corresponding FIF_ flags */
92721 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
92722 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
92723 index 514e90f..56f22bf 100644
92724 --- a/net/mac80211/iface.c
92725 +++ b/net/mac80211/iface.c
92726 @@ -502,7 +502,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
92727 break;
92728 }
92729
92730 - if (local->open_count == 0) {
92731 + if (local_read(&local->open_count) == 0) {
92732 res = drv_start(local);
92733 if (res)
92734 goto err_del_bss;
92735 @@ -545,7 +545,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
92736 break;
92737 }
92738
92739 - if (local->monitors == 0 && local->open_count == 0) {
92740 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
92741 res = ieee80211_add_virtual_monitor(local);
92742 if (res)
92743 goto err_stop;
92744 @@ -653,7 +653,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
92745 atomic_inc(&local->iff_promiscs);
92746
92747 if (coming_up)
92748 - local->open_count++;
92749 + local_inc(&local->open_count);
92750
92751 if (hw_reconf_flags)
92752 ieee80211_hw_config(local, hw_reconf_flags);
92753 @@ -691,7 +691,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
92754 err_del_interface:
92755 drv_remove_interface(local, sdata);
92756 err_stop:
92757 - if (!local->open_count)
92758 + if (!local_read(&local->open_count))
92759 drv_stop(local);
92760 err_del_bss:
92761 sdata->bss = NULL;
92762 @@ -828,7 +828,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
92763 }
92764
92765 if (going_down)
92766 - local->open_count--;
92767 + local_dec(&local->open_count);
92768
92769 switch (sdata->vif.type) {
92770 case NL80211_IFTYPE_AP_VLAN:
92771 @@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
92772 }
92773 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
92774
92775 - if (local->open_count == 0)
92776 + if (local_read(&local->open_count) == 0)
92777 ieee80211_clear_tx_pending(local);
92778
92779 /*
92780 @@ -931,7 +931,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
92781
92782 ieee80211_recalc_ps(local, -1);
92783
92784 - if (local->open_count == 0) {
92785 + if (local_read(&local->open_count) == 0) {
92786 ieee80211_stop_device(local);
92787
92788 /* no reconfiguring after stop! */
92789 @@ -942,7 +942,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
92790 ieee80211_configure_filter(local);
92791 ieee80211_hw_config(local, hw_reconf_flags);
92792
92793 - if (local->monitors == local->open_count)
92794 + if (local->monitors == local_read(&local->open_count))
92795 ieee80211_add_virtual_monitor(local);
92796 }
92797
92798 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
92799 index 8a7bfc4..4407cd0 100644
92800 --- a/net/mac80211/main.c
92801 +++ b/net/mac80211/main.c
92802 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
92803 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
92804 IEEE80211_CONF_CHANGE_POWER);
92805
92806 - if (changed && local->open_count) {
92807 + if (changed && local_read(&local->open_count)) {
92808 ret = drv_config(local, changed);
92809 /*
92810 * Goal:
92811 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
92812 index 3401262..d5cd68d 100644
92813 --- a/net/mac80211/pm.c
92814 +++ b/net/mac80211/pm.c
92815 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
92816 struct ieee80211_sub_if_data *sdata;
92817 struct sta_info *sta;
92818
92819 - if (!local->open_count)
92820 + if (!local_read(&local->open_count))
92821 goto suspend;
92822
92823 ieee80211_scan_cancel(local);
92824 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
92825 cancel_work_sync(&local->dynamic_ps_enable_work);
92826 del_timer_sync(&local->dynamic_ps_timer);
92827
92828 - local->wowlan = wowlan && local->open_count;
92829 + local->wowlan = wowlan && local_read(&local->open_count);
92830 if (local->wowlan) {
92831 int err = drv_suspend(local, wowlan);
92832 if (err < 0) {
92833 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
92834 WARN_ON(!list_empty(&local->chanctx_list));
92835
92836 /* stop hardware - this must stop RX */
92837 - if (local->open_count)
92838 + if (local_read(&local->open_count))
92839 ieee80211_stop_device(local);
92840
92841 suspend:
92842 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
92843 index a02bef3..f2f38dd 100644
92844 --- a/net/mac80211/rate.c
92845 +++ b/net/mac80211/rate.c
92846 @@ -712,7 +712,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
92847
92848 ASSERT_RTNL();
92849
92850 - if (local->open_count)
92851 + if (local_read(&local->open_count))
92852 return -EBUSY;
92853
92854 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
92855 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
92856 index c97a065..ff61928 100644
92857 --- a/net/mac80211/rc80211_pid_debugfs.c
92858 +++ b/net/mac80211/rc80211_pid_debugfs.c
92859 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
92860
92861 spin_unlock_irqrestore(&events->lock, status);
92862
92863 - if (copy_to_user(buf, pb, p))
92864 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
92865 return -EFAULT;
92866
92867 return p;
92868 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
92869 index 72e6292..e6319eb 100644
92870 --- a/net/mac80211/util.c
92871 +++ b/net/mac80211/util.c
92872 @@ -1472,7 +1472,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
92873 }
92874 #endif
92875 /* everything else happens only if HW was up & running */
92876 - if (!local->open_count)
92877 + if (!local_read(&local->open_count))
92878 goto wake_up;
92879
92880 /*
92881 @@ -1696,7 +1696,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
92882 local->in_reconfig = false;
92883 barrier();
92884
92885 - if (local->monitors == local->open_count && local->monitors > 0)
92886 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
92887 ieee80211_add_virtual_monitor(local);
92888
92889 /*
92890 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
92891 index 56d22ca..87c778f 100644
92892 --- a/net/netfilter/Kconfig
92893 +++ b/net/netfilter/Kconfig
92894 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
92895
92896 To compile it as a module, choose M here. If unsure, say N.
92897
92898 +config NETFILTER_XT_MATCH_GRADM
92899 + tristate '"gradm" match support'
92900 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
92901 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
92902 + ---help---
92903 + The gradm match allows to match on grsecurity RBAC being enabled.
92904 + It is useful when iptables rules are applied early on bootup to
92905 + prevent connections to the machine (except from a trusted host)
92906 + while the RBAC system is disabled.
92907 +
92908 config NETFILTER_XT_MATCH_HASHLIMIT
92909 tristate '"hashlimit" match support'
92910 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
92911 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
92912 index a1abf87..dbcb7ee 100644
92913 --- a/net/netfilter/Makefile
92914 +++ b/net/netfilter/Makefile
92915 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
92916 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
92917 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
92918 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
92919 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
92920 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
92921 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
92922 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
92923 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
92924 index f771390..145b765 100644
92925 --- a/net/netfilter/ipset/ip_set_core.c
92926 +++ b/net/netfilter/ipset/ip_set_core.c
92927 @@ -1820,7 +1820,7 @@ done:
92928 return ret;
92929 }
92930
92931 -static struct nf_sockopt_ops so_set __read_mostly = {
92932 +static struct nf_sockopt_ops so_set = {
92933 .pf = PF_INET,
92934 .get_optmin = SO_IP_SET,
92935 .get_optmax = SO_IP_SET + 1,
92936 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
92937 index a083bda..da661c3 100644
92938 --- a/net/netfilter/ipvs/ip_vs_conn.c
92939 +++ b/net/netfilter/ipvs/ip_vs_conn.c
92940 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
92941 /* Increase the refcnt counter of the dest */
92942 ip_vs_dest_hold(dest);
92943
92944 - conn_flags = atomic_read(&dest->conn_flags);
92945 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
92946 if (cp->protocol != IPPROTO_UDP)
92947 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
92948 flags = cp->flags;
92949 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
92950
92951 cp->control = NULL;
92952 atomic_set(&cp->n_control, 0);
92953 - atomic_set(&cp->in_pkts, 0);
92954 + atomic_set_unchecked(&cp->in_pkts, 0);
92955
92956 cp->packet_xmit = NULL;
92957 cp->app = NULL;
92958 @@ -1190,7 +1190,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
92959
92960 /* Don't drop the entry if its number of incoming packets is not
92961 located in [0, 8] */
92962 - i = atomic_read(&cp->in_pkts);
92963 + i = atomic_read_unchecked(&cp->in_pkts);
92964 if (i > 8 || i < 0) return 0;
92965
92966 if (!todrop_rate[i]) return 0;
92967 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
92968 index 23b8eb5..48a8959 100644
92969 --- a/net/netfilter/ipvs/ip_vs_core.c
92970 +++ b/net/netfilter/ipvs/ip_vs_core.c
92971 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
92972 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
92973 /* do not touch skb anymore */
92974
92975 - atomic_inc(&cp->in_pkts);
92976 + atomic_inc_unchecked(&cp->in_pkts);
92977 ip_vs_conn_put(cp);
92978 return ret;
92979 }
92980 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
92981 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
92982 pkts = sysctl_sync_threshold(ipvs);
92983 else
92984 - pkts = atomic_add_return(1, &cp->in_pkts);
92985 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
92986
92987 if (ipvs->sync_state & IP_VS_STATE_MASTER)
92988 ip_vs_sync_conn(net, cp, pkts);
92989 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
92990 index 9e6c2a0..28552e2 100644
92991 --- a/net/netfilter/ipvs/ip_vs_ctl.c
92992 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
92993 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
92994 */
92995 ip_vs_rs_hash(ipvs, dest);
92996 }
92997 - atomic_set(&dest->conn_flags, conn_flags);
92998 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
92999
93000 /* bind the service */
93001 if (!dest->svc) {
93002 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(ctl_table *table, int write,
93003 * align with netns init in ip_vs_control_net_init()
93004 */
93005
93006 -static struct ctl_table vs_vars[] = {
93007 +static ctl_table_no_const vs_vars[] __read_only = {
93008 {
93009 .procname = "amemthresh",
93010 .maxlen = sizeof(int),
93011 @@ -2060,7 +2060,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
93012 " %-7s %-6d %-10d %-10d\n",
93013 &dest->addr.in6,
93014 ntohs(dest->port),
93015 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
93016 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
93017 atomic_read(&dest->weight),
93018 atomic_read(&dest->activeconns),
93019 atomic_read(&dest->inactconns));
93020 @@ -2071,7 +2071,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
93021 "%-7s %-6d %-10d %-10d\n",
93022 ntohl(dest->addr.ip),
93023 ntohs(dest->port),
93024 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
93025 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
93026 atomic_read(&dest->weight),
93027 atomic_read(&dest->activeconns),
93028 atomic_read(&dest->inactconns));
93029 @@ -2549,7 +2549,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
93030
93031 entry.addr = dest->addr.ip;
93032 entry.port = dest->port;
93033 - entry.conn_flags = atomic_read(&dest->conn_flags);
93034 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
93035 entry.weight = atomic_read(&dest->weight);
93036 entry.u_threshold = dest->u_threshold;
93037 entry.l_threshold = dest->l_threshold;
93038 @@ -3092,7 +3092,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
93039 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
93040 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
93041 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
93042 - (atomic_read(&dest->conn_flags) &
93043 + (atomic_read_unchecked(&dest->conn_flags) &
93044 IP_VS_CONN_F_FWD_MASK)) ||
93045 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
93046 atomic_read(&dest->weight)) ||
93047 @@ -3682,7 +3682,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
93048 {
93049 int idx;
93050 struct netns_ipvs *ipvs = net_ipvs(net);
93051 - struct ctl_table *tbl;
93052 + ctl_table_no_const *tbl;
93053
93054 atomic_set(&ipvs->dropentry, 0);
93055 spin_lock_init(&ipvs->dropentry_lock);
93056 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
93057 index 5ea26bd..c9bc65f 100644
93058 --- a/net/netfilter/ipvs/ip_vs_lblc.c
93059 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
93060 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
93061 * IPVS LBLC sysctl table
93062 */
93063 #ifdef CONFIG_SYSCTL
93064 -static ctl_table vs_vars_table[] = {
93065 +static ctl_table_no_const vs_vars_table[] __read_only = {
93066 {
93067 .procname = "lblc_expiration",
93068 .data = NULL,
93069 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
93070 index 50123c2..067c773 100644
93071 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
93072 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
93073 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
93074 * IPVS LBLCR sysctl table
93075 */
93076
93077 -static ctl_table vs_vars_table[] = {
93078 +static ctl_table_no_const vs_vars_table[] __read_only = {
93079 {
93080 .procname = "lblcr_expiration",
93081 .data = NULL,
93082 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
93083 index f6046d9..4f10cfd 100644
93084 --- a/net/netfilter/ipvs/ip_vs_sync.c
93085 +++ b/net/netfilter/ipvs/ip_vs_sync.c
93086 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
93087 cp = cp->control;
93088 if (cp) {
93089 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
93090 - pkts = atomic_add_return(1, &cp->in_pkts);
93091 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
93092 else
93093 pkts = sysctl_sync_threshold(ipvs);
93094 ip_vs_sync_conn(net, cp->control, pkts);
93095 @@ -758,7 +758,7 @@ control:
93096 if (!cp)
93097 return;
93098 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
93099 - pkts = atomic_add_return(1, &cp->in_pkts);
93100 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
93101 else
93102 pkts = sysctl_sync_threshold(ipvs);
93103 goto sloop;
93104 @@ -882,7 +882,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
93105
93106 if (opt)
93107 memcpy(&cp->in_seq, opt, sizeof(*opt));
93108 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
93109 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
93110 cp->state = state;
93111 cp->old_state = cp->state;
93112 /*
93113 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
93114 index b75ff64..0c51bbe 100644
93115 --- a/net/netfilter/ipvs/ip_vs_xmit.c
93116 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
93117 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
93118 else
93119 rc = NF_ACCEPT;
93120 /* do not touch skb anymore */
93121 - atomic_inc(&cp->in_pkts);
93122 + atomic_inc_unchecked(&cp->in_pkts);
93123 goto out;
93124 }
93125
93126 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
93127 else
93128 rc = NF_ACCEPT;
93129 /* do not touch skb anymore */
93130 - atomic_inc(&cp->in_pkts);
93131 + atomic_inc_unchecked(&cp->in_pkts);
93132 goto out;
93133 }
93134
93135 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
93136 index 2d3030a..7ba1c0a 100644
93137 --- a/net/netfilter/nf_conntrack_acct.c
93138 +++ b/net/netfilter/nf_conntrack_acct.c
93139 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
93140 #ifdef CONFIG_SYSCTL
93141 static int nf_conntrack_acct_init_sysctl(struct net *net)
93142 {
93143 - struct ctl_table *table;
93144 + ctl_table_no_const *table;
93145
93146 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
93147 GFP_KERNEL);
93148 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
93149 index 0283bae..5febcb0 100644
93150 --- a/net/netfilter/nf_conntrack_core.c
93151 +++ b/net/netfilter/nf_conntrack_core.c
93152 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
93153 #define DYING_NULLS_VAL ((1<<30)+1)
93154 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
93155
93156 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93157 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
93158 +#endif
93159 +
93160 int nf_conntrack_init_net(struct net *net)
93161 {
93162 int ret;
93163 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
93164 goto err_stat;
93165 }
93166
93167 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93168 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
93169 +#else
93170 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
93171 +#endif
93172 if (!net->ct.slabname) {
93173 ret = -ENOMEM;
93174 goto err_slabname;
93175 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
93176 index 1df1761..ce8b88a 100644
93177 --- a/net/netfilter/nf_conntrack_ecache.c
93178 +++ b/net/netfilter/nf_conntrack_ecache.c
93179 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
93180 #ifdef CONFIG_SYSCTL
93181 static int nf_conntrack_event_init_sysctl(struct net *net)
93182 {
93183 - struct ctl_table *table;
93184 + ctl_table_no_const *table;
93185
93186 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
93187 GFP_KERNEL);
93188 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
93189 index 974a2a4..52cc6ff 100644
93190 --- a/net/netfilter/nf_conntrack_helper.c
93191 +++ b/net/netfilter/nf_conntrack_helper.c
93192 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
93193
93194 static int nf_conntrack_helper_init_sysctl(struct net *net)
93195 {
93196 - struct ctl_table *table;
93197 + ctl_table_no_const *table;
93198
93199 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
93200 GFP_KERNEL);
93201 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
93202 index 0ab9636..cea3c6a 100644
93203 --- a/net/netfilter/nf_conntrack_proto.c
93204 +++ b/net/netfilter/nf_conntrack_proto.c
93205 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
93206
93207 static void
93208 nf_ct_unregister_sysctl(struct ctl_table_header **header,
93209 - struct ctl_table **table,
93210 + ctl_table_no_const **table,
93211 unsigned int users)
93212 {
93213 if (users > 0)
93214 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
93215 index a99b6c3..3841268 100644
93216 --- a/net/netfilter/nf_conntrack_proto_dccp.c
93217 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
93218 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
93219 out_invalid:
93220 if (LOG_INVALID(net, IPPROTO_DCCP))
93221 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
93222 - NULL, msg);
93223 + NULL, "%s", msg);
93224 return false;
93225 }
93226
93227 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
93228
93229 out_invalid:
93230 if (LOG_INVALID(net, IPPROTO_DCCP))
93231 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
93232 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
93233 return -NF_ACCEPT;
93234 }
93235
93236 diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
93237 index 4d4d8f1..e0f9a32 100644
93238 --- a/net/netfilter/nf_conntrack_proto_tcp.c
93239 +++ b/net/netfilter/nf_conntrack_proto_tcp.c
93240 @@ -526,7 +526,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
93241 const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;
93242 __u32 seq, ack, sack, end, win, swin;
93243 s16 receiver_offset;
93244 - bool res;
93245 + bool res, in_recv_win;
93246
93247 /*
93248 * Get the required data from the packet.
93249 @@ -649,14 +649,18 @@ static bool tcp_in_window(const struct nf_conn *ct,
93250 receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
93251 receiver->td_scale);
93252
93253 + /* Is the ending sequence in the receive window (if available)? */
93254 + in_recv_win = !receiver->td_maxwin ||
93255 + after(end, sender->td_end - receiver->td_maxwin - 1);
93256 +
93257 pr_debug("tcp_in_window: I=%i II=%i III=%i IV=%i\n",
93258 before(seq, sender->td_maxend + 1),
93259 - after(end, sender->td_end - receiver->td_maxwin - 1),
93260 + (in_recv_win ? 1 : 0),
93261 before(sack, receiver->td_end + 1),
93262 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1));
93263
93264 if (before(seq, sender->td_maxend + 1) &&
93265 - after(end, sender->td_end - receiver->td_maxwin - 1) &&
93266 + in_recv_win &&
93267 before(sack, receiver->td_end + 1) &&
93268 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1)) {
93269 /*
93270 @@ -725,7 +729,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
93271 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
93272 "nf_ct_tcp: %s ",
93273 before(seq, sender->td_maxend + 1) ?
93274 - after(end, sender->td_end - receiver->td_maxwin - 1) ?
93275 + in_recv_win ?
93276 before(sack, receiver->td_end + 1) ?
93277 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1) ? "BUG"
93278 : "ACK is under the lower bound (possible overly delayed ACK)"
93279 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
93280 index bd700b4..4a3dc61 100644
93281 --- a/net/netfilter/nf_conntrack_standalone.c
93282 +++ b/net/netfilter/nf_conntrack_standalone.c
93283 @@ -471,7 +471,7 @@ static ctl_table nf_ct_netfilter_table[] = {
93284
93285 static int nf_conntrack_standalone_init_sysctl(struct net *net)
93286 {
93287 - struct ctl_table *table;
93288 + ctl_table_no_const *table;
93289
93290 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
93291 GFP_KERNEL);
93292 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
93293 index 902fb0a..87f7fdb 100644
93294 --- a/net/netfilter/nf_conntrack_timestamp.c
93295 +++ b/net/netfilter/nf_conntrack_timestamp.c
93296 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
93297 #ifdef CONFIG_SYSCTL
93298 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
93299 {
93300 - struct ctl_table *table;
93301 + ctl_table_no_const *table;
93302
93303 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
93304 GFP_KERNEL);
93305 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
93306 index 3b18dd1..f79e0ca 100644
93307 --- a/net/netfilter/nf_log.c
93308 +++ b/net/netfilter/nf_log.c
93309 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
93310
93311 #ifdef CONFIG_SYSCTL
93312 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
93313 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
93314 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
93315
93316 static int nf_log_proc_dostring(ctl_table *table, int write,
93317 void __user *buffer, size_t *lenp, loff_t *ppos)
93318 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
93319 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
93320 mutex_unlock(&nf_log_mutex);
93321 } else {
93322 + ctl_table_no_const nf_log_table = *table;
93323 +
93324 mutex_lock(&nf_log_mutex);
93325 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
93326 lockdep_is_held(&nf_log_mutex));
93327 if (!logger)
93328 - table->data = "NONE";
93329 + nf_log_table.data = "NONE";
93330 else
93331 - table->data = logger->name;
93332 - r = proc_dostring(table, write, buffer, lenp, ppos);
93333 + nf_log_table.data = logger->name;
93334 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
93335 mutex_unlock(&nf_log_mutex);
93336 }
93337
93338 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
93339 index f042ae5..30ea486 100644
93340 --- a/net/netfilter/nf_sockopt.c
93341 +++ b/net/netfilter/nf_sockopt.c
93342 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
93343 }
93344 }
93345
93346 - list_add(&reg->list, &nf_sockopts);
93347 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
93348 out:
93349 mutex_unlock(&nf_sockopt_mutex);
93350 return ret;
93351 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
93352 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
93353 {
93354 mutex_lock(&nf_sockopt_mutex);
93355 - list_del(&reg->list);
93356 + pax_list_del((struct list_head *)&reg->list);
93357 mutex_unlock(&nf_sockopt_mutex);
93358 }
93359 EXPORT_SYMBOL(nf_unregister_sockopt);
93360 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
93361 index 962e979..e46f350 100644
93362 --- a/net/netfilter/nfnetlink_log.c
93363 +++ b/net/netfilter/nfnetlink_log.c
93364 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
93365 struct nfnl_log_net {
93366 spinlock_t instances_lock;
93367 struct hlist_head instance_table[INSTANCE_BUCKETS];
93368 - atomic_t global_seq;
93369 + atomic_unchecked_t global_seq;
93370 };
93371
93372 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
93373 @@ -419,6 +419,7 @@ __build_packet_message(struct nfnl_log_net *log,
93374 nfmsg->version = NFNETLINK_V0;
93375 nfmsg->res_id = htons(inst->group_num);
93376
93377 + memset(&pmsg, 0, sizeof(pmsg));
93378 pmsg.hw_protocol = skb->protocol;
93379 pmsg.hook = hooknum;
93380
93381 @@ -498,7 +499,10 @@ __build_packet_message(struct nfnl_log_net *log,
93382 if (indev && skb->dev &&
93383 skb->mac_header != skb->network_header) {
93384 struct nfulnl_msg_packet_hw phw;
93385 - int len = dev_parse_header(skb, phw.hw_addr);
93386 + int len;
93387 +
93388 + memset(&phw, 0, sizeof(phw));
93389 + len = dev_parse_header(skb, phw.hw_addr);
93390 if (len > 0) {
93391 phw.hw_addrlen = htons(len);
93392 if (nla_put(inst->skb, NFULA_HWADDR, sizeof(phw), &phw))
93393 @@ -559,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
93394 /* global sequence number */
93395 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
93396 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
93397 - htonl(atomic_inc_return(&log->global_seq))))
93398 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
93399 goto nla_put_failure;
93400
93401 if (data_len) {
93402 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
93403 index 5352b2d..e0083ce 100644
93404 --- a/net/netfilter/nfnetlink_queue_core.c
93405 +++ b/net/netfilter/nfnetlink_queue_core.c
93406 @@ -444,7 +444,10 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
93407 if (indev && entskb->dev &&
93408 entskb->mac_header != entskb->network_header) {
93409 struct nfqnl_msg_packet_hw phw;
93410 - int len = dev_parse_header(entskb, phw.hw_addr);
93411 + int len;
93412 +
93413 + memset(&phw, 0, sizeof(phw));
93414 + len = dev_parse_header(entskb, phw.hw_addr);
93415 if (len) {
93416 phw.hw_addrlen = htons(len);
93417 if (nla_put(skb, NFQA_HWADDR, sizeof(phw), &phw))
93418 diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
93419 index 7011c71..6113cc7 100644
93420 --- a/net/netfilter/xt_TCPMSS.c
93421 +++ b/net/netfilter/xt_TCPMSS.c
93422 @@ -52,7 +52,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
93423 {
93424 const struct xt_tcpmss_info *info = par->targinfo;
93425 struct tcphdr *tcph;
93426 - unsigned int tcplen, i;
93427 + int len, tcp_hdrlen;
93428 + unsigned int i;
93429 __be16 oldval;
93430 u16 newmss;
93431 u8 *opt;
93432 @@ -64,11 +65,14 @@ tcpmss_mangle_packet(struct sk_buff *skb,
93433 if (!skb_make_writable(skb, skb->len))
93434 return -1;
93435
93436 - tcplen = skb->len - tcphoff;
93437 + len = skb->len - tcphoff;
93438 + if (len < (int)sizeof(struct tcphdr))
93439 + return -1;
93440 +
93441 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
93442 + tcp_hdrlen = tcph->doff * 4;
93443
93444 - /* Header cannot be larger than the packet */
93445 - if (tcplen < tcph->doff*4)
93446 + if (len < tcp_hdrlen)
93447 return -1;
93448
93449 if (info->mss == XT_TCPMSS_CLAMP_PMTU) {
93450 @@ -87,9 +91,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
93451 newmss = info->mss;
93452
93453 opt = (u_int8_t *)tcph;
93454 - for (i = sizeof(struct tcphdr); i < tcph->doff*4; i += optlen(opt, i)) {
93455 - if (opt[i] == TCPOPT_MSS && tcph->doff*4 - i >= TCPOLEN_MSS &&
93456 - opt[i+1] == TCPOLEN_MSS) {
93457 + for (i = sizeof(struct tcphdr); i <= tcp_hdrlen - TCPOLEN_MSS; i += optlen(opt, i)) {
93458 + if (opt[i] == TCPOPT_MSS && opt[i+1] == TCPOLEN_MSS) {
93459 u_int16_t oldmss;
93460
93461 oldmss = (opt[i+2] << 8) | opt[i+3];
93462 @@ -112,9 +115,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
93463 }
93464
93465 /* There is data after the header so the option can't be added
93466 - without moving it, and doing so may make the SYN packet
93467 - itself too large. Accept the packet unmodified instead. */
93468 - if (tcplen > tcph->doff*4)
93469 + * without moving it, and doing so may make the SYN packet
93470 + * itself too large. Accept the packet unmodified instead.
93471 + */
93472 + if (len > tcp_hdrlen)
93473 return 0;
93474
93475 /*
93476 @@ -143,10 +147,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
93477 newmss = min(newmss, (u16)1220);
93478
93479 opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
93480 - memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
93481 + memmove(opt + TCPOLEN_MSS, opt, len - sizeof(struct tcphdr));
93482
93483 inet_proto_csum_replace2(&tcph->check, skb,
93484 - htons(tcplen), htons(tcplen + TCPOLEN_MSS), 1);
93485 + htons(len), htons(len + TCPOLEN_MSS), 1);
93486 opt[0] = TCPOPT_MSS;
93487 opt[1] = TCPOLEN_MSS;
93488 opt[2] = (newmss & 0xff00) >> 8;
93489 diff --git a/net/netfilter/xt_TCPOPTSTRIP.c b/net/netfilter/xt_TCPOPTSTRIP.c
93490 index b68fa19..625fa1d 100644
93491 --- a/net/netfilter/xt_TCPOPTSTRIP.c
93492 +++ b/net/netfilter/xt_TCPOPTSTRIP.c
93493 @@ -38,7 +38,7 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
93494 struct tcphdr *tcph;
93495 u_int16_t n, o;
93496 u_int8_t *opt;
93497 - int len;
93498 + int len, tcp_hdrlen;
93499
93500 /* This is a fragment, no TCP header is available */
93501 if (par->fragoff != 0)
93502 @@ -52,7 +52,9 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
93503 return NF_DROP;
93504
93505 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
93506 - if (tcph->doff * 4 > len)
93507 + tcp_hdrlen = tcph->doff * 4;
93508 +
93509 + if (len < tcp_hdrlen)
93510 return NF_DROP;
93511
93512 opt = (u_int8_t *)tcph;
93513 @@ -61,10 +63,10 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
93514 * Walk through all TCP options - if we find some option to remove,
93515 * set all octets to %TCPOPT_NOP and adjust checksum.
93516 */
93517 - for (i = sizeof(struct tcphdr); i < tcp_hdrlen(skb); i += optl) {
93518 + for (i = sizeof(struct tcphdr); i < tcp_hdrlen - 1; i += optl) {
93519 optl = optlen(opt, i);
93520
93521 - if (i + optl > tcp_hdrlen(skb))
93522 + if (i + optl > tcp_hdrlen)
93523 break;
93524
93525 if (!tcpoptstrip_test_bit(info->strip_bmap, opt[i]))
93526 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
93527 new file mode 100644
93528 index 0000000..c566332
93529 --- /dev/null
93530 +++ b/net/netfilter/xt_gradm.c
93531 @@ -0,0 +1,51 @@
93532 +/*
93533 + * gradm match for netfilter
93534 + * Copyright © Zbigniew Krzystolik, 2010
93535 + *
93536 + * This program is free software; you can redistribute it and/or modify
93537 + * it under the terms of the GNU General Public License; either version
93538 + * 2 or 3 as published by the Free Software Foundation.
93539 + */
93540 +#include <linux/module.h>
93541 +#include <linux/moduleparam.h>
93542 +#include <linux/skbuff.h>
93543 +#include <linux/netfilter/x_tables.h>
93544 +#include <linux/grsecurity.h>
93545 +#include <linux/netfilter/xt_gradm.h>
93546 +
93547 +static bool
93548 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
93549 +{
93550 + const struct xt_gradm_mtinfo *info = par->matchinfo;
93551 + bool retval = false;
93552 + if (gr_acl_is_enabled())
93553 + retval = true;
93554 + return retval ^ info->invflags;
93555 +}
93556 +
93557 +static struct xt_match gradm_mt_reg __read_mostly = {
93558 + .name = "gradm",
93559 + .revision = 0,
93560 + .family = NFPROTO_UNSPEC,
93561 + .match = gradm_mt,
93562 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
93563 + .me = THIS_MODULE,
93564 +};
93565 +
93566 +static int __init gradm_mt_init(void)
93567 +{
93568 + return xt_register_match(&gradm_mt_reg);
93569 +}
93570 +
93571 +static void __exit gradm_mt_exit(void)
93572 +{
93573 + xt_unregister_match(&gradm_mt_reg);
93574 +}
93575 +
93576 +module_init(gradm_mt_init);
93577 +module_exit(gradm_mt_exit);
93578 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
93579 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
93580 +MODULE_LICENSE("GPL");
93581 +MODULE_ALIAS("ipt_gradm");
93582 +MODULE_ALIAS("ip6t_gradm");
93583 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
93584 index 4fe4fb4..87a89e5 100644
93585 --- a/net/netfilter/xt_statistic.c
93586 +++ b/net/netfilter/xt_statistic.c
93587 @@ -19,7 +19,7 @@
93588 #include <linux/module.h>
93589
93590 struct xt_statistic_priv {
93591 - atomic_t count;
93592 + atomic_unchecked_t count;
93593 } ____cacheline_aligned_in_smp;
93594
93595 MODULE_LICENSE("GPL");
93596 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
93597 break;
93598 case XT_STATISTIC_MODE_NTH:
93599 do {
93600 - oval = atomic_read(&info->master->count);
93601 + oval = atomic_read_unchecked(&info->master->count);
93602 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
93603 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
93604 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
93605 if (nval == 0)
93606 ret = !ret;
93607 break;
93608 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
93609 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
93610 if (info->master == NULL)
93611 return -ENOMEM;
93612 - atomic_set(&info->master->count, info->u.nth.count);
93613 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
93614
93615 return 0;
93616 }
93617 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
93618 index 57ee84d..8b99cf5 100644
93619 --- a/net/netlink/af_netlink.c
93620 +++ b/net/netlink/af_netlink.c
93621 @@ -121,7 +121,7 @@ static void netlink_overrun(struct sock *sk)
93622 sk->sk_error_report(sk);
93623 }
93624 }
93625 - atomic_inc(&sk->sk_drops);
93626 + atomic_inc_unchecked(&sk->sk_drops);
93627 }
93628
93629 static void netlink_rcv_wake(struct sock *sk)
93630 @@ -2771,7 +2771,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
93631 sk_wmem_alloc_get(s),
93632 nlk->cb,
93633 atomic_read(&s->sk_refcnt),
93634 - atomic_read(&s->sk_drops),
93635 + atomic_read_unchecked(&s->sk_drops),
93636 sock_i_ino(s)
93637 );
93638
93639 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
93640 index 1076fe1..8285fd7 100644
93641 --- a/net/netlink/genetlink.c
93642 +++ b/net/netlink/genetlink.c
93643 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
93644 goto errout;
93645 }
93646
93647 + pax_open_kernel();
93648 if (ops->dumpit)
93649 - ops->flags |= GENL_CMD_CAP_DUMP;
93650 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
93651 if (ops->doit)
93652 - ops->flags |= GENL_CMD_CAP_DO;
93653 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
93654 if (ops->policy)
93655 - ops->flags |= GENL_CMD_CAP_HASPOL;
93656 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
93657 + pax_close_kernel();
93658
93659 genl_lock_all();
93660 - list_add_tail(&ops->ops_list, &family->ops_list);
93661 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
93662 genl_unlock_all();
93663
93664 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
93665 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
93666 err = 0;
93667 errout:
93668 return err;
93669 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
93670 genl_lock_all();
93671 list_for_each_entry(rc, &family->ops_list, ops_list) {
93672 if (rc == ops) {
93673 - list_del(&ops->ops_list);
93674 + pax_list_del((struct list_head *)&ops->ops_list);
93675 genl_unlock_all();
93676 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
93677 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
93678 return 0;
93679 }
93680 }
93681 @@ -789,6 +791,10 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb)
93682 struct net *net = sock_net(skb->sk);
93683 int chains_to_skip = cb->args[0];
93684 int fams_to_skip = cb->args[1];
93685 + bool need_locking = chains_to_skip || fams_to_skip;
93686 +
93687 + if (need_locking)
93688 + genl_lock();
93689
93690 for (i = chains_to_skip; i < GENL_FAM_TAB_SIZE; i++) {
93691 n = 0;
93692 @@ -810,6 +816,9 @@ errout:
93693 cb->args[0] = i;
93694 cb->args[1] = n;
93695
93696 + if (need_locking)
93697 + genl_unlock();
93698 +
93699 return skb->len;
93700 }
93701
93702 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
93703 index ec0c80f..41e1830 100644
93704 --- a/net/netrom/af_netrom.c
93705 +++ b/net/netrom/af_netrom.c
93706 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
93707 *uaddr_len = sizeof(struct full_sockaddr_ax25);
93708 } else {
93709 sax->fsa_ax25.sax25_family = AF_NETROM;
93710 - sax->fsa_ax25.sax25_ndigis = 0;
93711 sax->fsa_ax25.sax25_call = nr->source_addr;
93712 *uaddr_len = sizeof(struct sockaddr_ax25);
93713 }
93714 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
93715 index 20a1bd0..bb8f1c1 100644
93716 --- a/net/packet/af_packet.c
93717 +++ b/net/packet/af_packet.c
93718 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
93719
93720 spin_lock(&sk->sk_receive_queue.lock);
93721 po->stats.stats1.tp_packets++;
93722 - skb->dropcount = atomic_read(&sk->sk_drops);
93723 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
93724 __skb_queue_tail(&sk->sk_receive_queue, skb);
93725 spin_unlock(&sk->sk_receive_queue.lock);
93726 sk->sk_data_ready(sk, skb->len);
93727 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
93728 drop_n_acct:
93729 spin_lock(&sk->sk_receive_queue.lock);
93730 po->stats.stats1.tp_drops++;
93731 - atomic_inc(&sk->sk_drops);
93732 + atomic_inc_unchecked(&sk->sk_drops);
93733 spin_unlock(&sk->sk_receive_queue.lock);
93734
93735 drop_n_restore:
93736 @@ -2640,6 +2640,7 @@ out:
93737
93738 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
93739 {
93740 + struct sock_extended_err ee;
93741 struct sock_exterr_skb *serr;
93742 struct sk_buff *skb, *skb2;
93743 int copied, err;
93744 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
93745 sock_recv_timestamp(msg, sk, skb);
93746
93747 serr = SKB_EXT_ERR(skb);
93748 + ee = serr->ee;
93749 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
93750 - sizeof(serr->ee), &serr->ee);
93751 + sizeof ee, &ee);
93752
93753 msg->msg_flags |= MSG_ERRQUEUE;
93754 err = copied;
93755 @@ -3281,7 +3283,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
93756 case PACKET_HDRLEN:
93757 if (len > sizeof(int))
93758 len = sizeof(int);
93759 - if (copy_from_user(&val, optval, len))
93760 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
93761 return -EFAULT;
93762 switch (val) {
93763 case TPACKET_V1:
93764 @@ -3324,7 +3326,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
93765 len = lv;
93766 if (put_user(len, optlen))
93767 return -EFAULT;
93768 - if (copy_to_user(optval, data, len))
93769 + if (len > sizeof(st) || copy_to_user(optval, data, len))
93770 return -EFAULT;
93771 return 0;
93772 }
93773 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
93774 index 5a940db..d6a502d 100644
93775 --- a/net/phonet/af_phonet.c
93776 +++ b/net/phonet/af_phonet.c
93777 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
93778 {
93779 int err = 0;
93780
93781 - if (protocol >= PHONET_NPROTO)
93782 + if (protocol < 0 || protocol >= PHONET_NPROTO)
93783 return -EINVAL;
93784
93785 err = proto_register(pp->prot, 1);
93786 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
93787 index e774117..900b8b7 100644
93788 --- a/net/phonet/pep.c
93789 +++ b/net/phonet/pep.c
93790 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
93791
93792 case PNS_PEP_CTRL_REQ:
93793 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
93794 - atomic_inc(&sk->sk_drops);
93795 + atomic_inc_unchecked(&sk->sk_drops);
93796 break;
93797 }
93798 __skb_pull(skb, 4);
93799 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
93800 }
93801
93802 if (pn->rx_credits == 0) {
93803 - atomic_inc(&sk->sk_drops);
93804 + atomic_inc_unchecked(&sk->sk_drops);
93805 err = -ENOBUFS;
93806 break;
93807 }
93808 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
93809 }
93810
93811 if (pn->rx_credits == 0) {
93812 - atomic_inc(&sk->sk_drops);
93813 + atomic_inc_unchecked(&sk->sk_drops);
93814 err = NET_RX_DROP;
93815 break;
93816 }
93817 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
93818 index 1afd138..0b42453 100644
93819 --- a/net/phonet/socket.c
93820 +++ b/net/phonet/socket.c
93821 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
93822 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
93823 sock_i_ino(sk),
93824 atomic_read(&sk->sk_refcnt), sk,
93825 - atomic_read(&sk->sk_drops), &len);
93826 + atomic_read_unchecked(&sk->sk_drops), &len);
93827 }
93828 seq_printf(seq, "%*s\n", 127 - len, "");
93829 return 0;
93830 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
93831 index d6bbbbd..61561e4 100644
93832 --- a/net/phonet/sysctl.c
93833 +++ b/net/phonet/sysctl.c
93834 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
93835 {
93836 int ret;
93837 int range[2] = {local_port_range[0], local_port_range[1]};
93838 - ctl_table tmp = {
93839 + ctl_table_no_const tmp = {
93840 .data = &range,
93841 .maxlen = sizeof(range),
93842 .mode = table->mode,
93843 diff --git a/net/rds/cong.c b/net/rds/cong.c
93844 index e5b65ac..f3b6fb7 100644
93845 --- a/net/rds/cong.c
93846 +++ b/net/rds/cong.c
93847 @@ -78,7 +78,7 @@
93848 * finds that the saved generation number is smaller than the global generation
93849 * number, it wakes up the process.
93850 */
93851 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
93852 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
93853
93854 /*
93855 * Congestion monitoring
93856 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
93857 rdsdebug("waking map %p for %pI4\n",
93858 map, &map->m_addr);
93859 rds_stats_inc(s_cong_update_received);
93860 - atomic_inc(&rds_cong_generation);
93861 + atomic_inc_unchecked(&rds_cong_generation);
93862 if (waitqueue_active(&map->m_waitq))
93863 wake_up(&map->m_waitq);
93864 if (waitqueue_active(&rds_poll_waitq))
93865 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
93866
93867 int rds_cong_updated_since(unsigned long *recent)
93868 {
93869 - unsigned long gen = atomic_read(&rds_cong_generation);
93870 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
93871
93872 if (likely(*recent == gen))
93873 return 0;
93874 diff --git a/net/rds/ib.h b/net/rds/ib.h
93875 index 7280ab8..e04f4ea 100644
93876 --- a/net/rds/ib.h
93877 +++ b/net/rds/ib.h
93878 @@ -128,7 +128,7 @@ struct rds_ib_connection {
93879 /* sending acks */
93880 unsigned long i_ack_flags;
93881 #ifdef KERNEL_HAS_ATOMIC64
93882 - atomic64_t i_ack_next; /* next ACK to send */
93883 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
93884 #else
93885 spinlock_t i_ack_lock; /* protect i_ack_next */
93886 u64 i_ack_next; /* next ACK to send */
93887 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
93888 index 31b74f5..dc1fbfa 100644
93889 --- a/net/rds/ib_cm.c
93890 +++ b/net/rds/ib_cm.c
93891 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
93892 /* Clear the ACK state */
93893 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
93894 #ifdef KERNEL_HAS_ATOMIC64
93895 - atomic64_set(&ic->i_ack_next, 0);
93896 + atomic64_set_unchecked(&ic->i_ack_next, 0);
93897 #else
93898 ic->i_ack_next = 0;
93899 #endif
93900 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
93901 index 8eb9501..0c386ff 100644
93902 --- a/net/rds/ib_recv.c
93903 +++ b/net/rds/ib_recv.c
93904 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
93905 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
93906 int ack_required)
93907 {
93908 - atomic64_set(&ic->i_ack_next, seq);
93909 + atomic64_set_unchecked(&ic->i_ack_next, seq);
93910 if (ack_required) {
93911 smp_mb__before_clear_bit();
93912 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
93913 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
93914 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
93915 smp_mb__after_clear_bit();
93916
93917 - return atomic64_read(&ic->i_ack_next);
93918 + return atomic64_read_unchecked(&ic->i_ack_next);
93919 }
93920 #endif
93921
93922 diff --git a/net/rds/iw.h b/net/rds/iw.h
93923 index 04ce3b1..48119a6 100644
93924 --- a/net/rds/iw.h
93925 +++ b/net/rds/iw.h
93926 @@ -134,7 +134,7 @@ struct rds_iw_connection {
93927 /* sending acks */
93928 unsigned long i_ack_flags;
93929 #ifdef KERNEL_HAS_ATOMIC64
93930 - atomic64_t i_ack_next; /* next ACK to send */
93931 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
93932 #else
93933 spinlock_t i_ack_lock; /* protect i_ack_next */
93934 u64 i_ack_next; /* next ACK to send */
93935 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
93936 index a91e1db..cf3053f 100644
93937 --- a/net/rds/iw_cm.c
93938 +++ b/net/rds/iw_cm.c
93939 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
93940 /* Clear the ACK state */
93941 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
93942 #ifdef KERNEL_HAS_ATOMIC64
93943 - atomic64_set(&ic->i_ack_next, 0);
93944 + atomic64_set_unchecked(&ic->i_ack_next, 0);
93945 #else
93946 ic->i_ack_next = 0;
93947 #endif
93948 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
93949 index 4503335..db566b4 100644
93950 --- a/net/rds/iw_recv.c
93951 +++ b/net/rds/iw_recv.c
93952 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
93953 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
93954 int ack_required)
93955 {
93956 - atomic64_set(&ic->i_ack_next, seq);
93957 + atomic64_set_unchecked(&ic->i_ack_next, seq);
93958 if (ack_required) {
93959 smp_mb__before_clear_bit();
93960 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
93961 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
93962 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
93963 smp_mb__after_clear_bit();
93964
93965 - return atomic64_read(&ic->i_ack_next);
93966 + return atomic64_read_unchecked(&ic->i_ack_next);
93967 }
93968 #endif
93969
93970 diff --git a/net/rds/rds.h b/net/rds/rds.h
93971 index ec1d731..90a3a8d 100644
93972 --- a/net/rds/rds.h
93973 +++ b/net/rds/rds.h
93974 @@ -449,7 +449,7 @@ struct rds_transport {
93975 void (*sync_mr)(void *trans_private, int direction);
93976 void (*free_mr)(void *trans_private, int invalidate);
93977 void (*flush_mrs)(void);
93978 -};
93979 +} __do_const;
93980
93981 struct rds_sock {
93982 struct sock rs_sk;
93983 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
93984 index edac9ef..16bcb98 100644
93985 --- a/net/rds/tcp.c
93986 +++ b/net/rds/tcp.c
93987 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
93988 int val = 1;
93989
93990 set_fs(KERNEL_DS);
93991 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
93992 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
93993 sizeof(val));
93994 set_fs(oldfs);
93995 }
93996 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
93997 index 81cf5a4..b5826ff 100644
93998 --- a/net/rds/tcp_send.c
93999 +++ b/net/rds/tcp_send.c
94000 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
94001
94002 oldfs = get_fs();
94003 set_fs(KERNEL_DS);
94004 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
94005 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
94006 sizeof(val));
94007 set_fs(oldfs);
94008 }
94009 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
94010 index e61aa60..f07cc89 100644
94011 --- a/net/rxrpc/af_rxrpc.c
94012 +++ b/net/rxrpc/af_rxrpc.c
94013 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
94014 __be32 rxrpc_epoch;
94015
94016 /* current debugging ID */
94017 -atomic_t rxrpc_debug_id;
94018 +atomic_unchecked_t rxrpc_debug_id;
94019
94020 /* count of skbs currently in use */
94021 atomic_t rxrpc_n_skbs;
94022 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
94023 index e4d9cbc..b229649 100644
94024 --- a/net/rxrpc/ar-ack.c
94025 +++ b/net/rxrpc/ar-ack.c
94026 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
94027
94028 _enter("{%d,%d,%d,%d},",
94029 call->acks_hard, call->acks_unacked,
94030 - atomic_read(&call->sequence),
94031 + atomic_read_unchecked(&call->sequence),
94032 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
94033
94034 stop = 0;
94035 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
94036
94037 /* each Tx packet has a new serial number */
94038 sp->hdr.serial =
94039 - htonl(atomic_inc_return(&call->conn->serial));
94040 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
94041
94042 hdr = (struct rxrpc_header *) txb->head;
94043 hdr->serial = sp->hdr.serial;
94044 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
94045 */
94046 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
94047 {
94048 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
94049 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
94050 }
94051
94052 /*
94053 @@ -629,7 +629,7 @@ process_further:
94054
94055 latest = ntohl(sp->hdr.serial);
94056 hard = ntohl(ack.firstPacket);
94057 - tx = atomic_read(&call->sequence);
94058 + tx = atomic_read_unchecked(&call->sequence);
94059
94060 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
94061 latest,
94062 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
94063 goto maybe_reschedule;
94064
94065 send_ACK_with_skew:
94066 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
94067 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
94068 ntohl(ack.serial));
94069 send_ACK:
94070 mtu = call->conn->trans->peer->if_mtu;
94071 @@ -1173,7 +1173,7 @@ send_ACK:
94072 ackinfo.rxMTU = htonl(5692);
94073 ackinfo.jumbo_max = htonl(4);
94074
94075 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
94076 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
94077 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
94078 ntohl(hdr.serial),
94079 ntohs(ack.maxSkew),
94080 @@ -1191,7 +1191,7 @@ send_ACK:
94081 send_message:
94082 _debug("send message");
94083
94084 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
94085 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
94086 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
94087 send_message_2:
94088
94089 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
94090 index a3bbb36..3341fb9 100644
94091 --- a/net/rxrpc/ar-call.c
94092 +++ b/net/rxrpc/ar-call.c
94093 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
94094 spin_lock_init(&call->lock);
94095 rwlock_init(&call->state_lock);
94096 atomic_set(&call->usage, 1);
94097 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
94098 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
94099 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
94100
94101 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
94102 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
94103 index 4106ca9..a338d7a 100644
94104 --- a/net/rxrpc/ar-connection.c
94105 +++ b/net/rxrpc/ar-connection.c
94106 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
94107 rwlock_init(&conn->lock);
94108 spin_lock_init(&conn->state_lock);
94109 atomic_set(&conn->usage, 1);
94110 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
94111 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
94112 conn->avail_calls = RXRPC_MAXCALLS;
94113 conn->size_align = 4;
94114 conn->header_size = sizeof(struct rxrpc_header);
94115 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
94116 index e7ed43a..6afa140 100644
94117 --- a/net/rxrpc/ar-connevent.c
94118 +++ b/net/rxrpc/ar-connevent.c
94119 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
94120
94121 len = iov[0].iov_len + iov[1].iov_len;
94122
94123 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
94124 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
94125 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
94126
94127 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
94128 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
94129 index 529572f..c758ca7 100644
94130 --- a/net/rxrpc/ar-input.c
94131 +++ b/net/rxrpc/ar-input.c
94132 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
94133 /* track the latest serial number on this connection for ACK packet
94134 * information */
94135 serial = ntohl(sp->hdr.serial);
94136 - hi_serial = atomic_read(&call->conn->hi_serial);
94137 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
94138 while (serial > hi_serial)
94139 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
94140 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
94141 serial);
94142
94143 /* request ACK generation for any ACK or DATA packet that requests
94144 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
94145 index a693aca..81e7293 100644
94146 --- a/net/rxrpc/ar-internal.h
94147 +++ b/net/rxrpc/ar-internal.h
94148 @@ -272,8 +272,8 @@ struct rxrpc_connection {
94149 int error; /* error code for local abort */
94150 int debug_id; /* debug ID for printks */
94151 unsigned int call_counter; /* call ID counter */
94152 - atomic_t serial; /* packet serial number counter */
94153 - atomic_t hi_serial; /* highest serial number received */
94154 + atomic_unchecked_t serial; /* packet serial number counter */
94155 + atomic_unchecked_t hi_serial; /* highest serial number received */
94156 u8 avail_calls; /* number of calls available */
94157 u8 size_align; /* data size alignment (for security) */
94158 u8 header_size; /* rxrpc + security header size */
94159 @@ -346,7 +346,7 @@ struct rxrpc_call {
94160 spinlock_t lock;
94161 rwlock_t state_lock; /* lock for state transition */
94162 atomic_t usage;
94163 - atomic_t sequence; /* Tx data packet sequence counter */
94164 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
94165 u32 abort_code; /* local/remote abort code */
94166 enum { /* current state of call */
94167 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
94168 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
94169 */
94170 extern atomic_t rxrpc_n_skbs;
94171 extern __be32 rxrpc_epoch;
94172 -extern atomic_t rxrpc_debug_id;
94173 +extern atomic_unchecked_t rxrpc_debug_id;
94174 extern struct workqueue_struct *rxrpc_workqueue;
94175
94176 /*
94177 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
94178 index 87f7135..74d3703 100644
94179 --- a/net/rxrpc/ar-local.c
94180 +++ b/net/rxrpc/ar-local.c
94181 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
94182 spin_lock_init(&local->lock);
94183 rwlock_init(&local->services_lock);
94184 atomic_set(&local->usage, 1);
94185 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
94186 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
94187 memcpy(&local->srx, srx, sizeof(*srx));
94188 }
94189
94190 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
94191 index e1ac183..b43e10e 100644
94192 --- a/net/rxrpc/ar-output.c
94193 +++ b/net/rxrpc/ar-output.c
94194 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
94195 sp->hdr.cid = call->cid;
94196 sp->hdr.callNumber = call->call_id;
94197 sp->hdr.seq =
94198 - htonl(atomic_inc_return(&call->sequence));
94199 + htonl(atomic_inc_return_unchecked(&call->sequence));
94200 sp->hdr.serial =
94201 - htonl(atomic_inc_return(&conn->serial));
94202 + htonl(atomic_inc_return_unchecked(&conn->serial));
94203 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
94204 sp->hdr.userStatus = 0;
94205 sp->hdr.securityIndex = conn->security_ix;
94206 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
94207 index bebaa43..2644591 100644
94208 --- a/net/rxrpc/ar-peer.c
94209 +++ b/net/rxrpc/ar-peer.c
94210 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
94211 INIT_LIST_HEAD(&peer->error_targets);
94212 spin_lock_init(&peer->lock);
94213 atomic_set(&peer->usage, 1);
94214 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
94215 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
94216 memcpy(&peer->srx, srx, sizeof(*srx));
94217
94218 rxrpc_assess_MTU_size(peer);
94219 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
94220 index 38047f7..9f48511 100644
94221 --- a/net/rxrpc/ar-proc.c
94222 +++ b/net/rxrpc/ar-proc.c
94223 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
94224 atomic_read(&conn->usage),
94225 rxrpc_conn_states[conn->state],
94226 key_serial(conn->key),
94227 - atomic_read(&conn->serial),
94228 - atomic_read(&conn->hi_serial));
94229 + atomic_read_unchecked(&conn->serial),
94230 + atomic_read_unchecked(&conn->hi_serial));
94231
94232 return 0;
94233 }
94234 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
94235 index 92df566..87ec1bf 100644
94236 --- a/net/rxrpc/ar-transport.c
94237 +++ b/net/rxrpc/ar-transport.c
94238 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
94239 spin_lock_init(&trans->client_lock);
94240 rwlock_init(&trans->conn_lock);
94241 atomic_set(&trans->usage, 1);
94242 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
94243 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
94244
94245 if (peer->srx.transport.family == AF_INET) {
94246 switch (peer->srx.transport_type) {
94247 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
94248 index f226709..0e735a8 100644
94249 --- a/net/rxrpc/rxkad.c
94250 +++ b/net/rxrpc/rxkad.c
94251 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
94252
94253 len = iov[0].iov_len + iov[1].iov_len;
94254
94255 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
94256 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
94257 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
94258
94259 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
94260 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
94261
94262 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
94263
94264 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
94265 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
94266 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
94267
94268 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
94269 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
94270 index 391a245..296b3d7 100644
94271 --- a/net/sctp/ipv6.c
94272 +++ b/net/sctp/ipv6.c
94273 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
94274 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
94275 };
94276
94277 -static struct sctp_af sctp_af_inet6 = {
94278 +static struct sctp_af sctp_af_inet6 __read_only = {
94279 .sa_family = AF_INET6,
94280 .sctp_xmit = sctp_v6_xmit,
94281 .setsockopt = ipv6_setsockopt,
94282 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
94283 #endif
94284 };
94285
94286 -static struct sctp_pf sctp_pf_inet6 = {
94287 +static struct sctp_pf sctp_pf_inet6 __read_only = {
94288 .event_msgname = sctp_inet6_event_msgname,
94289 .skb_msgname = sctp_inet6_skb_msgname,
94290 .af_supported = sctp_inet6_af_supported,
94291 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
94292
94293 void sctp_v6_pf_exit(void)
94294 {
94295 - list_del(&sctp_af_inet6.list);
94296 + pax_list_del(&sctp_af_inet6.list);
94297 }
94298
94299 /* Initialize IPv6 support and register with socket layer. */
94300 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
94301 index 4e45ee3..e66a031 100644
94302 --- a/net/sctp/proc.c
94303 +++ b/net/sctp/proc.c
94304 @@ -337,7 +337,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
94305 seq_printf(seq,
94306 "%8pK %8pK %-3d %-3d %-2d %-4d "
94307 "%4d %8d %8d %7d %5lu %-5d %5d ",
94308 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
94309 + assoc, sk,
94310 + sctp_sk(sk)->type, sk->sk_state,
94311 assoc->state, hash,
94312 assoc->assoc_id,
94313 assoc->sndbuf_used,
94314 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
94315 index eaee00c..97c0afd 100644
94316 --- a/net/sctp/protocol.c
94317 +++ b/net/sctp/protocol.c
94318 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
94319 return 0;
94320 }
94321
94322 + pax_open_kernel();
94323 INIT_LIST_HEAD(&af->list);
94324 - list_add_tail(&af->list, &sctp_address_families);
94325 + pax_close_kernel();
94326 + pax_list_add_tail(&af->list, &sctp_address_families);
94327 return 1;
94328 }
94329
94330 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
94331
94332 static struct sctp_af sctp_af_inet;
94333
94334 -static struct sctp_pf sctp_pf_inet = {
94335 +static struct sctp_pf sctp_pf_inet __read_only = {
94336 .event_msgname = sctp_inet_event_msgname,
94337 .skb_msgname = sctp_inet_skb_msgname,
94338 .af_supported = sctp_inet_af_supported,
94339 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
94340 };
94341
94342 /* IPv4 address related functions. */
94343 -static struct sctp_af sctp_af_inet = {
94344 +static struct sctp_af sctp_af_inet __read_only = {
94345 .sa_family = AF_INET,
94346 .sctp_xmit = sctp_v4_xmit,
94347 .setsockopt = ip_setsockopt,
94348 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
94349
94350 static void sctp_v4_pf_exit(void)
94351 {
94352 - list_del(&sctp_af_inet.list);
94353 + pax_list_del(&sctp_af_inet.list);
94354 }
94355
94356 static int sctp_v4_protosw_init(void)
94357 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
94358 index 8aab894..f6b7e7d 100644
94359 --- a/net/sctp/sm_sideeffect.c
94360 +++ b/net/sctp/sm_sideeffect.c
94361 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
94362 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
94363 }
94364
94365 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
94366 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
94367 NULL,
94368 sctp_generate_t1_cookie_event,
94369 sctp_generate_t1_init_event,
94370 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
94371 index 6abb1ca..1678f8b 100644
94372 --- a/net/sctp/socket.c
94373 +++ b/net/sctp/socket.c
94374 @@ -2167,11 +2167,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
94375 {
94376 struct sctp_association *asoc;
94377 struct sctp_ulpevent *event;
94378 + struct sctp_event_subscribe subscribe;
94379
94380 if (optlen > sizeof(struct sctp_event_subscribe))
94381 return -EINVAL;
94382 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
94383 + if (copy_from_user(&subscribe, optval, optlen))
94384 return -EFAULT;
94385 + sctp_sk(sk)->subscribe = subscribe;
94386
94387 /*
94388 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
94389 @@ -4222,13 +4224,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
94390 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
94391 int __user *optlen)
94392 {
94393 + struct sctp_event_subscribe subscribe;
94394 +
94395 if (len <= 0)
94396 return -EINVAL;
94397 if (len > sizeof(struct sctp_event_subscribe))
94398 len = sizeof(struct sctp_event_subscribe);
94399 if (put_user(len, optlen))
94400 return -EFAULT;
94401 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
94402 + subscribe = sctp_sk(sk)->subscribe;
94403 + if (copy_to_user(optval, &subscribe, len))
94404 return -EFAULT;
94405 return 0;
94406 }
94407 @@ -4246,6 +4251,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
94408 */
94409 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
94410 {
94411 + __u32 autoclose;
94412 +
94413 /* Applicable to UDP-style socket only */
94414 if (sctp_style(sk, TCP))
94415 return -EOPNOTSUPP;
94416 @@ -4254,7 +4261,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
94417 len = sizeof(int);
94418 if (put_user(len, optlen))
94419 return -EFAULT;
94420 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
94421 + autoclose = sctp_sk(sk)->autoclose;
94422 + if (copy_to_user(optval, &autoclose, sizeof(int)))
94423 return -EFAULT;
94424 return 0;
94425 }
94426 @@ -4626,12 +4634,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
94427 */
94428 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
94429 {
94430 + struct sctp_initmsg initmsg;
94431 +
94432 if (len < sizeof(struct sctp_initmsg))
94433 return -EINVAL;
94434 len = sizeof(struct sctp_initmsg);
94435 if (put_user(len, optlen))
94436 return -EFAULT;
94437 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
94438 + initmsg = sctp_sk(sk)->initmsg;
94439 + if (copy_to_user(optval, &initmsg, len))
94440 return -EFAULT;
94441 return 0;
94442 }
94443 @@ -4672,6 +4683,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
94444 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
94445 if (space_left < addrlen)
94446 return -ENOMEM;
94447 + if (addrlen > sizeof(temp) || addrlen < 0)
94448 + return -EFAULT;
94449 if (copy_to_user(to, &temp, addrlen))
94450 return -EFAULT;
94451 to += addrlen;
94452 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
94453 index bf3c6e8..376d8d0 100644
94454 --- a/net/sctp/sysctl.c
94455 +++ b/net/sctp/sysctl.c
94456 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
94457 {
94458 struct net *net = current->nsproxy->net_ns;
94459 char tmp[8];
94460 - ctl_table tbl;
94461 + ctl_table_no_const tbl;
94462 int ret;
94463 int changed = 0;
94464 char *none = "none";
94465 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
94466
94467 int sctp_sysctl_net_register(struct net *net)
94468 {
94469 - struct ctl_table *table;
94470 + ctl_table_no_const *table;
94471 int i;
94472
94473 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
94474 diff --git a/net/sctp/transport.c b/net/sctp/transport.c
94475 index 098f1d5f..60da2f7 100644
94476 --- a/net/sctp/transport.c
94477 +++ b/net/sctp/transport.c
94478 @@ -178,12 +178,12 @@ static void sctp_transport_destroy(struct sctp_transport *transport)
94479 {
94480 SCTP_ASSERT(transport->dead, "Transport is not dead", return);
94481
94482 - call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
94483 -
94484 sctp_packet_free(&transport->packet);
94485
94486 if (transport->asoc)
94487 sctp_association_put(transport->asoc);
94488 +
94489 + call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
94490 }
94491
94492 /* Start T3_rtx timer if it is not already running and update the heartbeat
94493 diff --git a/net/socket.c b/net/socket.c
94494 index 4ca1526..df83e47 100644
94495 --- a/net/socket.c
94496 +++ b/net/socket.c
94497 @@ -88,6 +88,7 @@
94498 #include <linux/magic.h>
94499 #include <linux/slab.h>
94500 #include <linux/xattr.h>
94501 +#include <linux/in.h>
94502
94503 #include <asm/uaccess.h>
94504 #include <asm/unistd.h>
94505 @@ -105,6 +106,8 @@
94506 #include <linux/sockios.h>
94507 #include <linux/atalk.h>
94508
94509 +#include <linux/grsock.h>
94510 +
94511 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
94512 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
94513 unsigned long nr_segs, loff_t pos);
94514 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
94515 &sockfs_dentry_operations, SOCKFS_MAGIC);
94516 }
94517
94518 -static struct vfsmount *sock_mnt __read_mostly;
94519 +struct vfsmount *sock_mnt __read_mostly;
94520
94521 static struct file_system_type sock_fs_type = {
94522 .name = "sockfs",
94523 @@ -1246,6 +1249,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
94524 return -EAFNOSUPPORT;
94525 if (type < 0 || type >= SOCK_MAX)
94526 return -EINVAL;
94527 + if (protocol < 0)
94528 + return -EINVAL;
94529
94530 /* Compatibility.
94531
94532 @@ -1377,6 +1382,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
94533 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
94534 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
94535
94536 + if(!gr_search_socket(family, type, protocol)) {
94537 + retval = -EACCES;
94538 + goto out;
94539 + }
94540 +
94541 + if (gr_handle_sock_all(family, type, protocol)) {
94542 + retval = -EACCES;
94543 + goto out;
94544 + }
94545 +
94546 retval = sock_create(family, type, protocol, &sock);
94547 if (retval < 0)
94548 goto out;
94549 @@ -1504,6 +1519,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
94550 if (sock) {
94551 err = move_addr_to_kernel(umyaddr, addrlen, &address);
94552 if (err >= 0) {
94553 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
94554 + err = -EACCES;
94555 + goto error;
94556 + }
94557 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
94558 + if (err)
94559 + goto error;
94560 +
94561 err = security_socket_bind(sock,
94562 (struct sockaddr *)&address,
94563 addrlen);
94564 @@ -1512,6 +1535,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
94565 (struct sockaddr *)
94566 &address, addrlen);
94567 }
94568 +error:
94569 fput_light(sock->file, fput_needed);
94570 }
94571 return err;
94572 @@ -1535,10 +1559,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
94573 if ((unsigned int)backlog > somaxconn)
94574 backlog = somaxconn;
94575
94576 + if (gr_handle_sock_server_other(sock->sk)) {
94577 + err = -EPERM;
94578 + goto error;
94579 + }
94580 +
94581 + err = gr_search_listen(sock);
94582 + if (err)
94583 + goto error;
94584 +
94585 err = security_socket_listen(sock, backlog);
94586 if (!err)
94587 err = sock->ops->listen(sock, backlog);
94588
94589 +error:
94590 fput_light(sock->file, fput_needed);
94591 }
94592 return err;
94593 @@ -1582,6 +1616,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
94594 newsock->type = sock->type;
94595 newsock->ops = sock->ops;
94596
94597 + if (gr_handle_sock_server_other(sock->sk)) {
94598 + err = -EPERM;
94599 + sock_release(newsock);
94600 + goto out_put;
94601 + }
94602 +
94603 + err = gr_search_accept(sock);
94604 + if (err) {
94605 + sock_release(newsock);
94606 + goto out_put;
94607 + }
94608 +
94609 /*
94610 * We don't need try_module_get here, as the listening socket (sock)
94611 * has the protocol module (sock->ops->owner) held.
94612 @@ -1627,6 +1673,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
94613 fd_install(newfd, newfile);
94614 err = newfd;
94615
94616 + gr_attach_curr_ip(newsock->sk);
94617 +
94618 out_put:
94619 fput_light(sock->file, fput_needed);
94620 out:
94621 @@ -1659,6 +1707,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
94622 int, addrlen)
94623 {
94624 struct socket *sock;
94625 + struct sockaddr *sck;
94626 struct sockaddr_storage address;
94627 int err, fput_needed;
94628
94629 @@ -1669,6 +1718,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
94630 if (err < 0)
94631 goto out_put;
94632
94633 + sck = (struct sockaddr *)&address;
94634 +
94635 + if (gr_handle_sock_client(sck)) {
94636 + err = -EACCES;
94637 + goto out_put;
94638 + }
94639 +
94640 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
94641 + if (err)
94642 + goto out_put;
94643 +
94644 err =
94645 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
94646 if (err)
94647 @@ -1750,6 +1810,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
94648 * the protocol.
94649 */
94650
94651 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
94652 +
94653 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
94654 unsigned int, flags, struct sockaddr __user *, addr,
94655 int, addr_len)
94656 @@ -1816,7 +1878,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
94657 struct socket *sock;
94658 struct iovec iov;
94659 struct msghdr msg;
94660 - struct sockaddr_storage address;
94661 + struct sockaddr_storage address = { };
94662 int err, err2;
94663 int fput_needed;
94664
94665 @@ -2023,7 +2085,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
94666 * checking falls down on this.
94667 */
94668 if (copy_from_user(ctl_buf,
94669 - (void __user __force *)msg_sys->msg_control,
94670 + (void __force_user *)msg_sys->msg_control,
94671 ctl_len))
94672 goto out_freectl;
94673 msg_sys->msg_control = ctl_buf;
94674 @@ -2174,7 +2236,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
94675 int err, total_len, len;
94676
94677 /* kernel mode address */
94678 - struct sockaddr_storage addr;
94679 + struct sockaddr_storage addr = { };
94680
94681 /* user mode address pointers */
94682 struct sockaddr __user *uaddr;
94683 @@ -2202,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
94684 * kernel msghdr to use the kernel address space)
94685 */
94686
94687 - uaddr = (__force void __user *)msg_sys->msg_name;
94688 + uaddr = (void __force_user *)msg_sys->msg_name;
94689 uaddr_len = COMPAT_NAMELEN(msg);
94690 if (MSG_CMSG_COMPAT & flags) {
94691 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
94692 @@ -2955,7 +3017,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
94693 old_fs = get_fs();
94694 set_fs(KERNEL_DS);
94695 err = dev_ioctl(net, cmd,
94696 - (struct ifreq __user __force *) &kifr);
94697 + (struct ifreq __force_user *) &kifr);
94698 set_fs(old_fs);
94699
94700 return err;
94701 @@ -3064,7 +3126,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
94702
94703 old_fs = get_fs();
94704 set_fs(KERNEL_DS);
94705 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
94706 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
94707 set_fs(old_fs);
94708
94709 if (cmd == SIOCGIFMAP && !err) {
94710 @@ -3169,7 +3231,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
94711 ret |= __get_user(rtdev, &(ur4->rt_dev));
94712 if (rtdev) {
94713 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
94714 - r4.rt_dev = (char __user __force *)devname;
94715 + r4.rt_dev = (char __force_user *)devname;
94716 devname[15] = 0;
94717 } else
94718 r4.rt_dev = NULL;
94719 @@ -3395,8 +3457,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
94720 int __user *uoptlen;
94721 int err;
94722
94723 - uoptval = (char __user __force *) optval;
94724 - uoptlen = (int __user __force *) optlen;
94725 + uoptval = (char __force_user *) optval;
94726 + uoptlen = (int __force_user *) optlen;
94727
94728 set_fs(KERNEL_DS);
94729 if (level == SOL_SOCKET)
94730 @@ -3416,7 +3478,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
94731 char __user *uoptval;
94732 int err;
94733
94734 - uoptval = (char __user __force *) optval;
94735 + uoptval = (char __force_user *) optval;
94736
94737 set_fs(KERNEL_DS);
94738 if (level == SOL_SOCKET)
94739 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
94740 index 426f8fc..1ef9c32 100644
94741 --- a/net/sunrpc/clnt.c
94742 +++ b/net/sunrpc/clnt.c
94743 @@ -1288,7 +1288,9 @@ call_start(struct rpc_task *task)
94744 (RPC_IS_ASYNC(task) ? "async" : "sync"));
94745
94746 /* Increment call count */
94747 - task->tk_msg.rpc_proc->p_count++;
94748 + pax_open_kernel();
94749 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
94750 + pax_close_kernel();
94751 clnt->cl_stats->rpccnt++;
94752 task->tk_action = call_reserve;
94753 }
94754 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
94755 index 5356b12..c0f4c29 100644
94756 --- a/net/sunrpc/sched.c
94757 +++ b/net/sunrpc/sched.c
94758 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
94759 #ifdef RPC_DEBUG
94760 static void rpc_task_set_debuginfo(struct rpc_task *task)
94761 {
94762 - static atomic_t rpc_pid;
94763 + static atomic_unchecked_t rpc_pid;
94764
94765 - task->tk_pid = atomic_inc_return(&rpc_pid);
94766 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
94767 }
94768 #else
94769 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
94770 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
94771 index 89a588b..678ed90 100644
94772 --- a/net/sunrpc/svc.c
94773 +++ b/net/sunrpc/svc.c
94774 @@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
94775
94776 __module_get(serv->sv_module);
94777 task = kthread_create_on_node(serv->sv_function, rqstp,
94778 - node, serv->sv_name);
94779 + node, "%s", serv->sv_name);
94780 if (IS_ERR(task)) {
94781 error = PTR_ERR(task);
94782 module_put(serv->sv_module);
94783 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
94784 svc_putnl(resv, RPC_SUCCESS);
94785
94786 /* Bump per-procedure stats counter */
94787 - procp->pc_count++;
94788 + pax_open_kernel();
94789 + (*(unsigned int *)&procp->pc_count)++;
94790 + pax_close_kernel();
94791
94792 /* Initialize storage for argp and resp */
94793 memset(rqstp->rq_argp, 0, procp->pc_argsize);
94794 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
94795 index 8343737..677025e 100644
94796 --- a/net/sunrpc/xprtrdma/svc_rdma.c
94797 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
94798 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
94799 static unsigned int min_max_inline = 4096;
94800 static unsigned int max_max_inline = 65536;
94801
94802 -atomic_t rdma_stat_recv;
94803 -atomic_t rdma_stat_read;
94804 -atomic_t rdma_stat_write;
94805 -atomic_t rdma_stat_sq_starve;
94806 -atomic_t rdma_stat_rq_starve;
94807 -atomic_t rdma_stat_rq_poll;
94808 -atomic_t rdma_stat_rq_prod;
94809 -atomic_t rdma_stat_sq_poll;
94810 -atomic_t rdma_stat_sq_prod;
94811 +atomic_unchecked_t rdma_stat_recv;
94812 +atomic_unchecked_t rdma_stat_read;
94813 +atomic_unchecked_t rdma_stat_write;
94814 +atomic_unchecked_t rdma_stat_sq_starve;
94815 +atomic_unchecked_t rdma_stat_rq_starve;
94816 +atomic_unchecked_t rdma_stat_rq_poll;
94817 +atomic_unchecked_t rdma_stat_rq_prod;
94818 +atomic_unchecked_t rdma_stat_sq_poll;
94819 +atomic_unchecked_t rdma_stat_sq_prod;
94820
94821 /* Temporary NFS request map and context caches */
94822 struct kmem_cache *svc_rdma_map_cachep;
94823 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
94824 len -= *ppos;
94825 if (len > *lenp)
94826 len = *lenp;
94827 - if (len && copy_to_user(buffer, str_buf, len))
94828 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
94829 return -EFAULT;
94830 *lenp = len;
94831 *ppos += len;
94832 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
94833 {
94834 .procname = "rdma_stat_read",
94835 .data = &rdma_stat_read,
94836 - .maxlen = sizeof(atomic_t),
94837 + .maxlen = sizeof(atomic_unchecked_t),
94838 .mode = 0644,
94839 .proc_handler = read_reset_stat,
94840 },
94841 {
94842 .procname = "rdma_stat_recv",
94843 .data = &rdma_stat_recv,
94844 - .maxlen = sizeof(atomic_t),
94845 + .maxlen = sizeof(atomic_unchecked_t),
94846 .mode = 0644,
94847 .proc_handler = read_reset_stat,
94848 },
94849 {
94850 .procname = "rdma_stat_write",
94851 .data = &rdma_stat_write,
94852 - .maxlen = sizeof(atomic_t),
94853 + .maxlen = sizeof(atomic_unchecked_t),
94854 .mode = 0644,
94855 .proc_handler = read_reset_stat,
94856 },
94857 {
94858 .procname = "rdma_stat_sq_starve",
94859 .data = &rdma_stat_sq_starve,
94860 - .maxlen = sizeof(atomic_t),
94861 + .maxlen = sizeof(atomic_unchecked_t),
94862 .mode = 0644,
94863 .proc_handler = read_reset_stat,
94864 },
94865 {
94866 .procname = "rdma_stat_rq_starve",
94867 .data = &rdma_stat_rq_starve,
94868 - .maxlen = sizeof(atomic_t),
94869 + .maxlen = sizeof(atomic_unchecked_t),
94870 .mode = 0644,
94871 .proc_handler = read_reset_stat,
94872 },
94873 {
94874 .procname = "rdma_stat_rq_poll",
94875 .data = &rdma_stat_rq_poll,
94876 - .maxlen = sizeof(atomic_t),
94877 + .maxlen = sizeof(atomic_unchecked_t),
94878 .mode = 0644,
94879 .proc_handler = read_reset_stat,
94880 },
94881 {
94882 .procname = "rdma_stat_rq_prod",
94883 .data = &rdma_stat_rq_prod,
94884 - .maxlen = sizeof(atomic_t),
94885 + .maxlen = sizeof(atomic_unchecked_t),
94886 .mode = 0644,
94887 .proc_handler = read_reset_stat,
94888 },
94889 {
94890 .procname = "rdma_stat_sq_poll",
94891 .data = &rdma_stat_sq_poll,
94892 - .maxlen = sizeof(atomic_t),
94893 + .maxlen = sizeof(atomic_unchecked_t),
94894 .mode = 0644,
94895 .proc_handler = read_reset_stat,
94896 },
94897 {
94898 .procname = "rdma_stat_sq_prod",
94899 .data = &rdma_stat_sq_prod,
94900 - .maxlen = sizeof(atomic_t),
94901 + .maxlen = sizeof(atomic_unchecked_t),
94902 .mode = 0644,
94903 .proc_handler = read_reset_stat,
94904 },
94905 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
94906 index 0ce7552..d074459 100644
94907 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
94908 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
94909 @@ -501,7 +501,7 @@ next_sge:
94910 svc_rdma_put_context(ctxt, 0);
94911 goto out;
94912 }
94913 - atomic_inc(&rdma_stat_read);
94914 + atomic_inc_unchecked(&rdma_stat_read);
94915
94916 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
94917 chl_map->ch[ch_no].count -= read_wr.num_sge;
94918 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
94919 dto_q);
94920 list_del_init(&ctxt->dto_q);
94921 } else {
94922 - atomic_inc(&rdma_stat_rq_starve);
94923 + atomic_inc_unchecked(&rdma_stat_rq_starve);
94924 clear_bit(XPT_DATA, &xprt->xpt_flags);
94925 ctxt = NULL;
94926 }
94927 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
94928 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
94929 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
94930 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
94931 - atomic_inc(&rdma_stat_recv);
94932 + atomic_inc_unchecked(&rdma_stat_recv);
94933
94934 /* Build up the XDR from the receive buffers. */
94935 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
94936 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
94937 index c1d124d..acfc59e 100644
94938 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
94939 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
94940 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
94941 write_wr.wr.rdma.remote_addr = to;
94942
94943 /* Post It */
94944 - atomic_inc(&rdma_stat_write);
94945 + atomic_inc_unchecked(&rdma_stat_write);
94946 if (svc_rdma_send(xprt, &write_wr))
94947 goto err;
94948 return 0;
94949 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
94950 index 62e4f9b..dd3f2d7 100644
94951 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
94952 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
94953 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
94954 return;
94955
94956 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
94957 - atomic_inc(&rdma_stat_rq_poll);
94958 + atomic_inc_unchecked(&rdma_stat_rq_poll);
94959
94960 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
94961 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
94962 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
94963 }
94964
94965 if (ctxt)
94966 - atomic_inc(&rdma_stat_rq_prod);
94967 + atomic_inc_unchecked(&rdma_stat_rq_prod);
94968
94969 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
94970 /*
94971 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
94972 return;
94973
94974 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
94975 - atomic_inc(&rdma_stat_sq_poll);
94976 + atomic_inc_unchecked(&rdma_stat_sq_poll);
94977 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
94978 if (wc.status != IB_WC_SUCCESS)
94979 /* Close the transport */
94980 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
94981 }
94982
94983 if (ctxt)
94984 - atomic_inc(&rdma_stat_sq_prod);
94985 + atomic_inc_unchecked(&rdma_stat_sq_prod);
94986 }
94987
94988 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
94989 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
94990 spin_lock_bh(&xprt->sc_lock);
94991 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
94992 spin_unlock_bh(&xprt->sc_lock);
94993 - atomic_inc(&rdma_stat_sq_starve);
94994 + atomic_inc_unchecked(&rdma_stat_sq_starve);
94995
94996 /* See if we can opportunistically reap SQ WR to make room */
94997 sq_cq_reap(xprt);
94998 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
94999 index 9bc6db0..47ac8c0 100644
95000 --- a/net/sysctl_net.c
95001 +++ b/net/sysctl_net.c
95002 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
95003 kgid_t root_gid = make_kgid(net->user_ns, 0);
95004
95005 /* Allow network administrator to have same access as root. */
95006 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
95007 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
95008 uid_eq(root_uid, current_uid())) {
95009 int mode = (table->mode >> 6) & 7;
95010 return (mode << 6) | (mode << 3) | mode;
95011 diff --git a/net/tipc/link.c b/net/tipc/link.c
95012 index a80feee..2bbbe70 100644
95013 --- a/net/tipc/link.c
95014 +++ b/net/tipc/link.c
95015 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
95016 struct tipc_msg fragm_hdr;
95017 struct sk_buff *buf, *buf_chain, *prev;
95018 u32 fragm_crs, fragm_rest, hsz, sect_rest;
95019 - const unchar *sect_crs;
95020 + const unchar __user *sect_crs;
95021 int curr_sect;
95022 u32 fragm_no;
95023
95024 @@ -1242,7 +1242,7 @@ again:
95025
95026 if (!sect_rest) {
95027 sect_rest = msg_sect[++curr_sect].iov_len;
95028 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
95029 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
95030 }
95031
95032 if (sect_rest < fragm_rest)
95033 @@ -1261,7 +1261,7 @@ error:
95034 }
95035 } else
95036 skb_copy_to_linear_data_offset(buf, fragm_crs,
95037 - sect_crs, sz);
95038 + (const void __force_kernel *)sect_crs, sz);
95039 sect_crs += sz;
95040 sect_rest -= sz;
95041 fragm_crs += sz;
95042 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
95043 index f2db8a8..9245aa4 100644
95044 --- a/net/tipc/msg.c
95045 +++ b/net/tipc/msg.c
95046 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
95047 msg_sect[cnt].iov_len);
95048 else
95049 skb_copy_to_linear_data_offset(*buf, pos,
95050 - msg_sect[cnt].iov_base,
95051 + (const void __force_kernel *)msg_sect[cnt].iov_base,
95052 msg_sect[cnt].iov_len);
95053 pos += msg_sect[cnt].iov_len;
95054 }
95055 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
95056 index 6b42d47..2ac24d5 100644
95057 --- a/net/tipc/subscr.c
95058 +++ b/net/tipc/subscr.c
95059 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
95060 {
95061 struct iovec msg_sect;
95062
95063 - msg_sect.iov_base = (void *)&sub->evt;
95064 + msg_sect.iov_base = (void __force_user *)&sub->evt;
95065 msg_sect.iov_len = sizeof(struct tipc_event);
95066
95067 sub->evt.event = htohl(event, sub->swap);
95068 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
95069 index 826e099..4fa8c93 100644
95070 --- a/net/unix/af_unix.c
95071 +++ b/net/unix/af_unix.c
95072 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
95073 err = -ECONNREFUSED;
95074 if (!S_ISSOCK(inode->i_mode))
95075 goto put_fail;
95076 +
95077 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
95078 + err = -EACCES;
95079 + goto put_fail;
95080 + }
95081 +
95082 u = unix_find_socket_byinode(inode);
95083 if (!u)
95084 goto put_fail;
95085 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
95086 if (u) {
95087 struct dentry *dentry;
95088 dentry = unix_sk(u)->path.dentry;
95089 +
95090 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
95091 + err = -EPERM;
95092 + sock_put(u);
95093 + goto fail;
95094 + }
95095 +
95096 if (dentry)
95097 touch_atime(&unix_sk(u)->path);
95098 } else
95099 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
95100 */
95101 err = security_path_mknod(&path, dentry, mode, 0);
95102 if (!err) {
95103 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
95104 + err = -EACCES;
95105 + goto out;
95106 + }
95107 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
95108 if (!err) {
95109 res->mnt = mntget(path.mnt);
95110 res->dentry = dget(dentry);
95111 + gr_handle_create(dentry, path.mnt);
95112 }
95113 }
95114 +out:
95115 done_path_create(&path, dentry);
95116 return err;
95117 }
95118 @@ -2324,9 +2343,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
95119 seq_puts(seq, "Num RefCount Protocol Flags Type St "
95120 "Inode Path\n");
95121 else {
95122 - struct sock *s = v;
95123 + struct sock *s = v, *peer;
95124 struct unix_sock *u = unix_sk(s);
95125 unix_state_lock(s);
95126 + peer = unix_peer(s);
95127 + unix_state_unlock(s);
95128 +
95129 + unix_state_double_lock(s, peer);
95130
95131 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
95132 s,
95133 @@ -2353,8 +2376,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
95134 }
95135 for ( ; i < len; i++)
95136 seq_putc(seq, u->addr->name->sun_path[i]);
95137 - }
95138 - unix_state_unlock(s);
95139 + } else if (peer)
95140 + seq_printf(seq, " P%lu", sock_i_ino(peer));
95141 +
95142 + unix_state_double_unlock(s, peer);
95143 seq_putc(seq, '\n');
95144 }
95145
95146 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
95147 index 8800604..0526440 100644
95148 --- a/net/unix/sysctl_net_unix.c
95149 +++ b/net/unix/sysctl_net_unix.c
95150 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
95151
95152 int __net_init unix_sysctl_register(struct net *net)
95153 {
95154 - struct ctl_table *table;
95155 + ctl_table_no_const *table;
95156
95157 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
95158 if (table == NULL)
95159 diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
95160 index 3f77f42..662d89b 100644
95161 --- a/net/vmw_vsock/af_vsock.c
95162 +++ b/net/vmw_vsock/af_vsock.c
95163 @@ -335,7 +335,7 @@ void vsock_for_each_connected_socket(void (*fn)(struct sock *sk))
95164 for (i = 0; i < ARRAY_SIZE(vsock_connected_table); i++) {
95165 struct vsock_sock *vsk;
95166 list_for_each_entry(vsk, &vsock_connected_table[i],
95167 - connected_table);
95168 + connected_table)
95169 fn(sk_vsock(vsk));
95170 }
95171
95172 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
95173 index c8717c1..08539f5 100644
95174 --- a/net/wireless/wext-core.c
95175 +++ b/net/wireless/wext-core.c
95176 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
95177 */
95178
95179 /* Support for very large requests */
95180 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
95181 - (user_length > descr->max_tokens)) {
95182 + if (user_length > descr->max_tokens) {
95183 /* Allow userspace to GET more than max so
95184 * we can support any size GET requests.
95185 * There is still a limit : -ENOMEM.
95186 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
95187 }
95188 }
95189
95190 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
95191 - /*
95192 - * If this is a GET, but not NOMAX, it means that the extra
95193 - * data is not bounded by userspace, but by max_tokens. Thus
95194 - * set the length to max_tokens. This matches the extra data
95195 - * allocation.
95196 - * The driver should fill it with the number of tokens it
95197 - * provided, and it may check iwp->length rather than having
95198 - * knowledge of max_tokens. If the driver doesn't change the
95199 - * iwp->length, this ioctl just copies back max_token tokens
95200 - * filled with zeroes. Hopefully the driver isn't claiming
95201 - * them to be valid data.
95202 - */
95203 - iwp->length = descr->max_tokens;
95204 - }
95205 -
95206 err = handler(dev, info, (union iwreq_data *) iwp, extra);
95207
95208 iwp->length += essid_compat;
95209 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
95210 index ea970b8..c68edb9f 100644
95211 --- a/net/xfrm/xfrm_policy.c
95212 +++ b/net/xfrm/xfrm_policy.c
95213 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
95214 {
95215 policy->walk.dead = 1;
95216
95217 - atomic_inc(&policy->genid);
95218 + atomic_inc_unchecked(&policy->genid);
95219
95220 del_timer(&policy->polq.hold_timer);
95221 xfrm_queue_purge(&policy->polq.hold_queue);
95222 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
95223 hlist_add_head(&policy->bydst, chain);
95224 xfrm_pol_hold(policy);
95225 net->xfrm.policy_count[dir]++;
95226 - atomic_inc(&flow_cache_genid);
95227 + atomic_inc_unchecked(&flow_cache_genid);
95228 rt_genid_bump(net);
95229 if (delpol) {
95230 xfrm_policy_requeue(delpol, policy);
95231 @@ -1629,7 +1629,7 @@ free_dst:
95232 goto out;
95233 }
95234
95235 -static int inline
95236 +static inline int
95237 xfrm_dst_alloc_copy(void **target, const void *src, int size)
95238 {
95239 if (!*target) {
95240 @@ -1641,7 +1641,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
95241 return 0;
95242 }
95243
95244 -static int inline
95245 +static inline int
95246 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
95247 {
95248 #ifdef CONFIG_XFRM_SUB_POLICY
95249 @@ -1653,7 +1653,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
95250 #endif
95251 }
95252
95253 -static int inline
95254 +static inline int
95255 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
95256 {
95257 #ifdef CONFIG_XFRM_SUB_POLICY
95258 @@ -1747,7 +1747,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
95259
95260 xdst->num_pols = num_pols;
95261 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
95262 - xdst->policy_genid = atomic_read(&pols[0]->genid);
95263 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
95264
95265 return xdst;
95266 }
95267 @@ -2618,7 +2618,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
95268 if (xdst->xfrm_genid != dst->xfrm->genid)
95269 return 0;
95270 if (xdst->num_pols > 0 &&
95271 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
95272 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
95273 return 0;
95274
95275 mtu = dst_mtu(dst->child);
95276 @@ -2706,8 +2706,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
95277 dst_ops->link_failure = xfrm_link_failure;
95278 if (likely(dst_ops->neigh_lookup == NULL))
95279 dst_ops->neigh_lookup = xfrm_neigh_lookup;
95280 - if (likely(afinfo->garbage_collect == NULL))
95281 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
95282 + if (likely(afinfo->garbage_collect == NULL)) {
95283 + pax_open_kernel();
95284 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
95285 + pax_close_kernel();
95286 + }
95287 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
95288 }
95289 spin_unlock(&xfrm_policy_afinfo_lock);
95290 @@ -2761,7 +2764,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
95291 dst_ops->check = NULL;
95292 dst_ops->negative_advice = NULL;
95293 dst_ops->link_failure = NULL;
95294 - afinfo->garbage_collect = NULL;
95295 + pax_open_kernel();
95296 + *(void **)&afinfo->garbage_collect = NULL;
95297 + pax_close_kernel();
95298 }
95299 return err;
95300 }
95301 @@ -3144,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
95302 sizeof(pol->xfrm_vec[i].saddr));
95303 pol->xfrm_vec[i].encap_family = mp->new_family;
95304 /* flush bundles */
95305 - atomic_inc(&pol->genid);
95306 + atomic_inc_unchecked(&pol->genid);
95307 }
95308 }
95309
95310 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
95311 index 78f66fa..9286768 100644
95312 --- a/net/xfrm/xfrm_state.c
95313 +++ b/net/xfrm/xfrm_state.c
95314 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
95315
95316 if (unlikely(afinfo == NULL))
95317 return -EAFNOSUPPORT;
95318 - typemap = afinfo->type_map;
95319 + typemap = (const struct xfrm_type **)afinfo->type_map;
95320 spin_lock_bh(&xfrm_type_lock);
95321
95322 - if (likely(typemap[type->proto] == NULL))
95323 + if (likely(typemap[type->proto] == NULL)) {
95324 + pax_open_kernel();
95325 typemap[type->proto] = type;
95326 - else
95327 + pax_close_kernel();
95328 + } else
95329 err = -EEXIST;
95330 spin_unlock_bh(&xfrm_type_lock);
95331 xfrm_state_put_afinfo(afinfo);
95332 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
95333
95334 if (unlikely(afinfo == NULL))
95335 return -EAFNOSUPPORT;
95336 - typemap = afinfo->type_map;
95337 + typemap = (const struct xfrm_type **)afinfo->type_map;
95338 spin_lock_bh(&xfrm_type_lock);
95339
95340 if (unlikely(typemap[type->proto] != type))
95341 err = -ENOENT;
95342 - else
95343 + else {
95344 + pax_open_kernel();
95345 typemap[type->proto] = NULL;
95346 + pax_close_kernel();
95347 + }
95348 spin_unlock_bh(&xfrm_type_lock);
95349 xfrm_state_put_afinfo(afinfo);
95350 return err;
95351 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
95352 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
95353 {
95354 struct xfrm_state_afinfo *afinfo;
95355 - const struct xfrm_type **typemap;
95356 const struct xfrm_type *type;
95357 int modload_attempted = 0;
95358
95359 @@ -222,9 +226,8 @@ retry:
95360 afinfo = xfrm_state_get_afinfo(family);
95361 if (unlikely(afinfo == NULL))
95362 return NULL;
95363 - typemap = afinfo->type_map;
95364
95365 - type = typemap[proto];
95366 + type = afinfo->type_map[proto];
95367 if (unlikely(type && !try_module_get(type->owner)))
95368 type = NULL;
95369 if (!type && !modload_attempted) {
95370 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
95371 return -EAFNOSUPPORT;
95372
95373 err = -EEXIST;
95374 - modemap = afinfo->mode_map;
95375 + modemap = (struct xfrm_mode **)afinfo->mode_map;
95376 spin_lock_bh(&xfrm_mode_lock);
95377 if (modemap[mode->encap])
95378 goto out;
95379 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
95380 if (!try_module_get(afinfo->owner))
95381 goto out;
95382
95383 - mode->afinfo = afinfo;
95384 + pax_open_kernel();
95385 + *(const void **)&mode->afinfo = afinfo;
95386 modemap[mode->encap] = mode;
95387 + pax_close_kernel();
95388 err = 0;
95389
95390 out:
95391 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
95392 return -EAFNOSUPPORT;
95393
95394 err = -ENOENT;
95395 - modemap = afinfo->mode_map;
95396 + modemap = (struct xfrm_mode **)afinfo->mode_map;
95397 spin_lock_bh(&xfrm_mode_lock);
95398 if (likely(modemap[mode->encap] == mode)) {
95399 + pax_open_kernel();
95400 modemap[mode->encap] = NULL;
95401 + pax_close_kernel();
95402 module_put(mode->afinfo->owner);
95403 err = 0;
95404 }
95405 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
95406 index 05a6e3d..6716ec9 100644
95407 --- a/net/xfrm/xfrm_sysctl.c
95408 +++ b/net/xfrm/xfrm_sysctl.c
95409 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
95410
95411 int __net_init xfrm_sysctl_init(struct net *net)
95412 {
95413 - struct ctl_table *table;
95414 + ctl_table_no_const *table;
95415
95416 __xfrm_sysctl_init(net);
95417
95418 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
95419 index d5d859c..781cbcb 100644
95420 --- a/scripts/Makefile.build
95421 +++ b/scripts/Makefile.build
95422 @@ -111,7 +111,7 @@ endif
95423 endif
95424
95425 # Do not include host rules unless needed
95426 -ifneq ($(hostprogs-y)$(hostprogs-m),)
95427 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
95428 include scripts/Makefile.host
95429 endif
95430
95431 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
95432 index 686cb0d..9d653bf 100644
95433 --- a/scripts/Makefile.clean
95434 +++ b/scripts/Makefile.clean
95435 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
95436 __clean-files := $(extra-y) $(always) \
95437 $(targets) $(clean-files) \
95438 $(host-progs) \
95439 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
95440 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
95441 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
95442
95443 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
95444
95445 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
95446 index 1ac414f..38575f7 100644
95447 --- a/scripts/Makefile.host
95448 +++ b/scripts/Makefile.host
95449 @@ -31,6 +31,8 @@
95450 # Note: Shared libraries consisting of C++ files are not supported
95451
95452 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
95453 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
95454 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
95455
95456 # C code
95457 # Executables compiled from a single .c file
95458 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
95459 # Shared libaries (only .c supported)
95460 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
95461 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
95462 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
95463 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
95464 # Remove .so files from "xxx-objs"
95465 host-cobjs := $(filter-out %.so,$(host-cobjs))
95466 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
95467
95468 -#Object (.o) files used by the shared libaries
95469 +# Object (.o) files used by the shared libaries
95470 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
95471 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
95472
95473 # output directory for programs/.o files
95474 # hostprogs-y := tools/build may have been specified. Retrieve directory
95475 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
95476 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
95477 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
95478 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
95479 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
95480 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
95481 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
95482 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
95483
95484 obj-dirs += $(host-objdirs)
95485 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
95486 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
95487 $(call if_changed_dep,host-cshobjs)
95488
95489 +# Compile .c file, create position independent .o file
95490 +# host-cxxshobjs -> .o
95491 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
95492 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
95493 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
95494 + $(call if_changed_dep,host-cxxshobjs)
95495 +
95496 # Link a shared library, based on position independent .o files
95497 # *.o -> .so shared library (host-cshlib)
95498 quiet_cmd_host-cshlib = HOSTLLD -shared $@
95499 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
95500 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
95501 $(call if_changed,host-cshlib)
95502
95503 +# Link a shared library, based on position independent .o files
95504 +# *.o -> .so shared library (host-cxxshlib)
95505 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
95506 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
95507 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
95508 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
95509 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
95510 + $(call if_changed,host-cxxshlib)
95511 +
95512 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
95513 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
95514 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
95515
95516 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
95517 index 078fe1d..fbdb363 100644
95518 --- a/scripts/basic/fixdep.c
95519 +++ b/scripts/basic/fixdep.c
95520 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
95521 /*
95522 * Lookup a value in the configuration string.
95523 */
95524 -static int is_defined_config(const char *name, int len, unsigned int hash)
95525 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
95526 {
95527 struct item *aux;
95528
95529 @@ -211,10 +211,10 @@ static void clear_config(void)
95530 /*
95531 * Record the use of a CONFIG_* word.
95532 */
95533 -static void use_config(const char *m, int slen)
95534 +static void use_config(const char *m, unsigned int slen)
95535 {
95536 unsigned int hash = strhash(m, slen);
95537 - int c, i;
95538 + unsigned int c, i;
95539
95540 if (is_defined_config(m, slen, hash))
95541 return;
95542 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
95543
95544 static void parse_config_file(const char *map, size_t len)
95545 {
95546 - const int *end = (const int *) (map + len);
95547 + const unsigned int *end = (const unsigned int *) (map + len);
95548 /* start at +1, so that p can never be < map */
95549 - const int *m = (const int *) map + 1;
95550 + const unsigned int *m = (const unsigned int *) map + 1;
95551 const char *p, *q;
95552
95553 for (; m < end; m++) {
95554 @@ -435,7 +435,7 @@ static void print_deps(void)
95555 static void traps(void)
95556 {
95557 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
95558 - int *p = (int *)test;
95559 + unsigned int *p = (unsigned int *)test;
95560
95561 if (*p != INT_CONF) {
95562 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
95563 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
95564 new file mode 100644
95565 index 0000000..5e0222d
95566 --- /dev/null
95567 +++ b/scripts/gcc-plugin.sh
95568 @@ -0,0 +1,17 @@
95569 +#!/bin/bash
95570 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
95571 +#include "gcc-plugin.h"
95572 +#include "tree.h"
95573 +#include "tm.h"
95574 +#include "rtl.h"
95575 +#ifdef ENABLE_BUILD_WITH_CXX
95576 +#warning $2
95577 +#else
95578 +#warning $1
95579 +#endif
95580 +EOF`
95581 +if [ $? -eq 0 ]
95582 +then
95583 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
95584 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
95585 +fi
95586 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
95587 index 643764f..6cc0137 100644
95588 --- a/scripts/headers_install.sh
95589 +++ b/scripts/headers_install.sh
95590 @@ -29,6 +29,7 @@ do
95591 FILE="$(basename "$i")"
95592 sed -r \
95593 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
95594 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
95595 -e 's/__attribute_const__([ \t]|$)/\1/g' \
95596 -e 's@^#include <linux/compiler.h>@@' \
95597 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
95598 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
95599 index 0149949..d482a0d 100644
95600 --- a/scripts/link-vmlinux.sh
95601 +++ b/scripts/link-vmlinux.sh
95602 @@ -158,7 +158,7 @@ else
95603 fi;
95604
95605 # final build of init/
95606 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
95607 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
95608
95609 kallsymso=""
95610 kallsyms_vmlinux=""
95611 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
95612 index 45f9a33..e4194b3 100644
95613 --- a/scripts/mod/file2alias.c
95614 +++ b/scripts/mod/file2alias.c
95615 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
95616 unsigned long size, unsigned long id_size,
95617 void *symval)
95618 {
95619 - int i;
95620 + unsigned int i;
95621
95622 if (size % id_size || size < id_size) {
95623 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
95624 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
95625 /* USB is special because the bcdDevice can be matched against a numeric range */
95626 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
95627 static void do_usb_entry(void *symval,
95628 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
95629 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
95630 unsigned char range_lo, unsigned char range_hi,
95631 unsigned char max, struct module *mod)
95632 {
95633 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
95634 {
95635 unsigned int devlo, devhi;
95636 unsigned char chi, clo, max;
95637 - int ndigits;
95638 + unsigned int ndigits;
95639
95640 DEF_FIELD(symval, usb_device_id, match_flags);
95641 DEF_FIELD(symval, usb_device_id, idVendor);
95642 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
95643 for (i = 0; i < count; i++) {
95644 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
95645 char acpi_id[sizeof(*id)];
95646 - int j;
95647 + unsigned int j;
95648
95649 buf_printf(&mod->dev_table_buf,
95650 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
95651 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
95652
95653 for (j = 0; j < PNP_MAX_DEVICES; j++) {
95654 const char *id = (char *)(*devs)[j].id;
95655 - int i2, j2;
95656 + unsigned int i2, j2;
95657 int dup = 0;
95658
95659 if (!id[0])
95660 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
95661 /* add an individual alias for every device entry */
95662 if (!dup) {
95663 char acpi_id[PNP_ID_LEN];
95664 - int k;
95665 + unsigned int k;
95666
95667 buf_printf(&mod->dev_table_buf,
95668 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
95669 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
95670 static int do_dmi_entry(const char *filename, void *symval,
95671 char *alias)
95672 {
95673 - int i, j;
95674 + unsigned int i, j;
95675 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
95676 sprintf(alias, "dmi*");
95677
95678 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
95679 index a4be8e1..6e8a5fb 100644
95680 --- a/scripts/mod/modpost.c
95681 +++ b/scripts/mod/modpost.c
95682 @@ -933,6 +933,7 @@ enum mismatch {
95683 ANY_INIT_TO_ANY_EXIT,
95684 ANY_EXIT_TO_ANY_INIT,
95685 EXPORT_TO_INIT_EXIT,
95686 + DATA_TO_TEXT
95687 };
95688
95689 struct sectioncheck {
95690 @@ -1047,6 +1048,12 @@ const struct sectioncheck sectioncheck[] = {
95691 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
95692 .mismatch = EXPORT_TO_INIT_EXIT,
95693 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
95694 +},
95695 +/* Do not reference code from writable data */
95696 +{
95697 + .fromsec = { DATA_SECTIONS, NULL },
95698 + .tosec = { TEXT_SECTIONS, NULL },
95699 + .mismatch = DATA_TO_TEXT
95700 }
95701 };
95702
95703 @@ -1169,10 +1176,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
95704 continue;
95705 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
95706 continue;
95707 - if (sym->st_value == addr)
95708 - return sym;
95709 /* Find a symbol nearby - addr are maybe negative */
95710 d = sym->st_value - addr;
95711 + if (d == 0)
95712 + return sym;
95713 if (d < 0)
95714 d = addr - sym->st_value;
95715 if (d < distance) {
95716 @@ -1451,6 +1458,14 @@ static void report_sec_mismatch(const char *modname,
95717 tosym, prl_to, prl_to, tosym);
95718 free(prl_to);
95719 break;
95720 + case DATA_TO_TEXT:
95721 +#if 0
95722 + fprintf(stderr,
95723 + "The %s %s:%s references\n"
95724 + "the %s %s:%s%s\n",
95725 + from, fromsec, fromsym, to, tosec, tosym, to_p);
95726 +#endif
95727 + break;
95728 }
95729 fprintf(stderr, "\n");
95730 }
95731 @@ -1685,7 +1700,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
95732 static void check_sec_ref(struct module *mod, const char *modname,
95733 struct elf_info *elf)
95734 {
95735 - int i;
95736 + unsigned int i;
95737 Elf_Shdr *sechdrs = elf->sechdrs;
95738
95739 /* Walk through all sections */
95740 @@ -1804,7 +1819,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
95741 va_end(ap);
95742 }
95743
95744 -void buf_write(struct buffer *buf, const char *s, int len)
95745 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
95746 {
95747 if (buf->size - buf->pos < len) {
95748 buf->size += len + SZ;
95749 @@ -2023,7 +2038,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
95750 if (fstat(fileno(file), &st) < 0)
95751 goto close_write;
95752
95753 - if (st.st_size != b->pos)
95754 + if (st.st_size != (off_t)b->pos)
95755 goto close_write;
95756
95757 tmp = NOFAIL(malloc(b->pos));
95758 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
95759 index 51207e4..f7d603d 100644
95760 --- a/scripts/mod/modpost.h
95761 +++ b/scripts/mod/modpost.h
95762 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
95763
95764 struct buffer {
95765 char *p;
95766 - int pos;
95767 - int size;
95768 + unsigned int pos;
95769 + unsigned int size;
95770 };
95771
95772 void __attribute__((format(printf, 2, 3)))
95773 buf_printf(struct buffer *buf, const char *fmt, ...);
95774
95775 void
95776 -buf_write(struct buffer *buf, const char *s, int len);
95777 +buf_write(struct buffer *buf, const char *s, unsigned int len);
95778
95779 struct module {
95780 struct module *next;
95781 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
95782 index 9dfcd6d..099068e 100644
95783 --- a/scripts/mod/sumversion.c
95784 +++ b/scripts/mod/sumversion.c
95785 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
95786 goto out;
95787 }
95788
95789 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
95790 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
95791 warn("writing sum in %s failed: %s\n",
95792 filename, strerror(errno));
95793 goto out;
95794 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
95795 index acb8650..b8c5f02 100644
95796 --- a/scripts/package/builddeb
95797 +++ b/scripts/package/builddeb
95798 @@ -246,6 +246,7 @@ fi
95799 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
95800 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
95801 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
95802 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
95803 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
95804 mkdir -p "$destdir"
95805 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
95806 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
95807 index 68bb4ef..2f419e1 100644
95808 --- a/scripts/pnmtologo.c
95809 +++ b/scripts/pnmtologo.c
95810 @@ -244,14 +244,14 @@ static void write_header(void)
95811 fprintf(out, " * Linux logo %s\n", logoname);
95812 fputs(" */\n\n", out);
95813 fputs("#include <linux/linux_logo.h>\n\n", out);
95814 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
95815 + fprintf(out, "static unsigned char %s_data[] = {\n",
95816 logoname);
95817 }
95818
95819 static void write_footer(void)
95820 {
95821 fputs("\n};\n\n", out);
95822 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
95823 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
95824 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
95825 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
95826 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
95827 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
95828 fputs("\n};\n\n", out);
95829
95830 /* write logo clut */
95831 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
95832 + fprintf(out, "static unsigned char %s_clut[] = {\n",
95833 logoname);
95834 write_hex_cnt = 0;
95835 for (i = 0; i < logo_clutsize; i++) {
95836 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
95837 index f5eb43d..1814de8 100644
95838 --- a/scripts/sortextable.h
95839 +++ b/scripts/sortextable.h
95840 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
95841 const char *secstrtab;
95842 const char *strtab;
95843 char *extab_image;
95844 - int extab_index = 0;
95845 - int i;
95846 - int idx;
95847 + unsigned int extab_index = 0;
95848 + unsigned int i;
95849 + unsigned int idx;
95850
95851 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
95852 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
95853 diff --git a/security/Kconfig b/security/Kconfig
95854 index e9c6ac7..3e3f362 100644
95855 --- a/security/Kconfig
95856 +++ b/security/Kconfig
95857 @@ -4,6 +4,959 @@
95858
95859 menu "Security options"
95860
95861 +menu "Grsecurity"
95862 +
95863 + config ARCH_TRACK_EXEC_LIMIT
95864 + bool
95865 +
95866 + config PAX_KERNEXEC_PLUGIN
95867 + bool
95868 +
95869 + config PAX_PER_CPU_PGD
95870 + bool
95871 +
95872 + config TASK_SIZE_MAX_SHIFT
95873 + int
95874 + depends on X86_64
95875 + default 47 if !PAX_PER_CPU_PGD
95876 + default 42 if PAX_PER_CPU_PGD
95877 +
95878 + config PAX_ENABLE_PAE
95879 + bool
95880 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
95881 +
95882 + config PAX_USERCOPY_SLABS
95883 + bool
95884 +
95885 +config GRKERNSEC
95886 + bool "Grsecurity"
95887 + select CRYPTO
95888 + select CRYPTO_SHA256
95889 + select PROC_FS
95890 + select STOP_MACHINE
95891 + select TTY
95892 + help
95893 + If you say Y here, you will be able to configure many features
95894 + that will enhance the security of your system. It is highly
95895 + recommended that you say Y here and read through the help
95896 + for each option so that you fully understand the features and
95897 + can evaluate their usefulness for your machine.
95898 +
95899 +choice
95900 + prompt "Configuration Method"
95901 + depends on GRKERNSEC
95902 + default GRKERNSEC_CONFIG_CUSTOM
95903 + help
95904 +
95905 +config GRKERNSEC_CONFIG_AUTO
95906 + bool "Automatic"
95907 + help
95908 + If you choose this configuration method, you'll be able to answer a small
95909 + number of simple questions about how you plan to use this kernel.
95910 + The settings of grsecurity and PaX will be automatically configured for
95911 + the highest commonly-used settings within the provided constraints.
95912 +
95913 + If you require additional configuration, custom changes can still be made
95914 + from the "custom configuration" menu.
95915 +
95916 +config GRKERNSEC_CONFIG_CUSTOM
95917 + bool "Custom"
95918 + help
95919 + If you choose this configuration method, you'll be able to configure all
95920 + grsecurity and PaX settings manually. Via this method, no options are
95921 + automatically enabled.
95922 +
95923 +endchoice
95924 +
95925 +choice
95926 + prompt "Usage Type"
95927 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
95928 + default GRKERNSEC_CONFIG_SERVER
95929 + help
95930 +
95931 +config GRKERNSEC_CONFIG_SERVER
95932 + bool "Server"
95933 + help
95934 + Choose this option if you plan to use this kernel on a server.
95935 +
95936 +config GRKERNSEC_CONFIG_DESKTOP
95937 + bool "Desktop"
95938 + help
95939 + Choose this option if you plan to use this kernel on a desktop.
95940 +
95941 +endchoice
95942 +
95943 +choice
95944 + prompt "Virtualization Type"
95945 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
95946 + default GRKERNSEC_CONFIG_VIRT_NONE
95947 + help
95948 +
95949 +config GRKERNSEC_CONFIG_VIRT_NONE
95950 + bool "None"
95951 + help
95952 + Choose this option if this kernel will be run on bare metal.
95953 +
95954 +config GRKERNSEC_CONFIG_VIRT_GUEST
95955 + bool "Guest"
95956 + help
95957 + Choose this option if this kernel will be run as a VM guest.
95958 +
95959 +config GRKERNSEC_CONFIG_VIRT_HOST
95960 + bool "Host"
95961 + help
95962 + Choose this option if this kernel will be run as a VM host.
95963 +
95964 +endchoice
95965 +
95966 +choice
95967 + prompt "Virtualization Hardware"
95968 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
95969 + help
95970 +
95971 +config GRKERNSEC_CONFIG_VIRT_EPT
95972 + bool "EPT/RVI Processor Support"
95973 + depends on X86
95974 + help
95975 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
95976 + hardware virtualization. This allows for additional kernel hardening protections
95977 + to operate without additional performance impact.
95978 +
95979 + To see if your Intel processor supports EPT, see:
95980 + http://ark.intel.com/Products/VirtualizationTechnology
95981 + (Most Core i3/5/7 support EPT)
95982 +
95983 + To see if your AMD processor supports RVI, see:
95984 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
95985 +
95986 +config GRKERNSEC_CONFIG_VIRT_SOFT
95987 + bool "First-gen/No Hardware Virtualization"
95988 + help
95989 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
95990 + support hardware virtualization or doesn't support the EPT/RVI extensions.
95991 +
95992 +endchoice
95993 +
95994 +choice
95995 + prompt "Virtualization Software"
95996 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
95997 + help
95998 +
95999 +config GRKERNSEC_CONFIG_VIRT_XEN
96000 + bool "Xen"
96001 + help
96002 + Choose this option if this kernel is running as a Xen guest or host.
96003 +
96004 +config GRKERNSEC_CONFIG_VIRT_VMWARE
96005 + bool "VMWare"
96006 + help
96007 + Choose this option if this kernel is running as a VMWare guest or host.
96008 +
96009 +config GRKERNSEC_CONFIG_VIRT_KVM
96010 + bool "KVM"
96011 + help
96012 + Choose this option if this kernel is running as a KVM guest or host.
96013 +
96014 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
96015 + bool "VirtualBox"
96016 + help
96017 + Choose this option if this kernel is running as a VirtualBox guest or host.
96018 +
96019 +endchoice
96020 +
96021 +choice
96022 + prompt "Required Priorities"
96023 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
96024 + default GRKERNSEC_CONFIG_PRIORITY_PERF
96025 + help
96026 +
96027 +config GRKERNSEC_CONFIG_PRIORITY_PERF
96028 + bool "Performance"
96029 + help
96030 + Choose this option if performance is of highest priority for this deployment
96031 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
96032 + clearing of structures intended for userland, and freed memory sanitizing will
96033 + be disabled.
96034 +
96035 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
96036 + bool "Security"
96037 + help
96038 + Choose this option if security is of highest priority for this deployment of
96039 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
96040 + for userland, and freed memory sanitizing will be enabled for this kernel.
96041 + In a worst-case scenario, these features can introduce a 20% performance hit
96042 + (UDEREF on x64 contributing half of this hit).
96043 +
96044 +endchoice
96045 +
96046 +menu "Default Special Groups"
96047 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
96048 +
96049 +config GRKERNSEC_PROC_GID
96050 + int "GID exempted from /proc restrictions"
96051 + default 1001
96052 + help
96053 + Setting this GID determines which group will be exempted from
96054 + grsecurity's /proc restrictions, allowing users of the specified
96055 + group to view network statistics and the existence of other users'
96056 + processes on the system. This GID may also be chosen at boot time
96057 + via "grsec_proc_gid=" on the kernel commandline.
96058 +
96059 +config GRKERNSEC_TPE_UNTRUSTED_GID
96060 + int "GID for TPE-untrusted users"
96061 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
96062 + default 1005
96063 + help
96064 + Setting this GID determines which group untrusted users should
96065 + be added to. These users will be placed under grsecurity's Trusted Path
96066 + Execution mechanism, preventing them from executing their own binaries.
96067 + The users will only be able to execute binaries in directories owned and
96068 + writable only by the root user. If the sysctl option is enabled, a sysctl
96069 + option with name "tpe_gid" is created.
96070 +
96071 +config GRKERNSEC_TPE_TRUSTED_GID
96072 + int "GID for TPE-trusted users"
96073 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
96074 + default 1005
96075 + help
96076 + Setting this GID determines what group TPE restrictions will be
96077 + *disabled* for. If the sysctl option is enabled, a sysctl option
96078 + with name "tpe_gid" is created.
96079 +
96080 +config GRKERNSEC_SYMLINKOWN_GID
96081 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
96082 + depends on GRKERNSEC_CONFIG_SERVER
96083 + default 1006
96084 + help
96085 + Setting this GID determines what group kernel-enforced
96086 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
96087 + is enabled, a sysctl option with name "symlinkown_gid" is created.
96088 +
96089 +
96090 +endmenu
96091 +
96092 +menu "Customize Configuration"
96093 +depends on GRKERNSEC
96094 +
96095 +menu "PaX"
96096 +
96097 +config PAX
96098 + bool "Enable various PaX features"
96099 + default y if GRKERNSEC_CONFIG_AUTO
96100 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
96101 + help
96102 + This allows you to enable various PaX features. PaX adds
96103 + intrusion prevention mechanisms to the kernel that reduce
96104 + the risks posed by exploitable memory corruption bugs.
96105 +
96106 +menu "PaX Control"
96107 + depends on PAX
96108 +
96109 +config PAX_SOFTMODE
96110 + bool 'Support soft mode'
96111 + help
96112 + Enabling this option will allow you to run PaX in soft mode, that
96113 + is, PaX features will not be enforced by default, only on executables
96114 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
96115 + support as they are the only way to mark executables for soft mode use.
96116 +
96117 + Soft mode can be activated by using the "pax_softmode=1" kernel command
96118 + line option on boot. Furthermore you can control various PaX features
96119 + at runtime via the entries in /proc/sys/kernel/pax.
96120 +
96121 +config PAX_EI_PAX
96122 + bool 'Use legacy ELF header marking'
96123 + default y if GRKERNSEC_CONFIG_AUTO
96124 + help
96125 + Enabling this option will allow you to control PaX features on
96126 + a per executable basis via the 'chpax' utility available at
96127 + http://pax.grsecurity.net/. The control flags will be read from
96128 + an otherwise reserved part of the ELF header. This marking has
96129 + numerous drawbacks (no support for soft-mode, toolchain does not
96130 + know about the non-standard use of the ELF header) therefore it
96131 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
96132 + support.
96133 +
96134 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
96135 + support as well, they will override the legacy EI_PAX marks.
96136 +
96137 + If you enable none of the marking options then all applications
96138 + will run with PaX enabled on them by default.
96139 +
96140 +config PAX_PT_PAX_FLAGS
96141 + bool 'Use ELF program header marking'
96142 + default y if GRKERNSEC_CONFIG_AUTO
96143 + help
96144 + Enabling this option will allow you to control PaX features on
96145 + a per executable basis via the 'paxctl' utility available at
96146 + http://pax.grsecurity.net/. The control flags will be read from
96147 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
96148 + has the benefits of supporting both soft mode and being fully
96149 + integrated into the toolchain (the binutils patch is available
96150 + from http://pax.grsecurity.net).
96151 +
96152 + Note that if you enable the legacy EI_PAX marking support as well,
96153 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
96154 +
96155 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
96156 + must make sure that the marks are the same if a binary has both marks.
96157 +
96158 + If you enable none of the marking options then all applications
96159 + will run with PaX enabled on them by default.
96160 +
96161 +config PAX_XATTR_PAX_FLAGS
96162 + bool 'Use filesystem extended attributes marking'
96163 + default y if GRKERNSEC_CONFIG_AUTO
96164 + select CIFS_XATTR if CIFS
96165 + select EXT2_FS_XATTR if EXT2_FS
96166 + select EXT3_FS_XATTR if EXT3_FS
96167 + select EXT4_FS_XATTR if EXT4_FS
96168 + select JFFS2_FS_XATTR if JFFS2_FS
96169 + select REISERFS_FS_XATTR if REISERFS_FS
96170 + select SQUASHFS_XATTR if SQUASHFS
96171 + select TMPFS_XATTR if TMPFS
96172 + select UBIFS_FS_XATTR if UBIFS_FS
96173 + help
96174 + Enabling this option will allow you to control PaX features on
96175 + a per executable basis via the 'setfattr' utility. The control
96176 + flags will be read from the user.pax.flags extended attribute of
96177 + the file. This marking has the benefit of supporting binary-only
96178 + applications that self-check themselves (e.g., skype) and would
96179 + not tolerate chpax/paxctl changes. The main drawback is that
96180 + extended attributes are not supported by some filesystems (e.g.,
96181 + isofs, udf, vfat) so copying files through such filesystems will
96182 + lose the extended attributes and these PaX markings.
96183 +
96184 + Note that if you enable the legacy EI_PAX marking support as well,
96185 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
96186 +
96187 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
96188 + must make sure that the marks are the same if a binary has both marks.
96189 +
96190 + If you enable none of the marking options then all applications
96191 + will run with PaX enabled on them by default.
96192 +
96193 +choice
96194 + prompt 'MAC system integration'
96195 + default PAX_HAVE_ACL_FLAGS
96196 + help
96197 + Mandatory Access Control systems have the option of controlling
96198 + PaX flags on a per executable basis, choose the method supported
96199 + by your particular system.
96200 +
96201 + - "none": if your MAC system does not interact with PaX,
96202 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
96203 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
96204 +
96205 + NOTE: this option is for developers/integrators only.
96206 +
96207 + config PAX_NO_ACL_FLAGS
96208 + bool 'none'
96209 +
96210 + config PAX_HAVE_ACL_FLAGS
96211 + bool 'direct'
96212 +
96213 + config PAX_HOOK_ACL_FLAGS
96214 + bool 'hook'
96215 +endchoice
96216 +
96217 +endmenu
96218 +
96219 +menu "Non-executable pages"
96220 + depends on PAX
96221 +
96222 +config PAX_NOEXEC
96223 + bool "Enforce non-executable pages"
96224 + default y if GRKERNSEC_CONFIG_AUTO
96225 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
96226 + help
96227 + By design some architectures do not allow for protecting memory
96228 + pages against execution or even if they do, Linux does not make
96229 + use of this feature. In practice this means that if a page is
96230 + readable (such as the stack or heap) it is also executable.
96231 +
96232 + There is a well known exploit technique that makes use of this
96233 + fact and a common programming mistake where an attacker can
96234 + introduce code of his choice somewhere in the attacked program's
96235 + memory (typically the stack or the heap) and then execute it.
96236 +
96237 + If the attacked program was running with different (typically
96238 + higher) privileges than that of the attacker, then he can elevate
96239 + his own privilege level (e.g. get a root shell, write to files for
96240 + which he does not have write access to, etc).
96241 +
96242 + Enabling this option will let you choose from various features
96243 + that prevent the injection and execution of 'foreign' code in
96244 + a program.
96245 +
96246 + This will also break programs that rely on the old behaviour and
96247 + expect that dynamically allocated memory via the malloc() family
96248 + of functions is executable (which it is not). Notable examples
96249 + are the XFree86 4.x server, the java runtime and wine.
96250 +
96251 +config PAX_PAGEEXEC
96252 + bool "Paging based non-executable pages"
96253 + default y if GRKERNSEC_CONFIG_AUTO
96254 + 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)
96255 + select ARCH_TRACK_EXEC_LIMIT if X86_32
96256 + help
96257 + This implementation is based on the paging feature of the CPU.
96258 + On i386 without hardware non-executable bit support there is a
96259 + variable but usually low performance impact, however on Intel's
96260 + P4 core based CPUs it is very high so you should not enable this
96261 + for kernels meant to be used on such CPUs.
96262 +
96263 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
96264 + with hardware non-executable bit support there is no performance
96265 + impact, on ppc the impact is negligible.
96266 +
96267 + Note that several architectures require various emulations due to
96268 + badly designed userland ABIs, this will cause a performance impact
96269 + but will disappear as soon as userland is fixed. For example, ppc
96270 + userland MUST have been built with secure-plt by a recent toolchain.
96271 +
96272 +config PAX_SEGMEXEC
96273 + bool "Segmentation based non-executable pages"
96274 + default y if GRKERNSEC_CONFIG_AUTO
96275 + depends on PAX_NOEXEC && X86_32
96276 + help
96277 + This implementation is based on the segmentation feature of the
96278 + CPU and has a very small performance impact, however applications
96279 + will be limited to a 1.5 GB address space instead of the normal
96280 + 3 GB.
96281 +
96282 +config PAX_EMUTRAMP
96283 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
96284 + default y if PARISC
96285 + help
96286 + There are some programs and libraries that for one reason or
96287 + another attempt to execute special small code snippets from
96288 + non-executable memory pages. Most notable examples are the
96289 + signal handler return code generated by the kernel itself and
96290 + the GCC trampolines.
96291 +
96292 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
96293 + such programs will no longer work under your kernel.
96294 +
96295 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
96296 + utilities to enable trampoline emulation for the affected programs
96297 + yet still have the protection provided by the non-executable pages.
96298 +
96299 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
96300 + your system will not even boot.
96301 +
96302 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
96303 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
96304 + for the affected files.
96305 +
96306 + NOTE: enabling this feature *may* open up a loophole in the
96307 + protection provided by non-executable pages that an attacker
96308 + could abuse. Therefore the best solution is to not have any
96309 + files on your system that would require this option. This can
96310 + be achieved by not using libc5 (which relies on the kernel
96311 + signal handler return code) and not using or rewriting programs
96312 + that make use of the nested function implementation of GCC.
96313 + Skilled users can just fix GCC itself so that it implements
96314 + nested function calls in a way that does not interfere with PaX.
96315 +
96316 +config PAX_EMUSIGRT
96317 + bool "Automatically emulate sigreturn trampolines"
96318 + depends on PAX_EMUTRAMP && PARISC
96319 + default y
96320 + help
96321 + Enabling this option will have the kernel automatically detect
96322 + and emulate signal return trampolines executing on the stack
96323 + that would otherwise lead to task termination.
96324 +
96325 + This solution is intended as a temporary one for users with
96326 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
96327 + Modula-3 runtime, etc) or executables linked to such, basically
96328 + everything that does not specify its own SA_RESTORER function in
96329 + normal executable memory like glibc 2.1+ does.
96330 +
96331 + On parisc you MUST enable this option, otherwise your system will
96332 + not even boot.
96333 +
96334 + NOTE: this feature cannot be disabled on a per executable basis
96335 + and since it *does* open up a loophole in the protection provided
96336 + by non-executable pages, the best solution is to not have any
96337 + files on your system that would require this option.
96338 +
96339 +config PAX_MPROTECT
96340 + bool "Restrict mprotect()"
96341 + default y if GRKERNSEC_CONFIG_AUTO
96342 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
96343 + help
96344 + Enabling this option will prevent programs from
96345 + - changing the executable status of memory pages that were
96346 + not originally created as executable,
96347 + - making read-only executable pages writable again,
96348 + - creating executable pages from anonymous memory,
96349 + - making read-only-after-relocations (RELRO) data pages writable again.
96350 +
96351 + You should say Y here to complete the protection provided by
96352 + the enforcement of non-executable pages.
96353 +
96354 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
96355 + this feature on a per file basis.
96356 +
96357 +config PAX_MPROTECT_COMPAT
96358 + bool "Use legacy/compat protection demoting (read help)"
96359 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
96360 + depends on PAX_MPROTECT
96361 + help
96362 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
96363 + by sending the proper error code to the application. For some broken
96364 + userland, this can cause problems with Python or other applications. The
96365 + current implementation however allows for applications like clamav to
96366 + detect if JIT compilation/execution is allowed and to fall back gracefully
96367 + to an interpreter-based mode if it does not. While we encourage everyone
96368 + to use the current implementation as-is and push upstream to fix broken
96369 + userland (note that the RWX logging option can assist with this), in some
96370 + environments this may not be possible. Having to disable MPROTECT
96371 + completely on certain binaries reduces the security benefit of PaX,
96372 + so this option is provided for those environments to revert to the old
96373 + behavior.
96374 +
96375 +config PAX_ELFRELOCS
96376 + bool "Allow ELF text relocations (read help)"
96377 + depends on PAX_MPROTECT
96378 + default n
96379 + help
96380 + Non-executable pages and mprotect() restrictions are effective
96381 + in preventing the introduction of new executable code into an
96382 + attacked task's address space. There remain only two venues
96383 + for this kind of attack: if the attacker can execute already
96384 + existing code in the attacked task then he can either have it
96385 + create and mmap() a file containing his code or have it mmap()
96386 + an already existing ELF library that does not have position
96387 + independent code in it and use mprotect() on it to make it
96388 + writable and copy his code there. While protecting against
96389 + the former approach is beyond PaX, the latter can be prevented
96390 + by having only PIC ELF libraries on one's system (which do not
96391 + need to relocate their code). If you are sure this is your case,
96392 + as is the case with all modern Linux distributions, then leave
96393 + this option disabled. You should say 'n' here.
96394 +
96395 +config PAX_ETEXECRELOCS
96396 + bool "Allow ELF ET_EXEC text relocations"
96397 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
96398 + select PAX_ELFRELOCS
96399 + default y
96400 + help
96401 + On some architectures there are incorrectly created applications
96402 + that require text relocations and would not work without enabling
96403 + this option. If you are an alpha, ia64 or parisc user, you should
96404 + enable this option and disable it once you have made sure that
96405 + none of your applications need it.
96406 +
96407 +config PAX_EMUPLT
96408 + bool "Automatically emulate ELF PLT"
96409 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
96410 + default y
96411 + help
96412 + Enabling this option will have the kernel automatically detect
96413 + and emulate the Procedure Linkage Table entries in ELF files.
96414 + On some architectures such entries are in writable memory, and
96415 + become non-executable leading to task termination. Therefore
96416 + it is mandatory that you enable this option on alpha, parisc,
96417 + sparc and sparc64, otherwise your system would not even boot.
96418 +
96419 + NOTE: this feature *does* open up a loophole in the protection
96420 + provided by the non-executable pages, therefore the proper
96421 + solution is to modify the toolchain to produce a PLT that does
96422 + not need to be writable.
96423 +
96424 +config PAX_DLRESOLVE
96425 + bool 'Emulate old glibc resolver stub'
96426 + depends on PAX_EMUPLT && SPARC
96427 + default n
96428 + help
96429 + This option is needed if userland has an old glibc (before 2.4)
96430 + that puts a 'save' instruction into the runtime generated resolver
96431 + stub that needs special emulation.
96432 +
96433 +config PAX_KERNEXEC
96434 + bool "Enforce non-executable kernel pages"
96435 + 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))
96436 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
96437 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
96438 + select PAX_KERNEXEC_PLUGIN if X86_64
96439 + help
96440 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
96441 + that is, enabling this option will make it harder to inject
96442 + and execute 'foreign' code in kernel memory itself.
96443 +
96444 +choice
96445 + prompt "Return Address Instrumentation Method"
96446 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
96447 + depends on PAX_KERNEXEC_PLUGIN
96448 + help
96449 + Select the method used to instrument function pointer dereferences.
96450 + Note that binary modules cannot be instrumented by this approach.
96451 +
96452 + Note that the implementation requires a gcc with plugin support,
96453 + i.e., gcc 4.5 or newer. You may need to install the supporting
96454 + headers explicitly in addition to the normal gcc package.
96455 +
96456 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
96457 + bool "bts"
96458 + help
96459 + This method is compatible with binary only modules but has
96460 + a higher runtime overhead.
96461 +
96462 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
96463 + bool "or"
96464 + depends on !PARAVIRT
96465 + help
96466 + This method is incompatible with binary only modules but has
96467 + a lower runtime overhead.
96468 +endchoice
96469 +
96470 +config PAX_KERNEXEC_PLUGIN_METHOD
96471 + string
96472 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
96473 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
96474 + default ""
96475 +
96476 +config PAX_KERNEXEC_MODULE_TEXT
96477 + int "Minimum amount of memory reserved for module code"
96478 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
96479 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
96480 + depends on PAX_KERNEXEC && X86_32
96481 + help
96482 + Due to implementation details the kernel must reserve a fixed
96483 + amount of memory for runtime allocated code (such as modules)
96484 + at compile time that cannot be changed at runtime. Here you
96485 + can specify the minimum amount in MB that will be reserved.
96486 + Due to the same implementation details this size will always
96487 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
96488 + the actually available memory for runtime allocated code will
96489 + usually be more than this minimum.
96490 +
96491 + The default 4 MB should be enough for most users but if you have
96492 + an excessive number of modules (e.g., most distribution configs
96493 + compile many drivers as modules) or use huge modules such as
96494 + nvidia's kernel driver, you will need to adjust this amount.
96495 + A good rule of thumb is to look at your currently loaded kernel
96496 + modules and add up their sizes.
96497 +
96498 +endmenu
96499 +
96500 +menu "Address Space Layout Randomization"
96501 + depends on PAX
96502 +
96503 +config PAX_ASLR
96504 + bool "Address Space Layout Randomization"
96505 + default y if GRKERNSEC_CONFIG_AUTO
96506 + help
96507 + Many if not most exploit techniques rely on the knowledge of
96508 + certain addresses in the attacked program. The following options
96509 + will allow the kernel to apply a certain amount of randomization
96510 + to specific parts of the program thereby forcing an attacker to
96511 + guess them in most cases. Any failed guess will most likely crash
96512 + the attacked program which allows the kernel to detect such attempts
96513 + and react on them. PaX itself provides no reaction mechanisms,
96514 + instead it is strongly encouraged that you make use of Nergal's
96515 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
96516 + (http://www.grsecurity.net/) built-in crash detection features or
96517 + develop one yourself.
96518 +
96519 + By saying Y here you can choose to randomize the following areas:
96520 + - top of the task's kernel stack
96521 + - top of the task's userland stack
96522 + - base address for mmap() requests that do not specify one
96523 + (this includes all libraries)
96524 + - base address of the main executable
96525 +
96526 + It is strongly recommended to say Y here as address space layout
96527 + randomization has negligible impact on performance yet it provides
96528 + a very effective protection.
96529 +
96530 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
96531 + this feature on a per file basis.
96532 +
96533 +config PAX_RANDKSTACK
96534 + bool "Randomize kernel stack base"
96535 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
96536 + depends on X86_TSC && X86
96537 + help
96538 + By saying Y here the kernel will randomize every task's kernel
96539 + stack on every system call. This will not only force an attacker
96540 + to guess it but also prevent him from making use of possible
96541 + leaked information about it.
96542 +
96543 + Since the kernel stack is a rather scarce resource, randomization
96544 + may cause unexpected stack overflows, therefore you should very
96545 + carefully test your system. Note that once enabled in the kernel
96546 + configuration, this feature cannot be disabled on a per file basis.
96547 +
96548 +config PAX_RANDUSTACK
96549 + bool "Randomize user stack base"
96550 + default y if GRKERNSEC_CONFIG_AUTO
96551 + depends on PAX_ASLR
96552 + help
96553 + By saying Y here the kernel will randomize every task's userland
96554 + stack. The randomization is done in two steps where the second
96555 + one may apply a big amount of shift to the top of the stack and
96556 + cause problems for programs that want to use lots of memory (more
96557 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
96558 + For this reason the second step can be controlled by 'chpax' or
96559 + 'paxctl' on a per file basis.
96560 +
96561 +config PAX_RANDMMAP
96562 + bool "Randomize mmap() base"
96563 + default y if GRKERNSEC_CONFIG_AUTO
96564 + depends on PAX_ASLR
96565 + help
96566 + By saying Y here the kernel will use a randomized base address for
96567 + mmap() requests that do not specify one themselves. As a result
96568 + all dynamically loaded libraries will appear at random addresses
96569 + and therefore be harder to exploit by a technique where an attacker
96570 + attempts to execute library code for his purposes (e.g. spawn a
96571 + shell from an exploited program that is running at an elevated
96572 + privilege level).
96573 +
96574 + Furthermore, if a program is relinked as a dynamic ELF file, its
96575 + base address will be randomized as well, completing the full
96576 + randomization of the address space layout. Attacking such programs
96577 + becomes a guess game. You can find an example of doing this at
96578 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
96579 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
96580 +
96581 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
96582 + feature on a per file basis.
96583 +
96584 +endmenu
96585 +
96586 +menu "Miscellaneous hardening features"
96587 +
96588 +config PAX_MEMORY_SANITIZE
96589 + bool "Sanitize all freed memory"
96590 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
96591 + depends on !HIBERNATION
96592 + help
96593 + By saying Y here the kernel will erase memory pages and slab objects
96594 + as soon as they are freed. This in turn reduces the lifetime of data
96595 + stored in them, making it less likely that sensitive information such
96596 + as passwords, cryptographic secrets, etc stay in memory for too long.
96597 +
96598 + This is especially useful for programs whose runtime is short, long
96599 + lived processes and the kernel itself benefit from this as long as
96600 + they ensure timely freeing of memory that may hold sensitive
96601 + information.
96602 +
96603 + A nice side effect of the sanitization of slab objects is the
96604 + reduction of possible info leaks caused by padding bytes within the
96605 + leaky structures. Use-after-free bugs for structures containing
96606 + pointers can also be detected as dereferencing the sanitized pointer
96607 + will generate an access violation.
96608 +
96609 + The tradeoff is performance impact, on a single CPU system kernel
96610 + compilation sees a 3% slowdown, other systems and workloads may vary
96611 + and you are advised to test this feature on your expected workload
96612 + before deploying it.
96613 +
96614 + To reduce the performance penalty by sanitizing pages only, albeit
96615 + limiting the effectiveness of this feature at the same time, slab
96616 + sanitization can be disabled with the kernel commandline parameter
96617 + "pax_sanitize_slab=0".
96618 +
96619 + Note that this feature does not protect data stored in live pages,
96620 + e.g., process memory swapped to disk may stay there for a long time.
96621 +
96622 +config PAX_MEMORY_STACKLEAK
96623 + bool "Sanitize kernel stack"
96624 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
96625 + depends on X86
96626 + help
96627 + By saying Y here the kernel will erase the kernel stack before it
96628 + returns from a system call. This in turn reduces the information
96629 + that a kernel stack leak bug can reveal.
96630 +
96631 + Note that such a bug can still leak information that was put on
96632 + the stack by the current system call (the one eventually triggering
96633 + the bug) but traces of earlier system calls on the kernel stack
96634 + cannot leak anymore.
96635 +
96636 + The tradeoff is performance impact: on a single CPU system kernel
96637 + compilation sees a 1% slowdown, other systems and workloads may vary
96638 + and you are advised to test this feature on your expected workload
96639 + before deploying it.
96640 +
96641 + Note that the full feature requires a gcc with plugin support,
96642 + i.e., gcc 4.5 or newer. You may need to install the supporting
96643 + headers explicitly in addition to the normal gcc package. Using
96644 + older gcc versions means that functions with large enough stack
96645 + frames may leave uninitialized memory behind that may be exposed
96646 + to a later syscall leaking the stack.
96647 +
96648 +config PAX_MEMORY_STRUCTLEAK
96649 + bool "Forcibly initialize local variables copied to userland"
96650 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
96651 + help
96652 + By saying Y here the kernel will zero initialize some local
96653 + variables that are going to be copied to userland. This in
96654 + turn prevents unintended information leakage from the kernel
96655 + stack should later code forget to explicitly set all parts of
96656 + the copied variable.
96657 +
96658 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
96659 + at a much smaller coverage.
96660 +
96661 + Note that the implementation requires a gcc with plugin support,
96662 + i.e., gcc 4.5 or newer. You may need to install the supporting
96663 + headers explicitly in addition to the normal gcc package.
96664 +
96665 +config PAX_MEMORY_UDEREF
96666 + bool "Prevent invalid userland pointer dereference"
96667 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
96668 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
96669 + select PAX_PER_CPU_PGD if X86_64
96670 + help
96671 + By saying Y here the kernel will be prevented from dereferencing
96672 + userland pointers in contexts where the kernel expects only kernel
96673 + pointers. This is both a useful runtime debugging feature and a
96674 + security measure that prevents exploiting a class of kernel bugs.
96675 +
96676 + The tradeoff is that some virtualization solutions may experience
96677 + a huge slowdown and therefore you should not enable this feature
96678 + for kernels meant to run in such environments. Whether a given VM
96679 + solution is affected or not is best determined by simply trying it
96680 + out, the performance impact will be obvious right on boot as this
96681 + mechanism engages from very early on. A good rule of thumb is that
96682 + VMs running on CPUs without hardware virtualization support (i.e.,
96683 + the majority of IA-32 CPUs) will likely experience the slowdown.
96684 +
96685 + On X86_64 the kernel will make use of PCID support when available
96686 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
96687 + or performance impact. Pass pax_weakuderef on the kernel command
96688 + line to choose the latter.
96689 +
96690 +config PAX_REFCOUNT
96691 + bool "Prevent various kernel object reference counter overflows"
96692 + default y if GRKERNSEC_CONFIG_AUTO
96693 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || SPARC64 || X86)
96694 + help
96695 + By saying Y here the kernel will detect and prevent overflowing
96696 + various (but not all) kinds of object reference counters. Such
96697 + overflows can normally occur due to bugs only and are often, if
96698 + not always, exploitable.
96699 +
96700 + The tradeoff is that data structures protected by an overflowed
96701 + refcount will never be freed and therefore will leak memory. Note
96702 + that this leak also happens even without this protection but in
96703 + that case the overflow can eventually trigger the freeing of the
96704 + data structure while it is still being used elsewhere, resulting
96705 + in the exploitable situation that this feature prevents.
96706 +
96707 + Since this has a negligible performance impact, you should enable
96708 + this feature.
96709 +
96710 +config PAX_CONSTIFY_PLUGIN
96711 + bool "Automatically constify eligible structures"
96712 + default y
96713 + depends on !UML && PAX_KERNEXEC
96714 + help
96715 + By saying Y here the compiler will automatically constify a class
96716 + of types that contain only function pointers. This reduces the
96717 + kernel's attack surface and also produces a better memory layout.
96718 +
96719 + Note that the implementation requires a gcc with plugin support,
96720 + i.e., gcc 4.5 or newer. You may need to install the supporting
96721 + headers explicitly in addition to the normal gcc package.
96722 +
96723 + Note that if some code really has to modify constified variables
96724 + then the source code will have to be patched to allow it. Examples
96725 + can be found in PaX itself (the no_const attribute) and for some
96726 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
96727 +
96728 +config PAX_USERCOPY
96729 + bool "Harden heap object copies between kernel and userland"
96730 + default y if GRKERNSEC_CONFIG_AUTO
96731 + depends on ARM || IA64 || PPC || SPARC || X86
96732 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
96733 + select PAX_USERCOPY_SLABS
96734 + help
96735 + By saying Y here the kernel will enforce the size of heap objects
96736 + when they are copied in either direction between the kernel and
96737 + userland, even if only a part of the heap object is copied.
96738 +
96739 + Specifically, this checking prevents information leaking from the
96740 + kernel heap during kernel to userland copies (if the kernel heap
96741 + object is otherwise fully initialized) and prevents kernel heap
96742 + overflows during userland to kernel copies.
96743 +
96744 + Note that the current implementation provides the strictest bounds
96745 + checks for the SLUB allocator.
96746 +
96747 + Enabling this option also enables per-slab cache protection against
96748 + data in a given cache being copied into/out of via userland
96749 + accessors. Though the whitelist of regions will be reduced over
96750 + time, it notably protects important data structures like task structs.
96751 +
96752 + If frame pointers are enabled on x86, this option will also restrict
96753 + copies into and out of the kernel stack to local variables within a
96754 + single frame.
96755 +
96756 + Since this has a negligible performance impact, you should enable
96757 + this feature.
96758 +
96759 +config PAX_USERCOPY_DEBUG
96760 + bool
96761 + depends on X86 && PAX_USERCOPY
96762 + default n
96763 +
96764 +config PAX_SIZE_OVERFLOW
96765 + bool "Prevent various integer overflows in function size parameters"
96766 + default y if GRKERNSEC_CONFIG_AUTO
96767 + depends on X86
96768 + help
96769 + By saying Y here the kernel recomputes expressions of function
96770 + arguments marked by a size_overflow attribute with double integer
96771 + precision (DImode/TImode for 32/64 bit integer types).
96772 +
96773 + The recomputed argument is checked against TYPE_MAX and an event
96774 + is logged on overflow and the triggering process is killed.
96775 +
96776 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
96777 +
96778 + Note that the implementation requires a gcc with plugin support,
96779 + i.e., gcc 4.5 or newer. You may need to install the supporting
96780 + headers explicitly in addition to the normal gcc package.
96781 +
96782 +config PAX_LATENT_ENTROPY
96783 + bool "Generate some entropy during boot"
96784 + default y if GRKERNSEC_CONFIG_AUTO
96785 + help
96786 + By saying Y here the kernel will instrument early boot code to
96787 + extract some entropy from both original and artificially created
96788 + program state. This will help especially embedded systems where
96789 + there is little 'natural' source of entropy normally. The cost
96790 + is some slowdown of the boot process.
96791 +
96792 + When pax_extra_latent_entropy is passed on the kernel command line,
96793 + entropy will be extracted from up to the first 4GB of RAM while the
96794 + runtime memory allocator is being initialized. This costs even more
96795 + slowdown of the boot process.
96796 +
96797 + Note that the implementation requires a gcc with plugin support,
96798 + i.e., gcc 4.5 or newer. You may need to install the supporting
96799 + headers explicitly in addition to the normal gcc package.
96800 +
96801 + Note that entropy extracted this way is not cryptographically
96802 + secure!
96803 +
96804 +endmenu
96805 +
96806 +endmenu
96807 +
96808 +source grsecurity/Kconfig
96809 +
96810 +endmenu
96811 +
96812 +endmenu
96813 +
96814 source security/keys/Kconfig
96815
96816 config SECURITY_DMESG_RESTRICT
96817 @@ -103,7 +1056,7 @@ config INTEL_TXT
96818 config LSM_MMAP_MIN_ADDR
96819 int "Low address space for LSM to protect from user allocation"
96820 depends on SECURITY && SECURITY_SELINUX
96821 - default 32768 if ARM
96822 + default 32768 if ALPHA || ARM || PARISC || SPARC32
96823 default 65536
96824 help
96825 This is the portion of low virtual memory which should be protected
96826 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
96827 index 9b9013b..51ebf96 100644
96828 --- a/security/apparmor/Kconfig
96829 +++ b/security/apparmor/Kconfig
96830 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
96831 boot.
96832
96833 If you are unsure how to answer this question, answer 1.
96834 +
96835 +config SECURITY_APPARMOR_COMPAT_24
96836 + bool "Enable AppArmor 2.4 compatability"
96837 + depends on SECURITY_APPARMOR
96838 + default y
96839 + help
96840 + This option enables compatability with AppArmor 2.4. It is
96841 + recommended if compatability with older versions of AppArmor
96842 + is desired.
96843 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
96844 index 16c15ec..42b7c9f 100644
96845 --- a/security/apparmor/apparmorfs.c
96846 +++ b/security/apparmor/apparmorfs.c
96847 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
96848 .release = single_release,
96849 };
96850
96851 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
96852 +/**
96853 + * __next_namespace - find the next namespace to list
96854 + * @root: root namespace to stop search at (NOT NULL)
96855 + * @ns: current ns position (NOT NULL)
96856 + *
96857 + * Find the next namespace from @ns under @root and handle all locking needed
96858 + * while switching current namespace.
96859 + *
96860 + * Returns: next namespace or NULL if at last namespace under @root
96861 + * NOTE: will not unlock root->lock
96862 + */
96863 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
96864 + struct aa_namespace *ns)
96865 +{
96866 + struct aa_namespace *parent;
96867 +
96868 + /* is next namespace a child */
96869 + if (!list_empty(&ns->sub_ns)) {
96870 + struct aa_namespace *next;
96871 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
96872 + read_lock(&next->lock);
96873 + return next;
96874 + }
96875 +
96876 + /* check if the next ns is a sibling, parent, gp, .. */
96877 + parent = ns->parent;
96878 + while (parent) {
96879 + read_unlock(&ns->lock);
96880 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
96881 + read_lock(&ns->lock);
96882 + return ns;
96883 + }
96884 + if (parent == root)
96885 + return NULL;
96886 + ns = parent;
96887 + parent = parent->parent;
96888 + }
96889 +
96890 + return NULL;
96891 +}
96892 +
96893 +/**
96894 + * __first_profile - find the first profile in a namespace
96895 + * @root: namespace that is root of profiles being displayed (NOT NULL)
96896 + * @ns: namespace to start in (NOT NULL)
96897 + *
96898 + * Returns: unrefcounted profile or NULL if no profile
96899 + */
96900 +static struct aa_profile *__first_profile(struct aa_namespace *root,
96901 + struct aa_namespace *ns)
96902 +{
96903 + for ( ; ns; ns = __next_namespace(root, ns)) {
96904 + if (!list_empty(&ns->base.profiles))
96905 + return list_first_entry(&ns->base.profiles,
96906 + struct aa_profile, base.list);
96907 + }
96908 + return NULL;
96909 +}
96910 +
96911 +/**
96912 + * __next_profile - step to the next profile in a profile tree
96913 + * @profile: current profile in tree (NOT NULL)
96914 + *
96915 + * Perform a depth first taversal on the profile tree in a namespace
96916 + *
96917 + * Returns: next profile or NULL if done
96918 + * Requires: profile->ns.lock to be held
96919 + */
96920 +static struct aa_profile *__next_profile(struct aa_profile *p)
96921 +{
96922 + struct aa_profile *parent;
96923 + struct aa_namespace *ns = p->ns;
96924 +
96925 + /* is next profile a child */
96926 + if (!list_empty(&p->base.profiles))
96927 + return list_first_entry(&p->base.profiles, typeof(*p),
96928 + base.list);
96929 +
96930 + /* is next profile a sibling, parent sibling, gp, subling, .. */
96931 + parent = p->parent;
96932 + while (parent) {
96933 + list_for_each_entry_continue(p, &parent->base.profiles,
96934 + base.list)
96935 + return p;
96936 + p = parent;
96937 + parent = parent->parent;
96938 + }
96939 +
96940 + /* is next another profile in the namespace */
96941 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
96942 + return p;
96943 +
96944 + return NULL;
96945 +}
96946 +
96947 +/**
96948 + * next_profile - step to the next profile in where ever it may be
96949 + * @root: root namespace (NOT NULL)
96950 + * @profile: current profile (NOT NULL)
96951 + *
96952 + * Returns: next profile or NULL if there isn't one
96953 + */
96954 +static struct aa_profile *next_profile(struct aa_namespace *root,
96955 + struct aa_profile *profile)
96956 +{
96957 + struct aa_profile *next = __next_profile(profile);
96958 + if (next)
96959 + return next;
96960 +
96961 + /* finished all profiles in namespace move to next namespace */
96962 + return __first_profile(root, __next_namespace(root, profile->ns));
96963 +}
96964 +
96965 +/**
96966 + * p_start - start a depth first traversal of profile tree
96967 + * @f: seq_file to fill
96968 + * @pos: current position
96969 + *
96970 + * Returns: first profile under current namespace or NULL if none found
96971 + *
96972 + * acquires first ns->lock
96973 + */
96974 +static void *p_start(struct seq_file *f, loff_t *pos)
96975 + __acquires(root->lock)
96976 +{
96977 + struct aa_profile *profile = NULL;
96978 + struct aa_namespace *root = aa_current_profile()->ns;
96979 + loff_t l = *pos;
96980 + f->private = aa_get_namespace(root);
96981 +
96982 +
96983 + /* find the first profile */
96984 + read_lock(&root->lock);
96985 + profile = __first_profile(root, root);
96986 +
96987 + /* skip to position */
96988 + for (; profile && l > 0; l--)
96989 + profile = next_profile(root, profile);
96990 +
96991 + return profile;
96992 +}
96993 +
96994 +/**
96995 + * p_next - read the next profile entry
96996 + * @f: seq_file to fill
96997 + * @p: profile previously returned
96998 + * @pos: current position
96999 + *
97000 + * Returns: next profile after @p or NULL if none
97001 + *
97002 + * may acquire/release locks in namespace tree as necessary
97003 + */
97004 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
97005 +{
97006 + struct aa_profile *profile = p;
97007 + struct aa_namespace *root = f->private;
97008 + (*pos)++;
97009 +
97010 + return next_profile(root, profile);
97011 +}
97012 +
97013 +/**
97014 + * p_stop - stop depth first traversal
97015 + * @f: seq_file we are filling
97016 + * @p: the last profile writen
97017 + *
97018 + * Release all locking done by p_start/p_next on namespace tree
97019 + */
97020 +static void p_stop(struct seq_file *f, void *p)
97021 + __releases(root->lock)
97022 +{
97023 + struct aa_profile *profile = p;
97024 + struct aa_namespace *root = f->private, *ns;
97025 +
97026 + if (profile) {
97027 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
97028 + read_unlock(&ns->lock);
97029 + }
97030 + read_unlock(&root->lock);
97031 + aa_put_namespace(root);
97032 +}
97033 +
97034 +/**
97035 + * seq_show_profile - show a profile entry
97036 + * @f: seq_file to file
97037 + * @p: current position (profile) (NOT NULL)
97038 + *
97039 + * Returns: error on failure
97040 + */
97041 +static int seq_show_profile(struct seq_file *f, void *p)
97042 +{
97043 + struct aa_profile *profile = (struct aa_profile *)p;
97044 + struct aa_namespace *root = f->private;
97045 +
97046 + if (profile->ns != root)
97047 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
97048 + seq_printf(f, "%s (%s)\n", profile->base.hname,
97049 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
97050 +
97051 + return 0;
97052 +}
97053 +
97054 +static const struct seq_operations aa_fs_profiles_op = {
97055 + .start = p_start,
97056 + .next = p_next,
97057 + .stop = p_stop,
97058 + .show = seq_show_profile,
97059 +};
97060 +
97061 +static int profiles_open(struct inode *inode, struct file *file)
97062 +{
97063 + return seq_open(file, &aa_fs_profiles_op);
97064 +}
97065 +
97066 +static int profiles_release(struct inode *inode, struct file *file)
97067 +{
97068 + return seq_release(inode, file);
97069 +}
97070 +
97071 +const struct file_operations aa_fs_profiles_fops = {
97072 + .open = profiles_open,
97073 + .read = seq_read,
97074 + .llseek = seq_lseek,
97075 + .release = profiles_release,
97076 +};
97077 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
97078 +
97079 /** Base file system setup **/
97080
97081 static struct aa_fs_entry aa_fs_entry_file[] = {
97082 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
97083 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
97084 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
97085 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
97086 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
97087 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
97088 +#endif
97089 AA_FS_DIR("features", aa_fs_entry_features),
97090 { }
97091 };
97092 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
97093 index b21830e..a7d1a17 100644
97094 --- a/security/apparmor/lsm.c
97095 +++ b/security/apparmor/lsm.c
97096 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
97097 return error;
97098 }
97099
97100 -static struct security_operations apparmor_ops = {
97101 +static struct security_operations apparmor_ops __read_only = {
97102 .name = "apparmor",
97103
97104 .ptrace_access_check = apparmor_ptrace_access_check,
97105 diff --git a/security/commoncap.c b/security/commoncap.c
97106 index c44b6fe..932df30 100644
97107 --- a/security/commoncap.c
97108 +++ b/security/commoncap.c
97109 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
97110 return 0;
97111 }
97112
97113 +/* returns:
97114 + 1 for suid privilege
97115 + 2 for sgid privilege
97116 + 3 for fscap privilege
97117 +*/
97118 +int is_privileged_binary(const struct dentry *dentry)
97119 +{
97120 + struct cpu_vfs_cap_data capdata;
97121 + struct inode *inode = dentry->d_inode;
97122 +
97123 + if (!inode || S_ISDIR(inode->i_mode))
97124 + return 0;
97125 +
97126 + if (inode->i_mode & S_ISUID)
97127 + return 1;
97128 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
97129 + return 2;
97130 +
97131 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
97132 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
97133 + return 3;
97134 + }
97135 +
97136 + return 0;
97137 +}
97138 +
97139 /*
97140 * Attempt to get the on-exec apply capability sets for an executable file from
97141 * its xattrs and, if present, apply them to the proposed credentials being
97142 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
97143 const struct cred *cred = current_cred();
97144 kuid_t root_uid = make_kuid(cred->user_ns, 0);
97145
97146 + if (gr_acl_enable_at_secure())
97147 + return 1;
97148 +
97149 if (!uid_eq(cred->uid, root_uid)) {
97150 if (bprm->cap_effective)
97151 return 1;
97152 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
97153 index a41c9c1..83da6dd 100644
97154 --- a/security/integrity/ima/ima.h
97155 +++ b/security/integrity/ima/ima.h
97156 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
97157 extern spinlock_t ima_queue_lock;
97158
97159 struct ima_h_table {
97160 - atomic_long_t len; /* number of stored measurements in the list */
97161 - atomic_long_t violations;
97162 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
97163 + atomic_long_unchecked_t violations;
97164 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
97165 };
97166 extern struct ima_h_table ima_htable;
97167 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
97168 index 1c03e8f1..398a941 100644
97169 --- a/security/integrity/ima/ima_api.c
97170 +++ b/security/integrity/ima/ima_api.c
97171 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
97172 int result;
97173
97174 /* can overflow, only indicator */
97175 - atomic_long_inc(&ima_htable.violations);
97176 + atomic_long_inc_unchecked(&ima_htable.violations);
97177
97178 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
97179 if (!entry) {
97180 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
97181 index 38477c9..87a60c7 100644
97182 --- a/security/integrity/ima/ima_fs.c
97183 +++ b/security/integrity/ima/ima_fs.c
97184 @@ -28,12 +28,12 @@
97185 static int valid_policy = 1;
97186 #define TMPBUFLEN 12
97187 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
97188 - loff_t *ppos, atomic_long_t *val)
97189 + loff_t *ppos, atomic_long_unchecked_t *val)
97190 {
97191 char tmpbuf[TMPBUFLEN];
97192 ssize_t len;
97193
97194 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
97195 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
97196 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
97197 }
97198
97199 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
97200 index ff63fe0..809cd96 100644
97201 --- a/security/integrity/ima/ima_queue.c
97202 +++ b/security/integrity/ima/ima_queue.c
97203 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
97204 INIT_LIST_HEAD(&qe->later);
97205 list_add_tail_rcu(&qe->later, &ima_measurements);
97206
97207 - atomic_long_inc(&ima_htable.len);
97208 + atomic_long_inc_unchecked(&ima_htable.len);
97209 key = ima_hash_key(entry->digest);
97210 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
97211 return 0;
97212 diff --git a/security/keys/compat.c b/security/keys/compat.c
97213 index d65fa7f..cbfe366 100644
97214 --- a/security/keys/compat.c
97215 +++ b/security/keys/compat.c
97216 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
97217 if (ret == 0)
97218 goto no_payload_free;
97219
97220 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
97221 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
97222 err:
97223 if (iov != iovstack)
97224 kfree(iov);
97225 diff --git a/security/keys/internal.h b/security/keys/internal.h
97226 index d4f1468..cc52f92 100644
97227 --- a/security/keys/internal.h
97228 +++ b/security/keys/internal.h
97229 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
97230 extern long keyctl_invalidate_key(key_serial_t);
97231
97232 extern long keyctl_instantiate_key_common(key_serial_t,
97233 - const struct iovec *,
97234 + const struct iovec __user *,
97235 unsigned, size_t, key_serial_t);
97236
97237 /*
97238 diff --git a/security/keys/key.c b/security/keys/key.c
97239 index 8fb7c7b..ba3610d 100644
97240 --- a/security/keys/key.c
97241 +++ b/security/keys/key.c
97242 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
97243
97244 atomic_set(&key->usage, 1);
97245 init_rwsem(&key->sem);
97246 - lockdep_set_class(&key->sem, &type->lock_class);
97247 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
97248 key->type = type;
97249 key->user = user;
97250 key->quotalen = quotalen;
97251 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
97252 struct key_type *p;
97253 int ret;
97254
97255 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
97256 + pax_open_kernel();
97257 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
97258 + pax_close_kernel();
97259
97260 ret = -EEXIST;
97261 down_write(&key_types_sem);
97262 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
97263 }
97264
97265 /* store the type */
97266 - list_add(&ktype->link, &key_types_list);
97267 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
97268
97269 pr_notice("Key type %s registered\n", ktype->name);
97270 ret = 0;
97271 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
97272 void unregister_key_type(struct key_type *ktype)
97273 {
97274 down_write(&key_types_sem);
97275 - list_del_init(&ktype->link);
97276 + pax_list_del_init((struct list_head *)&ktype->link);
97277 downgrade_write(&key_types_sem);
97278 key_gc_keytype(ktype);
97279 pr_notice("Key type %s unregistered\n", ktype->name);
97280 @@ -1084,10 +1086,10 @@ void __init key_init(void)
97281 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
97282
97283 /* add the special key types */
97284 - list_add_tail(&key_type_keyring.link, &key_types_list);
97285 - list_add_tail(&key_type_dead.link, &key_types_list);
97286 - list_add_tail(&key_type_user.link, &key_types_list);
97287 - list_add_tail(&key_type_logon.link, &key_types_list);
97288 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
97289 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
97290 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
97291 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
97292
97293 /* record the root user tracking */
97294 rb_link_node(&root_key_user.node,
97295 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
97296 index 33cfd27..842fc5a 100644
97297 --- a/security/keys/keyctl.c
97298 +++ b/security/keys/keyctl.c
97299 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
97300 /*
97301 * Copy the iovec data from userspace
97302 */
97303 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
97304 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
97305 unsigned ioc)
97306 {
97307 for (; ioc > 0; ioc--) {
97308 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
97309 * If successful, 0 will be returned.
97310 */
97311 long keyctl_instantiate_key_common(key_serial_t id,
97312 - const struct iovec *payload_iov,
97313 + const struct iovec __user *payload_iov,
97314 unsigned ioc,
97315 size_t plen,
97316 key_serial_t ringid)
97317 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
97318 [0].iov_len = plen
97319 };
97320
97321 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
97322 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
97323 }
97324
97325 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
97326 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
97327 if (ret == 0)
97328 goto no_payload_free;
97329
97330 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
97331 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
97332 err:
97333 if (iov != iovstack)
97334 kfree(iov);
97335 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
97336 index 6ece7f2..ecdb55c 100644
97337 --- a/security/keys/keyring.c
97338 +++ b/security/keys/keyring.c
97339 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
97340 ret = -EFAULT;
97341
97342 for (loop = 0; loop < klist->nkeys; loop++) {
97343 + key_serial_t serial;
97344 key = rcu_deref_link_locked(klist, loop,
97345 keyring);
97346 + serial = key->serial;
97347
97348 tmp = sizeof(key_serial_t);
97349 if (tmp > buflen)
97350 tmp = buflen;
97351
97352 - if (copy_to_user(buffer,
97353 - &key->serial,
97354 - tmp) != 0)
97355 + if (copy_to_user(buffer, &serial, tmp))
97356 goto error;
97357
97358 buflen -= tmp;
97359 diff --git a/security/min_addr.c b/security/min_addr.c
97360 index f728728..6457a0c 100644
97361 --- a/security/min_addr.c
97362 +++ b/security/min_addr.c
97363 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
97364 */
97365 static void update_mmap_min_addr(void)
97366 {
97367 +#ifndef SPARC
97368 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
97369 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
97370 mmap_min_addr = dac_mmap_min_addr;
97371 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
97372 #else
97373 mmap_min_addr = dac_mmap_min_addr;
97374 #endif
97375 +#endif
97376 }
97377
97378 /*
97379 diff --git a/security/security.c b/security/security.c
97380 index a3dce87..9ca1435 100644
97381 --- a/security/security.c
97382 +++ b/security/security.c
97383 @@ -20,6 +20,7 @@
97384 #include <linux/ima.h>
97385 #include <linux/evm.h>
97386 #include <linux/fsnotify.h>
97387 +#include <linux/mm.h>
97388 #include <linux/mman.h>
97389 #include <linux/mount.h>
97390 #include <linux/personality.h>
97391 @@ -32,8 +33,8 @@
97392 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
97393 CONFIG_DEFAULT_SECURITY;
97394
97395 -static struct security_operations *security_ops;
97396 -static struct security_operations default_security_ops = {
97397 +static struct security_operations *security_ops __read_only;
97398 +static struct security_operations default_security_ops __read_only = {
97399 .name = "default",
97400 };
97401
97402 @@ -74,7 +75,9 @@ int __init security_init(void)
97403
97404 void reset_security_ops(void)
97405 {
97406 + pax_open_kernel();
97407 security_ops = &default_security_ops;
97408 + pax_close_kernel();
97409 }
97410
97411 /* Save user chosen LSM */
97412 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
97413 index 5c6f2cd..b4f945c 100644
97414 --- a/security/selinux/hooks.c
97415 +++ b/security/selinux/hooks.c
97416 @@ -96,8 +96,6 @@
97417
97418 #define NUM_SEL_MNT_OPTS 5
97419
97420 -extern struct security_operations *security_ops;
97421 -
97422 /* SECMARK reference count */
97423 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
97424
97425 @@ -5529,7 +5527,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
97426
97427 #endif
97428
97429 -static struct security_operations selinux_ops = {
97430 +static struct security_operations selinux_ops __read_only = {
97431 .name = "selinux",
97432
97433 .ptrace_access_check = selinux_ptrace_access_check,
97434 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
97435 index 65f67cb..3f141ef 100644
97436 --- a/security/selinux/include/xfrm.h
97437 +++ b/security/selinux/include/xfrm.h
97438 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
97439
97440 static inline void selinux_xfrm_notify_policyload(void)
97441 {
97442 - atomic_inc(&flow_cache_genid);
97443 + atomic_inc_unchecked(&flow_cache_genid);
97444 rt_genid_bump(&init_net);
97445 }
97446 #else
97447 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
97448 index d52c780..6431349 100644
97449 --- a/security/smack/smack_lsm.c
97450 +++ b/security/smack/smack_lsm.c
97451 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
97452 return 0;
97453 }
97454
97455 -struct security_operations smack_ops = {
97456 +struct security_operations smack_ops __read_only = {
97457 .name = "smack",
97458
97459 .ptrace_access_check = smack_ptrace_access_check,
97460 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
97461 index 390c646..f2f8db3 100644
97462 --- a/security/tomoyo/mount.c
97463 +++ b/security/tomoyo/mount.c
97464 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
97465 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
97466 need_dev = -1; /* dev_name is a directory */
97467 } else {
97468 + if (!capable(CAP_SYS_ADMIN)) {
97469 + error = -EPERM;
97470 + goto out;
97471 + }
97472 fstype = get_fs_type(type);
97473 if (!fstype) {
97474 error = -ENODEV;
97475 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
97476 index f0b756e..b129202 100644
97477 --- a/security/tomoyo/tomoyo.c
97478 +++ b/security/tomoyo/tomoyo.c
97479 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
97480 * tomoyo_security_ops is a "struct security_operations" which is used for
97481 * registering TOMOYO.
97482 */
97483 -static struct security_operations tomoyo_security_ops = {
97484 +static struct security_operations tomoyo_security_ops __read_only = {
97485 .name = "tomoyo",
97486 .cred_alloc_blank = tomoyo_cred_alloc_blank,
97487 .cred_prepare = tomoyo_cred_prepare,
97488 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
97489 index 20ef514..4182bed 100644
97490 --- a/security/yama/Kconfig
97491 +++ b/security/yama/Kconfig
97492 @@ -1,6 +1,6 @@
97493 config SECURITY_YAMA
97494 bool "Yama support"
97495 - depends on SECURITY
97496 + depends on SECURITY && !GRKERNSEC
97497 select SECURITYFS
97498 select SECURITY_PATH
97499 default n
97500 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
97501 index 13c88fbc..f8c115e 100644
97502 --- a/security/yama/yama_lsm.c
97503 +++ b/security/yama/yama_lsm.c
97504 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
97505 }
97506
97507 #ifndef CONFIG_SECURITY_YAMA_STACKED
97508 -static struct security_operations yama_ops = {
97509 +static struct security_operations yama_ops __read_only = {
97510 .name = "yama",
97511
97512 .ptrace_access_check = yama_ptrace_access_check,
97513 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
97514 #endif
97515
97516 #ifdef CONFIG_SYSCTL
97517 +static int zero __read_only;
97518 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
97519 +
97520 static int yama_dointvec_minmax(struct ctl_table *table, int write,
97521 void __user *buffer, size_t *lenp, loff_t *ppos)
97522 {
97523 - int rc;
97524 + ctl_table_no_const yama_table;
97525
97526 if (write && !capable(CAP_SYS_PTRACE))
97527 return -EPERM;
97528
97529 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
97530 - if (rc)
97531 - return rc;
97532 -
97533 + yama_table = *table;
97534 /* Lock the max value if it ever gets set. */
97535 - if (write && *(int *)table->data == *(int *)table->extra2)
97536 - table->extra1 = table->extra2;
97537 -
97538 - return rc;
97539 + if (ptrace_scope == max_scope)
97540 + yama_table.extra1 = &max_scope;
97541 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
97542 }
97543
97544 -static int zero;
97545 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
97546 -
97547 struct ctl_path yama_sysctl_path[] = {
97548 { .procname = "kernel", },
97549 { .procname = "yama", },
97550 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
97551 index 4cedc69..e59d8a3 100644
97552 --- a/sound/aoa/codecs/onyx.c
97553 +++ b/sound/aoa/codecs/onyx.c
97554 @@ -54,7 +54,7 @@ struct onyx {
97555 spdif_locked:1,
97556 analog_locked:1,
97557 original_mute:2;
97558 - int open_count;
97559 + local_t open_count;
97560 struct codec_info *codec_info;
97561
97562 /* mutex serializes concurrent access to the device
97563 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
97564 struct onyx *onyx = cii->codec_data;
97565
97566 mutex_lock(&onyx->mutex);
97567 - onyx->open_count++;
97568 + local_inc(&onyx->open_count);
97569 mutex_unlock(&onyx->mutex);
97570
97571 return 0;
97572 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
97573 struct onyx *onyx = cii->codec_data;
97574
97575 mutex_lock(&onyx->mutex);
97576 - onyx->open_count--;
97577 - if (!onyx->open_count)
97578 + if (local_dec_and_test(&onyx->open_count))
97579 onyx->spdif_locked = onyx->analog_locked = 0;
97580 mutex_unlock(&onyx->mutex);
97581
97582 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
97583 index ffd2025..df062c9 100644
97584 --- a/sound/aoa/codecs/onyx.h
97585 +++ b/sound/aoa/codecs/onyx.h
97586 @@ -11,6 +11,7 @@
97587 #include <linux/i2c.h>
97588 #include <asm/pmac_low_i2c.h>
97589 #include <asm/prom.h>
97590 +#include <asm/local.h>
97591
97592 /* PCM3052 register definitions */
97593
97594 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
97595 index 4c1cc51..16040040 100644
97596 --- a/sound/core/oss/pcm_oss.c
97597 +++ b/sound/core/oss/pcm_oss.c
97598 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
97599 if (in_kernel) {
97600 mm_segment_t fs;
97601 fs = snd_enter_user();
97602 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
97603 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
97604 snd_leave_user(fs);
97605 } else {
97606 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
97607 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
97608 }
97609 if (ret != -EPIPE && ret != -ESTRPIPE)
97610 break;
97611 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
97612 if (in_kernel) {
97613 mm_segment_t fs;
97614 fs = snd_enter_user();
97615 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
97616 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
97617 snd_leave_user(fs);
97618 } else {
97619 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
97620 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
97621 }
97622 if (ret == -EPIPE) {
97623 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
97624 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
97625 struct snd_pcm_plugin_channel *channels;
97626 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
97627 if (!in_kernel) {
97628 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
97629 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
97630 return -EFAULT;
97631 buf = runtime->oss.buffer;
97632 }
97633 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
97634 }
97635 } else {
97636 tmp = snd_pcm_oss_write2(substream,
97637 - (const char __force *)buf,
97638 + (const char __force_kernel *)buf,
97639 runtime->oss.period_bytes, 0);
97640 if (tmp <= 0)
97641 goto err;
97642 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
97643 struct snd_pcm_runtime *runtime = substream->runtime;
97644 snd_pcm_sframes_t frames, frames1;
97645 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
97646 - char __user *final_dst = (char __force __user *)buf;
97647 + char __user *final_dst = (char __force_user *)buf;
97648 if (runtime->oss.plugin_first) {
97649 struct snd_pcm_plugin_channel *channels;
97650 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
97651 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
97652 xfer += tmp;
97653 runtime->oss.buffer_used -= tmp;
97654 } else {
97655 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
97656 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
97657 runtime->oss.period_bytes, 0);
97658 if (tmp <= 0)
97659 goto err;
97660 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
97661 size1);
97662 size1 /= runtime->channels; /* frames */
97663 fs = snd_enter_user();
97664 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
97665 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
97666 snd_leave_user(fs);
97667 }
97668 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
97669 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
97670 index af49721..e85058e 100644
97671 --- a/sound/core/pcm_compat.c
97672 +++ b/sound/core/pcm_compat.c
97673 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
97674 int err;
97675
97676 fs = snd_enter_user();
97677 - err = snd_pcm_delay(substream, &delay);
97678 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
97679 snd_leave_user(fs);
97680 if (err < 0)
97681 return err;
97682 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
97683 index f928181..33fb83d 100644
97684 --- a/sound/core/pcm_native.c
97685 +++ b/sound/core/pcm_native.c
97686 @@ -2819,11 +2819,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
97687 switch (substream->stream) {
97688 case SNDRV_PCM_STREAM_PLAYBACK:
97689 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
97690 - (void __user *)arg);
97691 + (void __force_user *)arg);
97692 break;
97693 case SNDRV_PCM_STREAM_CAPTURE:
97694 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
97695 - (void __user *)arg);
97696 + (void __force_user *)arg);
97697 break;
97698 default:
97699 result = -EINVAL;
97700 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
97701 index 040c60e..989a19a 100644
97702 --- a/sound/core/seq/seq_device.c
97703 +++ b/sound/core/seq/seq_device.c
97704 @@ -64,7 +64,7 @@ struct ops_list {
97705 int argsize; /* argument size */
97706
97707 /* operators */
97708 - struct snd_seq_dev_ops ops;
97709 + struct snd_seq_dev_ops *ops;
97710
97711 /* registered devices */
97712 struct list_head dev_list; /* list of devices */
97713 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
97714
97715 mutex_lock(&ops->reg_mutex);
97716 /* copy driver operators */
97717 - ops->ops = *entry;
97718 + ops->ops = entry;
97719 ops->driver |= DRIVER_LOADED;
97720 ops->argsize = argsize;
97721
97722 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
97723 dev->name, ops->id, ops->argsize, dev->argsize);
97724 return -EINVAL;
97725 }
97726 - if (ops->ops.init_device(dev) >= 0) {
97727 + if (ops->ops->init_device(dev) >= 0) {
97728 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
97729 ops->num_init_devices++;
97730 } else {
97731 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
97732 dev->name, ops->id, ops->argsize, dev->argsize);
97733 return -EINVAL;
97734 }
97735 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
97736 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
97737 dev->status = SNDRV_SEQ_DEVICE_FREE;
97738 dev->driver_data = NULL;
97739 ops->num_init_devices--;
97740 diff --git a/sound/core/sound.c b/sound/core/sound.c
97741 index f002bd9..c462985 100644
97742 --- a/sound/core/sound.c
97743 +++ b/sound/core/sound.c
97744 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
97745 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
97746 default: return;
97747 }
97748 - request_module(str);
97749 + request_module("%s", str);
97750 }
97751
97752 #endif /* modular kernel */
97753 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
97754 index 4e0dd22..7a1f32c 100644
97755 --- a/sound/drivers/mts64.c
97756 +++ b/sound/drivers/mts64.c
97757 @@ -29,6 +29,7 @@
97758 #include <sound/initval.h>
97759 #include <sound/rawmidi.h>
97760 #include <sound/control.h>
97761 +#include <asm/local.h>
97762
97763 #define CARD_NAME "Miditerminal 4140"
97764 #define DRIVER_NAME "MTS64"
97765 @@ -67,7 +68,7 @@ struct mts64 {
97766 struct pardevice *pardev;
97767 int pardev_claimed;
97768
97769 - int open_count;
97770 + local_t open_count;
97771 int current_midi_output_port;
97772 int current_midi_input_port;
97773 u8 mode[MTS64_NUM_INPUT_PORTS];
97774 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
97775 {
97776 struct mts64 *mts = substream->rmidi->private_data;
97777
97778 - if (mts->open_count == 0) {
97779 + if (local_read(&mts->open_count) == 0) {
97780 /* We don't need a spinlock here, because this is just called
97781 if the device has not been opened before.
97782 So there aren't any IRQs from the device */
97783 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
97784
97785 msleep(50);
97786 }
97787 - ++(mts->open_count);
97788 + local_inc(&mts->open_count);
97789
97790 return 0;
97791 }
97792 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
97793 struct mts64 *mts = substream->rmidi->private_data;
97794 unsigned long flags;
97795
97796 - --(mts->open_count);
97797 - if (mts->open_count == 0) {
97798 + if (local_dec_return(&mts->open_count) == 0) {
97799 /* We need the spinlock_irqsave here because we can still
97800 have IRQs at this point */
97801 spin_lock_irqsave(&mts->lock, flags);
97802 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
97803
97804 msleep(500);
97805
97806 - } else if (mts->open_count < 0)
97807 - mts->open_count = 0;
97808 + } else if (local_read(&mts->open_count) < 0)
97809 + local_set(&mts->open_count, 0);
97810
97811 return 0;
97812 }
97813 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
97814 index b953fb4..1999c01 100644
97815 --- a/sound/drivers/opl4/opl4_lib.c
97816 +++ b/sound/drivers/opl4/opl4_lib.c
97817 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
97818 MODULE_DESCRIPTION("OPL4 driver");
97819 MODULE_LICENSE("GPL");
97820
97821 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
97822 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
97823 {
97824 int timeout = 10;
97825 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
97826 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
97827 index 991018d..8984740 100644
97828 --- a/sound/drivers/portman2x4.c
97829 +++ b/sound/drivers/portman2x4.c
97830 @@ -48,6 +48,7 @@
97831 #include <sound/initval.h>
97832 #include <sound/rawmidi.h>
97833 #include <sound/control.h>
97834 +#include <asm/local.h>
97835
97836 #define CARD_NAME "Portman 2x4"
97837 #define DRIVER_NAME "portman"
97838 @@ -85,7 +86,7 @@ struct portman {
97839 struct pardevice *pardev;
97840 int pardev_claimed;
97841
97842 - int open_count;
97843 + local_t open_count;
97844 int mode[PORTMAN_NUM_INPUT_PORTS];
97845 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
97846 };
97847 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
97848 index ea995af..f1bfa37 100644
97849 --- a/sound/firewire/amdtp.c
97850 +++ b/sound/firewire/amdtp.c
97851 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
97852 ptr = s->pcm_buffer_pointer + data_blocks;
97853 if (ptr >= pcm->runtime->buffer_size)
97854 ptr -= pcm->runtime->buffer_size;
97855 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
97856 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
97857
97858 s->pcm_period_pointer += data_blocks;
97859 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
97860 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
97861 */
97862 void amdtp_out_stream_update(struct amdtp_out_stream *s)
97863 {
97864 - ACCESS_ONCE(s->source_node_id_field) =
97865 + ACCESS_ONCE_RW(s->source_node_id_field) =
97866 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
97867 }
97868 EXPORT_SYMBOL(amdtp_out_stream_update);
97869 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
97870 index b680c5e..061b7a0 100644
97871 --- a/sound/firewire/amdtp.h
97872 +++ b/sound/firewire/amdtp.h
97873 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
97874 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
97875 struct snd_pcm_substream *pcm)
97876 {
97877 - ACCESS_ONCE(s->pcm) = pcm;
97878 + ACCESS_ONCE_RW(s->pcm) = pcm;
97879 }
97880
97881 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
97882 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
97883 index d428ffe..751ef78 100644
97884 --- a/sound/firewire/isight.c
97885 +++ b/sound/firewire/isight.c
97886 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
97887 ptr += count;
97888 if (ptr >= runtime->buffer_size)
97889 ptr -= runtime->buffer_size;
97890 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
97891 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
97892
97893 isight->period_counter += count;
97894 if (isight->period_counter >= runtime->period_size) {
97895 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
97896 if (err < 0)
97897 return err;
97898
97899 - ACCESS_ONCE(isight->pcm_active) = true;
97900 + ACCESS_ONCE_RW(isight->pcm_active) = true;
97901
97902 return 0;
97903 }
97904 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
97905 {
97906 struct isight *isight = substream->private_data;
97907
97908 - ACCESS_ONCE(isight->pcm_active) = false;
97909 + ACCESS_ONCE_RW(isight->pcm_active) = false;
97910
97911 mutex_lock(&isight->mutex);
97912 isight_stop_streaming(isight);
97913 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
97914
97915 switch (cmd) {
97916 case SNDRV_PCM_TRIGGER_START:
97917 - ACCESS_ONCE(isight->pcm_running) = true;
97918 + ACCESS_ONCE_RW(isight->pcm_running) = true;
97919 break;
97920 case SNDRV_PCM_TRIGGER_STOP:
97921 - ACCESS_ONCE(isight->pcm_running) = false;
97922 + ACCESS_ONCE_RW(isight->pcm_running) = false;
97923 break;
97924 default:
97925 return -EINVAL;
97926 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
97927 index 844a555..985ab83 100644
97928 --- a/sound/firewire/scs1x.c
97929 +++ b/sound/firewire/scs1x.c
97930 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
97931 {
97932 struct scs *scs = stream->rmidi->private_data;
97933
97934 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
97935 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
97936 if (up) {
97937 scs->output_idle = false;
97938 tasklet_schedule(&scs->tasklet);
97939 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
97940 {
97941 struct scs *scs = stream->rmidi->private_data;
97942
97943 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
97944 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
97945 }
97946
97947 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
97948 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
97949
97950 snd_card_disconnect(scs->card);
97951
97952 - ACCESS_ONCE(scs->output) = NULL;
97953 - ACCESS_ONCE(scs->input) = NULL;
97954 + ACCESS_ONCE_RW(scs->output) = NULL;
97955 + ACCESS_ONCE_RW(scs->input) = NULL;
97956
97957 wait_event(scs->idle_wait, scs->output_idle);
97958
97959 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
97960 index 048439a..3be9f6f 100644
97961 --- a/sound/oss/sb_audio.c
97962 +++ b/sound/oss/sb_audio.c
97963 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
97964 buf16 = (signed short *)(localbuf + localoffs);
97965 while (c)
97966 {
97967 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
97968 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
97969 if (copy_from_user(lbuf8,
97970 userbuf+useroffs + p,
97971 locallen))
97972 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
97973 index 7d8803a..559f8d0 100644
97974 --- a/sound/oss/swarm_cs4297a.c
97975 +++ b/sound/oss/swarm_cs4297a.c
97976 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
97977 {
97978 struct cs4297a_state *s;
97979 u32 pwr, id;
97980 - mm_segment_t fs;
97981 int rval;
97982 #ifndef CONFIG_BCM_CS4297A_CSWARM
97983 u64 cfg;
97984 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
97985 if (!rval) {
97986 char *sb1250_duart_present;
97987
97988 +#if 0
97989 + mm_segment_t fs;
97990 fs = get_fs();
97991 set_fs(KERNEL_DS);
97992 -#if 0
97993 val = SOUND_MASK_LINE;
97994 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
97995 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
97996 val = initvol[i].vol;
97997 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
97998 }
97999 + set_fs(fs);
98000 // cs4297a_write_ac97(s, 0x18, 0x0808);
98001 #else
98002 // cs4297a_write_ac97(s, 0x5e, 0x180);
98003 cs4297a_write_ac97(s, 0x02, 0x0808);
98004 cs4297a_write_ac97(s, 0x18, 0x0808);
98005 #endif
98006 - set_fs(fs);
98007
98008 list_add(&s->list, &cs4297a_devs);
98009
98010 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
98011 index 4631a23..001ae57 100644
98012 --- a/sound/pci/ymfpci/ymfpci.h
98013 +++ b/sound/pci/ymfpci/ymfpci.h
98014 @@ -358,7 +358,7 @@ struct snd_ymfpci {
98015 spinlock_t reg_lock;
98016 spinlock_t voice_lock;
98017 wait_queue_head_t interrupt_sleep;
98018 - atomic_t interrupt_sleep_count;
98019 + atomic_unchecked_t interrupt_sleep_count;
98020 struct snd_info_entry *proc_entry;
98021 const struct firmware *dsp_microcode;
98022 const struct firmware *controller_microcode;
98023 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
98024 index 22056c5..25d3244 100644
98025 --- a/sound/pci/ymfpci/ymfpci_main.c
98026 +++ b/sound/pci/ymfpci/ymfpci_main.c
98027 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
98028 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
98029 break;
98030 }
98031 - if (atomic_read(&chip->interrupt_sleep_count)) {
98032 - atomic_set(&chip->interrupt_sleep_count, 0);
98033 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
98034 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
98035 wake_up(&chip->interrupt_sleep);
98036 }
98037 __end:
98038 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
98039 continue;
98040 init_waitqueue_entry(&wait, current);
98041 add_wait_queue(&chip->interrupt_sleep, &wait);
98042 - atomic_inc(&chip->interrupt_sleep_count);
98043 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
98044 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
98045 remove_wait_queue(&chip->interrupt_sleep, &wait);
98046 }
98047 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
98048 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
98049 spin_unlock(&chip->reg_lock);
98050
98051 - if (atomic_read(&chip->interrupt_sleep_count)) {
98052 - atomic_set(&chip->interrupt_sleep_count, 0);
98053 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
98054 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
98055 wake_up(&chip->interrupt_sleep);
98056 }
98057 }
98058 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
98059 spin_lock_init(&chip->reg_lock);
98060 spin_lock_init(&chip->voice_lock);
98061 init_waitqueue_head(&chip->interrupt_sleep);
98062 - atomic_set(&chip->interrupt_sleep_count, 0);
98063 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
98064 chip->card = card;
98065 chip->pci = pci;
98066 chip->irq = -1;
98067 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
98068 index 0f0bed6..c161e28 100644
98069 --- a/sound/soc/fsl/fsl_ssi.c
98070 +++ b/sound/soc/fsl/fsl_ssi.c
98071 @@ -657,7 +657,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
98072 {
98073 struct fsl_ssi_private *ssi_private;
98074 int ret = 0;
98075 - struct device_attribute *dev_attr = NULL;
98076 + device_attribute_no_const *dev_attr = NULL;
98077 struct device_node *np = pdev->dev.of_node;
98078 const char *p, *sprop;
98079 const uint32_t *iprop;
98080 diff --git a/sound/sound_core.c b/sound/sound_core.c
98081 index 359753f..45759f4 100644
98082 --- a/sound/sound_core.c
98083 +++ b/sound/sound_core.c
98084 @@ -292,7 +292,7 @@ retry:
98085 }
98086
98087 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
98088 - NULL, s->name+6);
98089 + NULL, "%s", s->name+6);
98090 return s->unit_minor;
98091
98092 fail:
98093 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
98094 new file mode 100644
98095 index 0000000..50f2f2f
98096 --- /dev/null
98097 +++ b/tools/gcc/.gitignore
98098 @@ -0,0 +1 @@
98099 +size_overflow_hash.h
98100 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
98101 new file mode 100644
98102 index 0000000..144dbee
98103 --- /dev/null
98104 +++ b/tools/gcc/Makefile
98105 @@ -0,0 +1,45 @@
98106 +#CC := gcc
98107 +#PLUGIN_SOURCE_FILES := pax_plugin.c
98108 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
98109 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
98110 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
98111 +
98112 +ifeq ($(PLUGINCC),$(HOSTCC))
98113 +HOSTLIBS := hostlibs
98114 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
98115 +else
98116 +HOSTLIBS := hostcxxlibs
98117 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
98118 +endif
98119 +
98120 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
98121 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
98122 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
98123 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
98124 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
98125 +$(HOSTLIBS)-y += colorize_plugin.so
98126 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
98127 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
98128 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
98129 +
98130 +always := $($(HOSTLIBS)-y)
98131 +
98132 +constify_plugin-objs := constify_plugin.o
98133 +stackleak_plugin-objs := stackleak_plugin.o
98134 +kallocstat_plugin-objs := kallocstat_plugin.o
98135 +kernexec_plugin-objs := kernexec_plugin.o
98136 +checker_plugin-objs := checker_plugin.o
98137 +colorize_plugin-objs := colorize_plugin.o
98138 +size_overflow_plugin-objs := size_overflow_plugin.o
98139 +latent_entropy_plugin-objs := latent_entropy_plugin.o
98140 +structleak_plugin-objs := structleak_plugin.o
98141 +
98142 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
98143 +
98144 +quiet_cmd_build_size_overflow_hash = GENHASH $@
98145 + cmd_build_size_overflow_hash = \
98146 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
98147 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
98148 + $(call if_changed,build_size_overflow_hash)
98149 +
98150 +targets += size_overflow_hash.h
98151 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
98152 new file mode 100644
98153 index 0000000..22f03c0
98154 --- /dev/null
98155 +++ b/tools/gcc/checker_plugin.c
98156 @@ -0,0 +1,172 @@
98157 +/*
98158 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
98159 + * Licensed under the GPL v2
98160 + *
98161 + * Note: the choice of the license means that the compilation process is
98162 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
98163 + * but for the kernel it doesn't matter since it doesn't link against
98164 + * any of the gcc libraries
98165 + *
98166 + * gcc plugin to implement various sparse (source code checker) features
98167 + *
98168 + * TODO:
98169 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
98170 + *
98171 + * BUGS:
98172 + * - none known
98173 + */
98174 +#include "gcc-plugin.h"
98175 +#include "config.h"
98176 +#include "system.h"
98177 +#include "coretypes.h"
98178 +#include "tree.h"
98179 +#include "tree-pass.h"
98180 +#include "flags.h"
98181 +#include "intl.h"
98182 +#include "toplev.h"
98183 +#include "plugin.h"
98184 +//#include "expr.h" where are you...
98185 +#include "diagnostic.h"
98186 +#include "plugin-version.h"
98187 +#include "tm.h"
98188 +#include "function.h"
98189 +#include "basic-block.h"
98190 +#include "gimple.h"
98191 +#include "rtl.h"
98192 +#include "emit-rtl.h"
98193 +#include "tree-flow.h"
98194 +#include "target.h"
98195 +
98196 +extern void c_register_addr_space (const char *str, addr_space_t as);
98197 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
98198 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
98199 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
98200 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
98201 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
98202 +
98203 +extern void print_gimple_stmt(FILE *, gimple, int, int);
98204 +extern rtx emit_move_insn(rtx x, rtx y);
98205 +
98206 +int plugin_is_GPL_compatible;
98207 +
98208 +static struct plugin_info checker_plugin_info = {
98209 + .version = "201111150100",
98210 + .help = NULL,
98211 +};
98212 +
98213 +#define ADDR_SPACE_KERNEL 0
98214 +#define ADDR_SPACE_FORCE_KERNEL 1
98215 +#define ADDR_SPACE_USER 2
98216 +#define ADDR_SPACE_FORCE_USER 3
98217 +#define ADDR_SPACE_IOMEM 0
98218 +#define ADDR_SPACE_FORCE_IOMEM 0
98219 +#define ADDR_SPACE_PERCPU 0
98220 +#define ADDR_SPACE_FORCE_PERCPU 0
98221 +#define ADDR_SPACE_RCU 0
98222 +#define ADDR_SPACE_FORCE_RCU 0
98223 +
98224 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
98225 +{
98226 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
98227 +}
98228 +
98229 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
98230 +{
98231 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
98232 +}
98233 +
98234 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
98235 +{
98236 + return default_addr_space_valid_pointer_mode(mode, as);
98237 +}
98238 +
98239 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
98240 +{
98241 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
98242 +}
98243 +
98244 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
98245 +{
98246 + return default_addr_space_legitimize_address(x, oldx, mode, as);
98247 +}
98248 +
98249 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
98250 +{
98251 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
98252 + return true;
98253 +
98254 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
98255 + return true;
98256 +
98257 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
98258 + return true;
98259 +
98260 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
98261 + return true;
98262 +
98263 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
98264 + return true;
98265 +
98266 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
98267 + return true;
98268 +
98269 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
98270 + return true;
98271 +
98272 + return subset == superset;
98273 +}
98274 +
98275 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
98276 +{
98277 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
98278 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
98279 +
98280 + return op;
98281 +}
98282 +
98283 +static void register_checker_address_spaces(void *event_data, void *data)
98284 +{
98285 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
98286 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
98287 + c_register_addr_space("__user", ADDR_SPACE_USER);
98288 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
98289 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
98290 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
98291 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
98292 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
98293 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
98294 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
98295 +
98296 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
98297 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
98298 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
98299 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
98300 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
98301 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
98302 + targetm.addr_space.convert = checker_addr_space_convert;
98303 +}
98304 +
98305 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
98306 +{
98307 + const char * const plugin_name = plugin_info->base_name;
98308 + const int argc = plugin_info->argc;
98309 + const struct plugin_argument * const argv = plugin_info->argv;
98310 + int i;
98311 +
98312 + if (!plugin_default_version_check(version, &gcc_version)) {
98313 + error(G_("incompatible gcc/plugin versions"));
98314 + return 1;
98315 + }
98316 +
98317 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
98318 +
98319 + for (i = 0; i < argc; ++i)
98320 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
98321 +
98322 + if (TARGET_64BIT == 0)
98323 + return 0;
98324 +
98325 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
98326 +
98327 + return 0;
98328 +}
98329 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
98330 new file mode 100644
98331 index 0000000..414fe5e
98332 --- /dev/null
98333 +++ b/tools/gcc/colorize_plugin.c
98334 @@ -0,0 +1,151 @@
98335 +/*
98336 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
98337 + * Licensed under the GPL v2
98338 + *
98339 + * Note: the choice of the license means that the compilation process is
98340 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
98341 + * but for the kernel it doesn't matter since it doesn't link against
98342 + * any of the gcc libraries
98343 + *
98344 + * gcc plugin to colorize diagnostic output
98345 + *
98346 + */
98347 +
98348 +#include "gcc-plugin.h"
98349 +#include "config.h"
98350 +#include "system.h"
98351 +#include "coretypes.h"
98352 +#include "tree.h"
98353 +#include "tree-pass.h"
98354 +#include "flags.h"
98355 +#include "intl.h"
98356 +#include "toplev.h"
98357 +#include "plugin.h"
98358 +#include "diagnostic.h"
98359 +#include "plugin-version.h"
98360 +#include "tm.h"
98361 +
98362 +int plugin_is_GPL_compatible;
98363 +
98364 +static struct plugin_info colorize_plugin_info = {
98365 + .version = "201302112000",
98366 + .help = NULL,
98367 +};
98368 +
98369 +#define GREEN "\033[32m\033[2m"
98370 +#define LIGHTGREEN "\033[32m\033[1m"
98371 +#define YELLOW "\033[33m\033[2m"
98372 +#define LIGHTYELLOW "\033[33m\033[1m"
98373 +#define RED "\033[31m\033[2m"
98374 +#define LIGHTRED "\033[31m\033[1m"
98375 +#define BLUE "\033[34m\033[2m"
98376 +#define LIGHTBLUE "\033[34m\033[1m"
98377 +#define BRIGHT "\033[m\033[1m"
98378 +#define NORMAL "\033[m"
98379 +
98380 +static diagnostic_starter_fn old_starter;
98381 +static diagnostic_finalizer_fn old_finalizer;
98382 +
98383 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
98384 +{
98385 + const char *color;
98386 + char *newprefix;
98387 +
98388 + switch (diagnostic->kind) {
98389 + case DK_NOTE:
98390 + color = LIGHTBLUE;
98391 + break;
98392 +
98393 + case DK_PEDWARN:
98394 + case DK_WARNING:
98395 + color = LIGHTYELLOW;
98396 + break;
98397 +
98398 + case DK_ERROR:
98399 + case DK_FATAL:
98400 + case DK_ICE:
98401 + case DK_PERMERROR:
98402 + case DK_SORRY:
98403 + color = LIGHTRED;
98404 + break;
98405 +
98406 + default:
98407 + color = NORMAL;
98408 + }
98409 +
98410 + old_starter(context, diagnostic);
98411 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
98412 + return;
98413 + pp_destroy_prefix(context->printer);
98414 + pp_set_prefix(context->printer, newprefix);
98415 +}
98416 +
98417 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
98418 +{
98419 + old_finalizer(context, diagnostic);
98420 +}
98421 +
98422 +static void colorize_arm(void)
98423 +{
98424 + old_starter = diagnostic_starter(global_dc);
98425 + old_finalizer = diagnostic_finalizer(global_dc);
98426 +
98427 + diagnostic_starter(global_dc) = start_colorize;
98428 + diagnostic_finalizer(global_dc) = finalize_colorize;
98429 +}
98430 +
98431 +static unsigned int execute_colorize_rearm(void)
98432 +{
98433 + if (diagnostic_starter(global_dc) == start_colorize)
98434 + return 0;
98435 +
98436 + colorize_arm();
98437 + return 0;
98438 +}
98439 +
98440 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
98441 + .pass = {
98442 + .type = SIMPLE_IPA_PASS,
98443 + .name = "colorize_rearm",
98444 +#if BUILDING_GCC_VERSION >= 4008
98445 + .optinfo_flags = OPTGROUP_NONE,
98446 +#endif
98447 + .gate = NULL,
98448 + .execute = execute_colorize_rearm,
98449 + .sub = NULL,
98450 + .next = NULL,
98451 + .static_pass_number = 0,
98452 + .tv_id = TV_NONE,
98453 + .properties_required = 0,
98454 + .properties_provided = 0,
98455 + .properties_destroyed = 0,
98456 + .todo_flags_start = 0,
98457 + .todo_flags_finish = 0
98458 + }
98459 +};
98460 +
98461 +static void colorize_start_unit(void *gcc_data, void *user_data)
98462 +{
98463 + colorize_arm();
98464 +}
98465 +
98466 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
98467 +{
98468 + const char * const plugin_name = plugin_info->base_name;
98469 + struct register_pass_info colorize_rearm_pass_info = {
98470 + .pass = &pass_ipa_colorize_rearm.pass,
98471 + .reference_pass_name = "*free_lang_data",
98472 + .ref_pass_instance_number = 1,
98473 + .pos_op = PASS_POS_INSERT_AFTER
98474 + };
98475 +
98476 + if (!plugin_default_version_check(version, &gcc_version)) {
98477 + error(G_("incompatible gcc/plugin versions"));
98478 + return 1;
98479 + }
98480 +
98481 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
98482 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
98483 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
98484 + return 0;
98485 +}
98486 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
98487 new file mode 100644
98488 index 0000000..c17312d
98489 --- /dev/null
98490 +++ b/tools/gcc/constify_plugin.c
98491 @@ -0,0 +1,560 @@
98492 +/*
98493 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
98494 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
98495 + * Licensed under the GPL v2, or (at your option) v3
98496 + *
98497 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
98498 + *
98499 + * Homepage:
98500 + * http://www.grsecurity.net/~ephox/const_plugin/
98501 + *
98502 + * Usage:
98503 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
98504 + * $ gcc -fplugin=constify_plugin.so test.c -O2
98505 + */
98506 +
98507 +#include "gcc-plugin.h"
98508 +#include "config.h"
98509 +#include "system.h"
98510 +#include "coretypes.h"
98511 +#include "tree.h"
98512 +#include "tree-pass.h"
98513 +#include "flags.h"
98514 +#include "intl.h"
98515 +#include "toplev.h"
98516 +#include "plugin.h"
98517 +#include "diagnostic.h"
98518 +#include "plugin-version.h"
98519 +#include "tm.h"
98520 +#include "function.h"
98521 +#include "basic-block.h"
98522 +#include "gimple.h"
98523 +#include "rtl.h"
98524 +#include "emit-rtl.h"
98525 +#include "tree-flow.h"
98526 +#include "target.h"
98527 +#include "langhooks.h"
98528 +
98529 +// should come from c-tree.h if only it were installed for gcc 4.5...
98530 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
98531 +
98532 +// unused type flag in all versions 4.5-4.8
98533 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
98534 +
98535 +int plugin_is_GPL_compatible;
98536 +
98537 +static struct plugin_info const_plugin_info = {
98538 + .version = "201305231310",
98539 + .help = "no-constify\tturn off constification\n",
98540 +};
98541 +
98542 +typedef struct {
98543 + bool has_fptr_field;
98544 + bool has_writable_field;
98545 + bool has_do_const_field;
98546 + bool has_no_const_field;
98547 +} constify_info;
98548 +
98549 +static const_tree get_field_type(const_tree field)
98550 +{
98551 + return strip_array_types(TREE_TYPE(field));
98552 +}
98553 +
98554 +static bool is_fptr(const_tree field)
98555 +{
98556 + const_tree ptr = get_field_type(field);
98557 +
98558 + if (TREE_CODE(ptr) != POINTER_TYPE)
98559 + return false;
98560 +
98561 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
98562 +}
98563 +
98564 +/*
98565 + * determine whether the given structure type meets the requirements for automatic constification,
98566 + * including the constification attributes on nested structure types
98567 + */
98568 +static void constifiable(const_tree node, constify_info *cinfo)
98569 +{
98570 + const_tree field;
98571 +
98572 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
98573 +
98574 + // e.g., pointer to structure fields while still constructing the structure type
98575 + if (TYPE_FIELDS(node) == NULL_TREE)
98576 + return;
98577 +
98578 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
98579 + const_tree type = get_field_type(field);
98580 + enum tree_code code = TREE_CODE(type);
98581 +
98582 + if (node == type)
98583 + continue;
98584 +
98585 + if (is_fptr(field))
98586 + cinfo->has_fptr_field = true;
98587 + else if (!TREE_READONLY(field))
98588 + cinfo->has_writable_field = true;
98589 +
98590 + if (code == RECORD_TYPE || code == UNION_TYPE) {
98591 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
98592 + cinfo->has_do_const_field = true;
98593 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
98594 + cinfo->has_no_const_field = true;
98595 + else
98596 + constifiable(type, cinfo);
98597 + }
98598 + }
98599 +}
98600 +
98601 +static bool constified(const_tree node)
98602 +{
98603 + constify_info cinfo = {
98604 + .has_fptr_field = false,
98605 + .has_writable_field = false,
98606 + .has_do_const_field = false,
98607 + .has_no_const_field = false
98608 + };
98609 +
98610 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
98611 +
98612 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
98613 + gcc_assert(!TYPE_READONLY(node));
98614 + return false;
98615 + }
98616 +
98617 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
98618 + gcc_assert(TYPE_READONLY(node));
98619 + return true;
98620 + }
98621 +
98622 + constifiable(node, &cinfo);
98623 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
98624 + return false;
98625 +
98626 + return TYPE_READONLY(node);
98627 +}
98628 +
98629 +static void deconstify_tree(tree node);
98630 +
98631 +static void deconstify_type(tree type)
98632 +{
98633 + tree field;
98634 +
98635 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
98636 +
98637 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
98638 + const_tree fieldtype = get_field_type(field);
98639 +
98640 + // special case handling of simple ptr-to-same-array-type members
98641 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
98642 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
98643 +
98644 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
98645 + continue;
98646 + if (TREE_TYPE(TREE_TYPE(field)) == type)
98647 + continue;
98648 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
98649 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
98650 + TREE_TYPE(TREE_TYPE(field)) = type;
98651 + }
98652 + continue;
98653 + }
98654 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
98655 + continue;
98656 + if (!constified(fieldtype))
98657 + continue;
98658 +
98659 + deconstify_tree(field);
98660 + TREE_READONLY(field) = 0;
98661 + }
98662 + TYPE_READONLY(type) = 0;
98663 + C_TYPE_FIELDS_READONLY(type) = 0;
98664 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
98665 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
98666 +}
98667 +
98668 +static void deconstify_tree(tree node)
98669 +{
98670 + tree old_type, new_type, field;
98671 +
98672 + old_type = TREE_TYPE(node);
98673 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
98674 + node = TREE_TYPE(node) = copy_node(old_type);
98675 + old_type = TREE_TYPE(old_type);
98676 + }
98677 +
98678 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
98679 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
98680 +
98681 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
98682 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
98683 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
98684 + DECL_FIELD_CONTEXT(field) = new_type;
98685 +
98686 + deconstify_type(new_type);
98687 +
98688 + TREE_TYPE(node) = new_type;
98689 +}
98690 +
98691 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
98692 +{
98693 + tree type;
98694 + constify_info cinfo = {
98695 + .has_fptr_field = false,
98696 + .has_writable_field = false,
98697 + .has_do_const_field = false,
98698 + .has_no_const_field = false
98699 + };
98700 +
98701 + *no_add_attrs = true;
98702 + if (TREE_CODE(*node) == FUNCTION_DECL) {
98703 + error("%qE attribute does not apply to functions", name);
98704 + return NULL_TREE;
98705 + }
98706 +
98707 + if (TREE_CODE(*node) == PARM_DECL) {
98708 + error("%qE attribute does not apply to function parameters", name);
98709 + return NULL_TREE;
98710 + }
98711 +
98712 + if (TREE_CODE(*node) == VAR_DECL) {
98713 + error("%qE attribute does not apply to variables", name);
98714 + return NULL_TREE;
98715 + }
98716 +
98717 + if (TYPE_P(*node)) {
98718 + *no_add_attrs = false;
98719 + type = *node;
98720 + } else {
98721 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
98722 + type = TREE_TYPE(*node);
98723 + }
98724 +
98725 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
98726 + error("%qE attribute applies to struct and union types only", name);
98727 + return NULL_TREE;
98728 + }
98729 +
98730 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
98731 + error("%qE attribute is already applied to the type", name);
98732 + return NULL_TREE;
98733 + }
98734 +
98735 + if (TYPE_P(*node)) {
98736 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
98737 + error("%qE attribute is incompatible with 'do_const'", name);
98738 + return NULL_TREE;
98739 + }
98740 +
98741 + constifiable(type, &cinfo);
98742 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
98743 + deconstify_tree(*node);
98744 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
98745 + return NULL_TREE;
98746 + }
98747 +
98748 + error("%qE attribute used on type that is not constified", name);
98749 + return NULL_TREE;
98750 +}
98751 +
98752 +static void constify_type(tree type)
98753 +{
98754 + TYPE_READONLY(type) = 1;
98755 + C_TYPE_FIELDS_READONLY(type) = 1;
98756 + TYPE_CONSTIFY_VISITED(type) = 1;
98757 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
98758 +}
98759 +
98760 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
98761 +{
98762 + *no_add_attrs = true;
98763 + if (!TYPE_P(*node)) {
98764 + error("%qE attribute applies to types only", name);
98765 + return NULL_TREE;
98766 + }
98767 +
98768 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
98769 + error("%qE attribute applies to struct and union types only", name);
98770 + return NULL_TREE;
98771 + }
98772 +
98773 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
98774 + error("%qE attribute is already applied to the type", name);
98775 + return NULL_TREE;
98776 + }
98777 +
98778 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
98779 + error("%qE attribute is incompatible with 'no_const'", name);
98780 + return NULL_TREE;
98781 + }
98782 +
98783 + *no_add_attrs = false;
98784 + return NULL_TREE;
98785 +}
98786 +
98787 +static struct attribute_spec no_const_attr = {
98788 + .name = "no_const",
98789 + .min_length = 0,
98790 + .max_length = 0,
98791 + .decl_required = false,
98792 + .type_required = false,
98793 + .function_type_required = false,
98794 + .handler = handle_no_const_attribute,
98795 +#if BUILDING_GCC_VERSION >= 4007
98796 + .affects_type_identity = true
98797 +#endif
98798 +};
98799 +
98800 +static struct attribute_spec do_const_attr = {
98801 + .name = "do_const",
98802 + .min_length = 0,
98803 + .max_length = 0,
98804 + .decl_required = false,
98805 + .type_required = false,
98806 + .function_type_required = false,
98807 + .handler = handle_do_const_attribute,
98808 +#if BUILDING_GCC_VERSION >= 4007
98809 + .affects_type_identity = true
98810 +#endif
98811 +};
98812 +
98813 +static void register_attributes(void *event_data, void *data)
98814 +{
98815 + register_attribute(&no_const_attr);
98816 + register_attribute(&do_const_attr);
98817 +}
98818 +
98819 +static void finish_type(void *event_data, void *data)
98820 +{
98821 + tree type = (tree)event_data;
98822 + constify_info cinfo = {
98823 + .has_fptr_field = false,
98824 + .has_writable_field = false,
98825 + .has_do_const_field = false,
98826 + .has_no_const_field = false
98827 + };
98828 +
98829 + if (type == NULL_TREE || type == error_mark_node)
98830 + return;
98831 +
98832 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
98833 + return;
98834 +
98835 + constifiable(type, &cinfo);
98836 +
98837 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
98838 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
98839 + return;
98840 + if (cinfo.has_writable_field)
98841 + return;
98842 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
98843 + return;
98844 + }
98845 +
98846 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
98847 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
98848 + deconstify_type(type);
98849 + TYPE_CONSTIFY_VISITED(type) = 1;
98850 + } else
98851 + error("'no_const' attribute used on type that is not constified");
98852 + return;
98853 + }
98854 +
98855 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
98856 + constify_type(type);
98857 + return;
98858 + }
98859 +
98860 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
98861 + constify_type(type);
98862 + return;
98863 + }
98864 +
98865 + deconstify_type(type);
98866 + TYPE_CONSTIFY_VISITED(type) = 1;
98867 +}
98868 +
98869 +static void check_global_variables(void)
98870 +{
98871 + struct varpool_node *node;
98872 +
98873 +#if BUILDING_GCC_VERSION <= 4007
98874 + for (node = varpool_nodes; node; node = node->next) {
98875 + tree var = node->decl;
98876 +#else
98877 + FOR_EACH_VARIABLE(node) {
98878 + tree var = node->symbol.decl;
98879 +#endif
98880 + tree type = TREE_TYPE(var);
98881 +
98882 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
98883 + continue;
98884 +
98885 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
98886 + continue;
98887 +
98888 + if (!TYPE_CONSTIFY_VISITED(type))
98889 + continue;
98890 +
98891 + if (DECL_EXTERNAL(var))
98892 + continue;
98893 +
98894 + if (DECL_INITIAL(var))
98895 + continue;
98896 +
98897 + // this works around a gcc bug/feature where uninitialized globals
98898 + // are moved into the .bss section regardless of any constification
98899 + DECL_INITIAL(var) = build_constructor(type, NULL);
98900 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
98901 + }
98902 +}
98903 +
98904 +static unsigned int check_local_variables(void)
98905 +{
98906 + unsigned int ret = 0;
98907 + tree var;
98908 +
98909 +#if BUILDING_GCC_VERSION == 4005
98910 + tree vars;
98911 +#else
98912 + unsigned int i;
98913 +#endif
98914 +
98915 +#if BUILDING_GCC_VERSION == 4005
98916 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
98917 + var = TREE_VALUE(vars);
98918 +#else
98919 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
98920 +#endif
98921 + tree type = TREE_TYPE(var);
98922 +
98923 + gcc_assert(DECL_P(var));
98924 + if (is_global_var(var))
98925 + continue;
98926 +
98927 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
98928 + continue;
98929 +
98930 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
98931 + continue;
98932 +
98933 + if (!TYPE_CONSTIFY_VISITED(type))
98934 + continue;
98935 +
98936 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
98937 + ret = 1;
98938 + }
98939 + return ret;
98940 +}
98941 +
98942 +static unsigned int check_variables(void)
98943 +{
98944 + check_global_variables();
98945 + return check_local_variables();
98946 +}
98947 +
98948 + unsigned int ret = 0;
98949 +static struct gimple_opt_pass pass_local_variable = {
98950 + {
98951 + .type = GIMPLE_PASS,
98952 + .name = "check_variables",
98953 +#if BUILDING_GCC_VERSION >= 4008
98954 + .optinfo_flags = OPTGROUP_NONE,
98955 +#endif
98956 + .gate = NULL,
98957 + .execute = check_variables,
98958 + .sub = NULL,
98959 + .next = NULL,
98960 + .static_pass_number = 0,
98961 + .tv_id = TV_NONE,
98962 + .properties_required = 0,
98963 + .properties_provided = 0,
98964 + .properties_destroyed = 0,
98965 + .todo_flags_start = 0,
98966 + .todo_flags_finish = 0
98967 + }
98968 +};
98969 +
98970 +static struct {
98971 + const char *name;
98972 + const char *asm_op;
98973 +} sections[] = {
98974 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
98975 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
98976 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
98977 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
98978 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
98979 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
98980 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
98981 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
98982 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
98983 +};
98984 +
98985 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
98986 +
98987 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
98988 +{
98989 + size_t i;
98990 +
98991 + for (i = 0; i < ARRAY_SIZE(sections); i++)
98992 + if (!strcmp(sections[i].name, name))
98993 + return 0;
98994 + return old_section_type_flags(decl, name, reloc);
98995 +}
98996 +
98997 +static void constify_start_unit(void *gcc_data, void *user_data)
98998 +{
98999 +// size_t i;
99000 +
99001 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
99002 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
99003 +// sections[i].section = get_section(sections[i].name, 0, NULL);
99004 +
99005 + old_section_type_flags = targetm.section_type_flags;
99006 + targetm.section_type_flags = constify_section_type_flags;
99007 +}
99008 +
99009 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99010 +{
99011 + const char * const plugin_name = plugin_info->base_name;
99012 + const int argc = plugin_info->argc;
99013 + const struct plugin_argument * const argv = plugin_info->argv;
99014 + int i;
99015 + bool constify = true;
99016 +
99017 + struct register_pass_info local_variable_pass_info = {
99018 + .pass = &pass_local_variable.pass,
99019 + .reference_pass_name = "ssa",
99020 + .ref_pass_instance_number = 1,
99021 + .pos_op = PASS_POS_INSERT_BEFORE
99022 + };
99023 +
99024 + if (!plugin_default_version_check(version, &gcc_version)) {
99025 + error(G_("incompatible gcc/plugin versions"));
99026 + return 1;
99027 + }
99028 +
99029 + for (i = 0; i < argc; ++i) {
99030 + if (!(strcmp(argv[i].key, "no-constify"))) {
99031 + constify = false;
99032 + continue;
99033 + }
99034 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
99035 + }
99036 +
99037 + if (strcmp(lang_hooks.name, "GNU C")) {
99038 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
99039 + constify = false;
99040 + }
99041 +
99042 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
99043 + if (constify) {
99044 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
99045 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
99046 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
99047 + }
99048 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
99049 +
99050 + return 0;
99051 +}
99052 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
99053 new file mode 100644
99054 index 0000000..e518932
99055 --- /dev/null
99056 +++ b/tools/gcc/generate_size_overflow_hash.sh
99057 @@ -0,0 +1,94 @@
99058 +#!/bin/bash
99059 +
99060 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
99061 +
99062 +header1="size_overflow_hash.h"
99063 +database="size_overflow_hash.data"
99064 +n=65536
99065 +
99066 +usage() {
99067 +cat <<EOF
99068 +usage: $0 options
99069 +OPTIONS:
99070 + -h|--help help
99071 + -o header file
99072 + -d database file
99073 + -n hash array size
99074 +EOF
99075 + return 0
99076 +}
99077 +
99078 +while true
99079 +do
99080 + case "$1" in
99081 + -h|--help) usage && exit 0;;
99082 + -n) n=$2; shift 2;;
99083 + -o) header1="$2"; shift 2;;
99084 + -d) database="$2"; shift 2;;
99085 + --) shift 1; break ;;
99086 + *) break ;;
99087 + esac
99088 +done
99089 +
99090 +create_defines() {
99091 + for i in `seq 0 31`
99092 + do
99093 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
99094 + done
99095 + echo >> "$header1"
99096 +}
99097 +
99098 +create_structs() {
99099 + rm -f "$header1"
99100 +
99101 + create_defines
99102 +
99103 + cat "$database" | while read data
99104 + do
99105 + data_array=($data)
99106 + struct_hash_name="${data_array[0]}"
99107 + funcn="${data_array[1]}"
99108 + params="${data_array[2]}"
99109 + next="${data_array[4]}"
99110 +
99111 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
99112 +
99113 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
99114 + echo -en "\t.param\t= " >> "$header1"
99115 + line=
99116 + for param_num in ${params//-/ };
99117 + do
99118 + line="${line}PARAM"$param_num"|"
99119 + done
99120 +
99121 + echo -e "${line%?},\n};\n" >> "$header1"
99122 + done
99123 +}
99124 +
99125 +create_headers() {
99126 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
99127 +}
99128 +
99129 +create_array_elements() {
99130 + index=0
99131 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
99132 + do
99133 + data_array=($data)
99134 + i="${data_array[3]}"
99135 + hash="${data_array[0]}"
99136 + while [[ $index -lt $i ]]
99137 + do
99138 + echo -e "\t["$index"]\t= NULL," >> "$header1"
99139 + index=$(($index + 1))
99140 + done
99141 + index=$(($index + 1))
99142 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
99143 + done
99144 + echo '};' >> $header1
99145 +}
99146 +
99147 +create_structs
99148 +create_headers
99149 +create_array_elements
99150 +
99151 +exit 0
99152 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
99153 new file mode 100644
99154 index 0000000..568b360
99155 --- /dev/null
99156 +++ b/tools/gcc/kallocstat_plugin.c
99157 @@ -0,0 +1,170 @@
99158 +/*
99159 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
99160 + * Licensed under the GPL v2
99161 + *
99162 + * Note: the choice of the license means that the compilation process is
99163 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99164 + * but for the kernel it doesn't matter since it doesn't link against
99165 + * any of the gcc libraries
99166 + *
99167 + * gcc plugin to find the distribution of k*alloc sizes
99168 + *
99169 + * TODO:
99170 + *
99171 + * BUGS:
99172 + * - none known
99173 + */
99174 +#include "gcc-plugin.h"
99175 +#include "config.h"
99176 +#include "system.h"
99177 +#include "coretypes.h"
99178 +#include "tree.h"
99179 +#include "tree-pass.h"
99180 +#include "flags.h"
99181 +#include "intl.h"
99182 +#include "toplev.h"
99183 +#include "plugin.h"
99184 +//#include "expr.h" where are you...
99185 +#include "diagnostic.h"
99186 +#include "plugin-version.h"
99187 +#include "tm.h"
99188 +#include "function.h"
99189 +#include "basic-block.h"
99190 +#include "gimple.h"
99191 +#include "rtl.h"
99192 +#include "emit-rtl.h"
99193 +
99194 +extern void print_gimple_stmt(FILE *, gimple, int, int);
99195 +
99196 +int plugin_is_GPL_compatible;
99197 +
99198 +static const char * const kalloc_functions[] = {
99199 + "__kmalloc",
99200 + "kmalloc",
99201 + "kmalloc_large",
99202 + "kmalloc_node",
99203 + "kmalloc_order",
99204 + "kmalloc_order_trace",
99205 + "kmalloc_slab",
99206 + "kzalloc",
99207 + "kzalloc_node",
99208 +};
99209 +
99210 +static struct plugin_info kallocstat_plugin_info = {
99211 + .version = "201302112000",
99212 +};
99213 +
99214 +static unsigned int execute_kallocstat(void);
99215 +
99216 +static struct gimple_opt_pass kallocstat_pass = {
99217 + .pass = {
99218 + .type = GIMPLE_PASS,
99219 + .name = "kallocstat",
99220 +#if BUILDING_GCC_VERSION >= 4008
99221 + .optinfo_flags = OPTGROUP_NONE,
99222 +#endif
99223 + .gate = NULL,
99224 + .execute = execute_kallocstat,
99225 + .sub = NULL,
99226 + .next = NULL,
99227 + .static_pass_number = 0,
99228 + .tv_id = TV_NONE,
99229 + .properties_required = 0,
99230 + .properties_provided = 0,
99231 + .properties_destroyed = 0,
99232 + .todo_flags_start = 0,
99233 + .todo_flags_finish = 0
99234 + }
99235 +};
99236 +
99237 +static bool is_kalloc(const char *fnname)
99238 +{
99239 + size_t i;
99240 +
99241 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
99242 + if (!strcmp(fnname, kalloc_functions[i]))
99243 + return true;
99244 + return false;
99245 +}
99246 +
99247 +static unsigned int execute_kallocstat(void)
99248 +{
99249 + basic_block bb;
99250 +
99251 + // 1. loop through BBs and GIMPLE statements
99252 + FOR_EACH_BB(bb) {
99253 + gimple_stmt_iterator gsi;
99254 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
99255 + // gimple match:
99256 + tree fndecl, size;
99257 + gimple call_stmt;
99258 + const char *fnname;
99259 +
99260 + // is it a call
99261 + call_stmt = gsi_stmt(gsi);
99262 + if (!is_gimple_call(call_stmt))
99263 + continue;
99264 + fndecl = gimple_call_fndecl(call_stmt);
99265 + if (fndecl == NULL_TREE)
99266 + continue;
99267 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
99268 + continue;
99269 +
99270 + // is it a call to k*alloc
99271 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
99272 + if (!is_kalloc(fnname))
99273 + continue;
99274 +
99275 + // is the size arg the result of a simple const assignment
99276 + size = gimple_call_arg(call_stmt, 0);
99277 + while (true) {
99278 + gimple def_stmt;
99279 + expanded_location xloc;
99280 + size_t size_val;
99281 +
99282 + if (TREE_CODE(size) != SSA_NAME)
99283 + break;
99284 + def_stmt = SSA_NAME_DEF_STMT(size);
99285 + if (!def_stmt || !is_gimple_assign(def_stmt))
99286 + break;
99287 + if (gimple_num_ops(def_stmt) != 2)
99288 + break;
99289 + size = gimple_assign_rhs1(def_stmt);
99290 + if (!TREE_CONSTANT(size))
99291 + continue;
99292 + xloc = expand_location(gimple_location(def_stmt));
99293 + if (!xloc.file)
99294 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
99295 + size_val = TREE_INT_CST_LOW(size);
99296 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
99297 + break;
99298 + }
99299 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
99300 +//debug_tree(gimple_call_fn(call_stmt));
99301 +//print_node(stderr, "pax", fndecl, 4);
99302 + }
99303 + }
99304 +
99305 + return 0;
99306 +}
99307 +
99308 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99309 +{
99310 + const char * const plugin_name = plugin_info->base_name;
99311 + struct register_pass_info kallocstat_pass_info = {
99312 + .pass = &kallocstat_pass.pass,
99313 + .reference_pass_name = "ssa",
99314 + .ref_pass_instance_number = 1,
99315 + .pos_op = PASS_POS_INSERT_AFTER
99316 + };
99317 +
99318 + if (!plugin_default_version_check(version, &gcc_version)) {
99319 + error(G_("incompatible gcc/plugin versions"));
99320 + return 1;
99321 + }
99322 +
99323 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
99324 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
99325 +
99326 + return 0;
99327 +}
99328 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
99329 new file mode 100644
99330 index 0000000..0408e06
99331 --- /dev/null
99332 +++ b/tools/gcc/kernexec_plugin.c
99333 @@ -0,0 +1,465 @@
99334 +/*
99335 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
99336 + * Licensed under the GPL v2
99337 + *
99338 + * Note: the choice of the license means that the compilation process is
99339 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99340 + * but for the kernel it doesn't matter since it doesn't link against
99341 + * any of the gcc libraries
99342 + *
99343 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
99344 + *
99345 + * TODO:
99346 + *
99347 + * BUGS:
99348 + * - none known
99349 + */
99350 +#include "gcc-plugin.h"
99351 +#include "config.h"
99352 +#include "system.h"
99353 +#include "coretypes.h"
99354 +#include "tree.h"
99355 +#include "tree-pass.h"
99356 +#include "flags.h"
99357 +#include "intl.h"
99358 +#include "toplev.h"
99359 +#include "plugin.h"
99360 +//#include "expr.h" where are you...
99361 +#include "diagnostic.h"
99362 +#include "plugin-version.h"
99363 +#include "tm.h"
99364 +#include "function.h"
99365 +#include "basic-block.h"
99366 +#include "gimple.h"
99367 +#include "rtl.h"
99368 +#include "emit-rtl.h"
99369 +#include "tree-flow.h"
99370 +
99371 +extern void print_gimple_stmt(FILE *, gimple, int, int);
99372 +extern rtx emit_move_insn(rtx x, rtx y);
99373 +
99374 +#if BUILDING_GCC_VERSION <= 4006
99375 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
99376 +#endif
99377 +
99378 +#if BUILDING_GCC_VERSION >= 4008
99379 +#define TODO_dump_func 0
99380 +#endif
99381 +
99382 +int plugin_is_GPL_compatible;
99383 +
99384 +static struct plugin_info kernexec_plugin_info = {
99385 + .version = "201302112000",
99386 + .help = "method=[bts|or]\tinstrumentation method\n"
99387 +};
99388 +
99389 +static unsigned int execute_kernexec_reload(void);
99390 +static unsigned int execute_kernexec_fptr(void);
99391 +static unsigned int execute_kernexec_retaddr(void);
99392 +static bool kernexec_cmodel_check(void);
99393 +
99394 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
99395 +static void (*kernexec_instrument_retaddr)(rtx);
99396 +
99397 +static struct gimple_opt_pass kernexec_reload_pass = {
99398 + .pass = {
99399 + .type = GIMPLE_PASS,
99400 + .name = "kernexec_reload",
99401 +#if BUILDING_GCC_VERSION >= 4008
99402 + .optinfo_flags = OPTGROUP_NONE,
99403 +#endif
99404 + .gate = kernexec_cmodel_check,
99405 + .execute = execute_kernexec_reload,
99406 + .sub = NULL,
99407 + .next = NULL,
99408 + .static_pass_number = 0,
99409 + .tv_id = TV_NONE,
99410 + .properties_required = 0,
99411 + .properties_provided = 0,
99412 + .properties_destroyed = 0,
99413 + .todo_flags_start = 0,
99414 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
99415 + }
99416 +};
99417 +
99418 +static struct gimple_opt_pass kernexec_fptr_pass = {
99419 + .pass = {
99420 + .type = GIMPLE_PASS,
99421 + .name = "kernexec_fptr",
99422 +#if BUILDING_GCC_VERSION >= 4008
99423 + .optinfo_flags = OPTGROUP_NONE,
99424 +#endif
99425 + .gate = kernexec_cmodel_check,
99426 + .execute = execute_kernexec_fptr,
99427 + .sub = NULL,
99428 + .next = NULL,
99429 + .static_pass_number = 0,
99430 + .tv_id = TV_NONE,
99431 + .properties_required = 0,
99432 + .properties_provided = 0,
99433 + .properties_destroyed = 0,
99434 + .todo_flags_start = 0,
99435 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
99436 + }
99437 +};
99438 +
99439 +static struct rtl_opt_pass kernexec_retaddr_pass = {
99440 + .pass = {
99441 + .type = RTL_PASS,
99442 + .name = "kernexec_retaddr",
99443 +#if BUILDING_GCC_VERSION >= 4008
99444 + .optinfo_flags = OPTGROUP_NONE,
99445 +#endif
99446 + .gate = kernexec_cmodel_check,
99447 + .execute = execute_kernexec_retaddr,
99448 + .sub = NULL,
99449 + .next = NULL,
99450 + .static_pass_number = 0,
99451 + .tv_id = TV_NONE,
99452 + .properties_required = 0,
99453 + .properties_provided = 0,
99454 + .properties_destroyed = 0,
99455 + .todo_flags_start = 0,
99456 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
99457 + }
99458 +};
99459 +
99460 +static bool kernexec_cmodel_check(void)
99461 +{
99462 + tree section;
99463 +
99464 + if (ix86_cmodel != CM_KERNEL)
99465 + return false;
99466 +
99467 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
99468 + if (!section || !TREE_VALUE(section))
99469 + return true;
99470 +
99471 + section = TREE_VALUE(TREE_VALUE(section));
99472 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
99473 + return true;
99474 +
99475 + return false;
99476 +}
99477 +
99478 +/*
99479 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
99480 + */
99481 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
99482 +{
99483 + gimple asm_movabs_stmt;
99484 +
99485 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
99486 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
99487 + gimple_asm_set_volatile(asm_movabs_stmt, true);
99488 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
99489 + update_stmt(asm_movabs_stmt);
99490 +}
99491 +
99492 +/*
99493 + * find all asm() stmts that clobber r10 and add a reload of r10
99494 + */
99495 +static unsigned int execute_kernexec_reload(void)
99496 +{
99497 + basic_block bb;
99498 +
99499 + // 1. loop through BBs and GIMPLE statements
99500 + FOR_EACH_BB(bb) {
99501 + gimple_stmt_iterator gsi;
99502 +
99503 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
99504 + // gimple match: __asm__ ("" : : : "r10");
99505 + gimple asm_stmt;
99506 + size_t nclobbers;
99507 +
99508 + // is it an asm ...
99509 + asm_stmt = gsi_stmt(gsi);
99510 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
99511 + continue;
99512 +
99513 + // ... clobbering r10
99514 + nclobbers = gimple_asm_nclobbers(asm_stmt);
99515 + while (nclobbers--) {
99516 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
99517 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
99518 + continue;
99519 + kernexec_reload_fptr_mask(&gsi);
99520 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
99521 + break;
99522 + }
99523 + }
99524 + }
99525 +
99526 + return 0;
99527 +}
99528 +
99529 +/*
99530 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
99531 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
99532 + */
99533 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
99534 +{
99535 + gimple assign_intptr, assign_new_fptr, call_stmt;
99536 + tree intptr, old_fptr, new_fptr, kernexec_mask;
99537 +
99538 + call_stmt = gsi_stmt(*gsi);
99539 + old_fptr = gimple_call_fn(call_stmt);
99540 +
99541 + // create temporary unsigned long variable used for bitops and cast fptr to it
99542 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
99543 +#if BUILDING_GCC_VERSION <= 4007
99544 + add_referenced_var(intptr);
99545 + mark_sym_for_renaming(intptr);
99546 +#endif
99547 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
99548 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
99549 + update_stmt(assign_intptr);
99550 +
99551 + // apply logical or to temporary unsigned long and bitmask
99552 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
99553 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
99554 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
99555 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
99556 + update_stmt(assign_intptr);
99557 +
99558 + // cast temporary unsigned long back to a temporary fptr variable
99559 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
99560 +#if BUILDING_GCC_VERSION <= 4007
99561 + add_referenced_var(new_fptr);
99562 + mark_sym_for_renaming(new_fptr);
99563 +#endif
99564 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
99565 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
99566 + update_stmt(assign_new_fptr);
99567 +
99568 + // replace call stmt fn with the new fptr
99569 + gimple_call_set_fn(call_stmt, new_fptr);
99570 + update_stmt(call_stmt);
99571 +}
99572 +
99573 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
99574 +{
99575 + gimple asm_or_stmt, call_stmt;
99576 + tree old_fptr, new_fptr, input, output;
99577 +#if BUILDING_GCC_VERSION <= 4007
99578 + VEC(tree, gc) *inputs = NULL;
99579 + VEC(tree, gc) *outputs = NULL;
99580 +#else
99581 + vec<tree, va_gc> *inputs = NULL;
99582 + vec<tree, va_gc> *outputs = NULL;
99583 +#endif
99584 +
99585 + call_stmt = gsi_stmt(*gsi);
99586 + old_fptr = gimple_call_fn(call_stmt);
99587 +
99588 + // create temporary fptr variable
99589 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
99590 +#if BUILDING_GCC_VERSION <= 4007
99591 + add_referenced_var(new_fptr);
99592 + mark_sym_for_renaming(new_fptr);
99593 +#endif
99594 +
99595 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
99596 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
99597 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
99598 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
99599 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
99600 +#if BUILDING_GCC_VERSION <= 4007
99601 + VEC_safe_push(tree, gc, inputs, input);
99602 + VEC_safe_push(tree, gc, outputs, output);
99603 +#else
99604 + vec_safe_push(inputs, input);
99605 + vec_safe_push(outputs, output);
99606 +#endif
99607 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
99608 + gimple_asm_set_volatile(asm_or_stmt, true);
99609 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
99610 + update_stmt(asm_or_stmt);
99611 +
99612 + // replace call stmt fn with the new fptr
99613 + gimple_call_set_fn(call_stmt, new_fptr);
99614 + update_stmt(call_stmt);
99615 +}
99616 +
99617 +/*
99618 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
99619 + */
99620 +static unsigned int execute_kernexec_fptr(void)
99621 +{
99622 + basic_block bb;
99623 +
99624 + // 1. loop through BBs and GIMPLE statements
99625 + FOR_EACH_BB(bb) {
99626 + gimple_stmt_iterator gsi;
99627 +
99628 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
99629 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
99630 + tree fn;
99631 + gimple call_stmt;
99632 +
99633 + // is it a call ...
99634 + call_stmt = gsi_stmt(gsi);
99635 + if (!is_gimple_call(call_stmt))
99636 + continue;
99637 + fn = gimple_call_fn(call_stmt);
99638 + if (TREE_CODE(fn) == ADDR_EXPR)
99639 + continue;
99640 + if (TREE_CODE(fn) != SSA_NAME)
99641 + gcc_unreachable();
99642 +
99643 + // ... through a function pointer
99644 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
99645 + fn = SSA_NAME_VAR(fn);
99646 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
99647 + debug_tree(fn);
99648 + gcc_unreachable();
99649 + }
99650 + }
99651 + fn = TREE_TYPE(fn);
99652 + if (TREE_CODE(fn) != POINTER_TYPE)
99653 + continue;
99654 + fn = TREE_TYPE(fn);
99655 + if (TREE_CODE(fn) != FUNCTION_TYPE)
99656 + continue;
99657 +
99658 + kernexec_instrument_fptr(&gsi);
99659 +
99660 +//debug_tree(gimple_call_fn(call_stmt));
99661 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
99662 + }
99663 + }
99664 +
99665 + return 0;
99666 +}
99667 +
99668 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
99669 +static void kernexec_instrument_retaddr_bts(rtx insn)
99670 +{
99671 + rtx btsq;
99672 + rtvec argvec, constraintvec, labelvec;
99673 + int line;
99674 +
99675 + // create asm volatile("btsq $63,(%%rsp)":::)
99676 + argvec = rtvec_alloc(0);
99677 + constraintvec = rtvec_alloc(0);
99678 + labelvec = rtvec_alloc(0);
99679 + line = expand_location(RTL_LOCATION(insn)).line;
99680 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
99681 + MEM_VOLATILE_P(btsq) = 1;
99682 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
99683 + emit_insn_before(btsq, insn);
99684 +}
99685 +
99686 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
99687 +static void kernexec_instrument_retaddr_or(rtx insn)
99688 +{
99689 + rtx orq;
99690 + rtvec argvec, constraintvec, labelvec;
99691 + int line;
99692 +
99693 + // create asm volatile("orq %%r10,(%%rsp)":::)
99694 + argvec = rtvec_alloc(0);
99695 + constraintvec = rtvec_alloc(0);
99696 + labelvec = rtvec_alloc(0);
99697 + line = expand_location(RTL_LOCATION(insn)).line;
99698 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
99699 + MEM_VOLATILE_P(orq) = 1;
99700 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
99701 + emit_insn_before(orq, insn);
99702 +}
99703 +
99704 +/*
99705 + * find all asm level function returns and forcibly set the highest bit of the return address
99706 + */
99707 +static unsigned int execute_kernexec_retaddr(void)
99708 +{
99709 + rtx insn;
99710 +
99711 + // 1. find function returns
99712 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
99713 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
99714 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
99715 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
99716 + rtx body;
99717 +
99718 + // is it a retn
99719 + if (!JUMP_P(insn))
99720 + continue;
99721 + body = PATTERN(insn);
99722 + if (GET_CODE(body) == PARALLEL)
99723 + body = XVECEXP(body, 0, 0);
99724 + if (!ANY_RETURN_P(body))
99725 + continue;
99726 + kernexec_instrument_retaddr(insn);
99727 + }
99728 +
99729 +// print_simple_rtl(stderr, get_insns());
99730 +// print_rtl(stderr, get_insns());
99731 +
99732 + return 0;
99733 +}
99734 +
99735 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99736 +{
99737 + const char * const plugin_name = plugin_info->base_name;
99738 + const int argc = plugin_info->argc;
99739 + const struct plugin_argument * const argv = plugin_info->argv;
99740 + int i;
99741 + struct register_pass_info kernexec_reload_pass_info = {
99742 + .pass = &kernexec_reload_pass.pass,
99743 + .reference_pass_name = "ssa",
99744 + .ref_pass_instance_number = 1,
99745 + .pos_op = PASS_POS_INSERT_AFTER
99746 + };
99747 + struct register_pass_info kernexec_fptr_pass_info = {
99748 + .pass = &kernexec_fptr_pass.pass,
99749 + .reference_pass_name = "ssa",
99750 + .ref_pass_instance_number = 1,
99751 + .pos_op = PASS_POS_INSERT_AFTER
99752 + };
99753 + struct register_pass_info kernexec_retaddr_pass_info = {
99754 + .pass = &kernexec_retaddr_pass.pass,
99755 + .reference_pass_name = "pro_and_epilogue",
99756 + .ref_pass_instance_number = 1,
99757 + .pos_op = PASS_POS_INSERT_AFTER
99758 + };
99759 +
99760 + if (!plugin_default_version_check(version, &gcc_version)) {
99761 + error(G_("incompatible gcc/plugin versions"));
99762 + return 1;
99763 + }
99764 +
99765 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
99766 +
99767 + if (TARGET_64BIT == 0)
99768 + return 0;
99769 +
99770 + for (i = 0; i < argc; ++i) {
99771 + if (!strcmp(argv[i].key, "method")) {
99772 + if (!argv[i].value) {
99773 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
99774 + continue;
99775 + }
99776 + if (!strcmp(argv[i].value, "bts")) {
99777 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
99778 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
99779 + } else if (!strcmp(argv[i].value, "or")) {
99780 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
99781 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
99782 + fix_register("r10", 1, 1);
99783 + } else
99784 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
99785 + continue;
99786 + }
99787 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
99788 + }
99789 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
99790 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
99791 +
99792 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
99793 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
99794 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
99795 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
99796 +
99797 + return 0;
99798 +}
99799 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
99800 new file mode 100644
99801 index 0000000..b5395ba
99802 --- /dev/null
99803 +++ b/tools/gcc/latent_entropy_plugin.c
99804 @@ -0,0 +1,327 @@
99805 +/*
99806 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
99807 + * Licensed under the GPL v2
99808 + *
99809 + * Note: the choice of the license means that the compilation process is
99810 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99811 + * but for the kernel it doesn't matter since it doesn't link against
99812 + * any of the gcc libraries
99813 + *
99814 + * gcc plugin to help generate a little bit of entropy from program state,
99815 + * used during boot in the kernel
99816 + *
99817 + * TODO:
99818 + * - add ipa pass to identify not explicitly marked candidate functions
99819 + * - mix in more program state (function arguments/return values, loop variables, etc)
99820 + * - more instrumentation control via attribute parameters
99821 + *
99822 + * BUGS:
99823 + * - LTO needs -flto-partition=none for now
99824 + */
99825 +#include "gcc-plugin.h"
99826 +#include "config.h"
99827 +#include "system.h"
99828 +#include "coretypes.h"
99829 +#include "tree.h"
99830 +#include "tree-pass.h"
99831 +#include "flags.h"
99832 +#include "intl.h"
99833 +#include "toplev.h"
99834 +#include "plugin.h"
99835 +//#include "expr.h" where are you...
99836 +#include "diagnostic.h"
99837 +#include "plugin-version.h"
99838 +#include "tm.h"
99839 +#include "function.h"
99840 +#include "basic-block.h"
99841 +#include "gimple.h"
99842 +#include "rtl.h"
99843 +#include "emit-rtl.h"
99844 +#include "tree-flow.h"
99845 +#include "langhooks.h"
99846 +
99847 +#if BUILDING_GCC_VERSION >= 4008
99848 +#define TODO_dump_func 0
99849 +#endif
99850 +
99851 +int plugin_is_GPL_compatible;
99852 +
99853 +static tree latent_entropy_decl;
99854 +
99855 +static struct plugin_info latent_entropy_plugin_info = {
99856 + .version = "201303102320",
99857 + .help = NULL
99858 +};
99859 +
99860 +static unsigned int execute_latent_entropy(void);
99861 +static bool gate_latent_entropy(void);
99862 +
99863 +static struct gimple_opt_pass latent_entropy_pass = {
99864 + .pass = {
99865 + .type = GIMPLE_PASS,
99866 + .name = "latent_entropy",
99867 +#if BUILDING_GCC_VERSION >= 4008
99868 + .optinfo_flags = OPTGROUP_NONE,
99869 +#endif
99870 + .gate = gate_latent_entropy,
99871 + .execute = execute_latent_entropy,
99872 + .sub = NULL,
99873 + .next = NULL,
99874 + .static_pass_number = 0,
99875 + .tv_id = TV_NONE,
99876 + .properties_required = PROP_gimple_leh | PROP_cfg,
99877 + .properties_provided = 0,
99878 + .properties_destroyed = 0,
99879 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
99880 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
99881 + }
99882 +};
99883 +
99884 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
99885 +{
99886 + if (TREE_CODE(*node) != FUNCTION_DECL) {
99887 + *no_add_attrs = true;
99888 + error("%qE attribute only applies to functions", name);
99889 + }
99890 + return NULL_TREE;
99891 +}
99892 +
99893 +static struct attribute_spec latent_entropy_attr = {
99894 + .name = "latent_entropy",
99895 + .min_length = 0,
99896 + .max_length = 0,
99897 + .decl_required = true,
99898 + .type_required = false,
99899 + .function_type_required = false,
99900 + .handler = handle_latent_entropy_attribute,
99901 +#if BUILDING_GCC_VERSION >= 4007
99902 + .affects_type_identity = false
99903 +#endif
99904 +};
99905 +
99906 +static void register_attributes(void *event_data, void *data)
99907 +{
99908 + register_attribute(&latent_entropy_attr);
99909 +}
99910 +
99911 +static bool gate_latent_entropy(void)
99912 +{
99913 + tree latent_entropy_attr;
99914 +
99915 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
99916 + return latent_entropy_attr != NULL_TREE;
99917 +}
99918 +
99919 +static unsigned HOST_WIDE_INT seed;
99920 +static unsigned HOST_WIDE_INT get_random_const(void)
99921 +{
99922 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
99923 + return seed;
99924 +}
99925 +
99926 +static enum tree_code get_op(tree *rhs)
99927 +{
99928 + static enum tree_code op;
99929 + unsigned HOST_WIDE_INT random_const;
99930 +
99931 + random_const = get_random_const();
99932 +
99933 + switch (op) {
99934 + case BIT_XOR_EXPR:
99935 + op = PLUS_EXPR;
99936 + break;
99937 +
99938 + case PLUS_EXPR:
99939 + if (rhs) {
99940 + op = LROTATE_EXPR;
99941 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
99942 + break;
99943 + }
99944 +
99945 + case LROTATE_EXPR:
99946 + default:
99947 + op = BIT_XOR_EXPR;
99948 + break;
99949 + }
99950 + if (rhs)
99951 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
99952 + return op;
99953 +}
99954 +
99955 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
99956 +{
99957 + gimple_stmt_iterator gsi;
99958 + gimple assign;
99959 + tree addxorrol, rhs;
99960 + enum tree_code op;
99961 +
99962 + op = get_op(&rhs);
99963 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
99964 + assign = gimple_build_assign(local_entropy, addxorrol);
99965 +#if BUILDING_GCC_VERSION <= 4007
99966 + find_referenced_vars_in(assign);
99967 +#endif
99968 +//debug_bb(bb);
99969 + gsi = gsi_after_labels(bb);
99970 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
99971 + update_stmt(assign);
99972 +}
99973 +
99974 +static void perturb_latent_entropy(basic_block bb, tree rhs)
99975 +{
99976 + gimple_stmt_iterator gsi;
99977 + gimple assign;
99978 + tree addxorrol, temp;
99979 +
99980 + // 1. create temporary copy of latent_entropy
99981 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
99982 +#if BUILDING_GCC_VERSION <= 4007
99983 + add_referenced_var(temp);
99984 + mark_sym_for_renaming(temp);
99985 +#endif
99986 +
99987 + // 2. read...
99988 + assign = gimple_build_assign(temp, latent_entropy_decl);
99989 +#if BUILDING_GCC_VERSION <= 4007
99990 + find_referenced_vars_in(assign);
99991 +#endif
99992 + gsi = gsi_after_labels(bb);
99993 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
99994 + update_stmt(assign);
99995 +
99996 + // 3. ...modify...
99997 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
99998 + assign = gimple_build_assign(temp, addxorrol);
99999 +#if BUILDING_GCC_VERSION <= 4007
100000 + find_referenced_vars_in(assign);
100001 +#endif
100002 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
100003 + update_stmt(assign);
100004 +
100005 + // 4. ...write latent_entropy
100006 + assign = gimple_build_assign(latent_entropy_decl, temp);
100007 +#if BUILDING_GCC_VERSION <= 4007
100008 + find_referenced_vars_in(assign);
100009 +#endif
100010 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
100011 + update_stmt(assign);
100012 +}
100013 +
100014 +static unsigned int execute_latent_entropy(void)
100015 +{
100016 + basic_block bb;
100017 + gimple assign;
100018 + gimple_stmt_iterator gsi;
100019 + tree local_entropy;
100020 +
100021 + if (!latent_entropy_decl) {
100022 + struct varpool_node *node;
100023 +
100024 +#if BUILDING_GCC_VERSION <= 4007
100025 + for (node = varpool_nodes; node; node = node->next) {
100026 + tree var = node->decl;
100027 +#else
100028 + FOR_EACH_VARIABLE(node) {
100029 + tree var = node->symbol.decl;
100030 +#endif
100031 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
100032 + continue;
100033 + latent_entropy_decl = var;
100034 +// debug_tree(var);
100035 + break;
100036 + }
100037 + if (!latent_entropy_decl) {
100038 +// debug_tree(current_function_decl);
100039 + return 0;
100040 + }
100041 + }
100042 +
100043 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
100044 +
100045 + // 1. create local entropy variable
100046 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
100047 +#if BUILDING_GCC_VERSION <= 4007
100048 + add_referenced_var(local_entropy);
100049 + mark_sym_for_renaming(local_entropy);
100050 +#endif
100051 +
100052 + // 2. initialize local entropy variable
100053 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
100054 + if (dom_info_available_p(CDI_DOMINATORS))
100055 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
100056 + gsi = gsi_start_bb(bb);
100057 +
100058 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
100059 +// gimple_set_location(assign, loc);
100060 +#if BUILDING_GCC_VERSION <= 4007
100061 + find_referenced_vars_in(assign);
100062 +#endif
100063 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
100064 + update_stmt(assign);
100065 + bb = bb->next_bb;
100066 +
100067 + // 3. instrument each BB with an operation on the local entropy variable
100068 + while (bb != EXIT_BLOCK_PTR) {
100069 + perturb_local_entropy(bb, local_entropy);
100070 + bb = bb->next_bb;
100071 + };
100072 +
100073 + // 4. mix local entropy into the global entropy variable
100074 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
100075 + return 0;
100076 +}
100077 +
100078 +static void start_unit_callback(void *gcc_data, void *user_data)
100079 +{
100080 + tree latent_entropy_type;
100081 +
100082 +#if BUILDING_GCC_VERSION >= 4007
100083 + seed = get_random_seed(false);
100084 +#else
100085 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
100086 + seed *= seed;
100087 +#endif
100088 +
100089 + if (in_lto_p)
100090 + return;
100091 +
100092 + // extern volatile u64 latent_entropy
100093 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
100094 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
100095 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
100096 +
100097 + TREE_STATIC(latent_entropy_decl) = 1;
100098 + TREE_PUBLIC(latent_entropy_decl) = 1;
100099 + TREE_USED(latent_entropy_decl) = 1;
100100 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
100101 + DECL_EXTERNAL(latent_entropy_decl) = 1;
100102 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
100103 + DECL_INITIAL(latent_entropy_decl) = NULL;
100104 + lang_hooks.decls.pushdecl(latent_entropy_decl);
100105 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
100106 +// varpool_finalize_decl(latent_entropy_decl);
100107 +// varpool_mark_needed_node(latent_entropy_decl);
100108 +}
100109 +
100110 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100111 +{
100112 + const char * const plugin_name = plugin_info->base_name;
100113 + struct register_pass_info latent_entropy_pass_info = {
100114 + .pass = &latent_entropy_pass.pass,
100115 + .reference_pass_name = "optimized",
100116 + .ref_pass_instance_number = 1,
100117 + .pos_op = PASS_POS_INSERT_BEFORE
100118 + };
100119 +
100120 + if (!plugin_default_version_check(version, &gcc_version)) {
100121 + error(G_("incompatible gcc/plugin versions"));
100122 + return 1;
100123 + }
100124 +
100125 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
100126 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
100127 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
100128 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
100129 +
100130 + return 0;
100131 +}
100132 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
100133 new file mode 100644
100134 index 0000000..b04803b
100135 --- /dev/null
100136 +++ b/tools/gcc/size_overflow_hash.data
100137 @@ -0,0 +1,6350 @@
100138 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
100139 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
100140 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
100141 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
100142 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
100143 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
100144 +padzero_55 padzero 1 55 &sel_read_policyvers_55
100145 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
100146 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
100147 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
100148 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
100149 +load_msg_95 load_msg 2 95 NULL
100150 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
100151 +init_q_132 init_q 4 132 NULL
100152 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
100153 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
100154 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
100155 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
100156 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
100157 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
100158 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
100159 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
100160 +br_port_info_size_268 br_port_info_size 0 268 NULL
100161 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
100162 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
100163 +SYSC_connect_304 SYSC_connect 3 304 NULL
100164 +syslog_print_307 syslog_print 2 307 NULL
100165 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
100166 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
100167 +next_node_allowed_318 next_node_allowed 1 318 NULL
100168 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
100169 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
100170 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
100171 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
100172 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
100173 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
100174 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
100175 +pidlist_resize_496 pidlist_resize 2 496 NULL
100176 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
100177 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
100178 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
100179 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
100180 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
100181 +dle_count_543 dle_count 0 543 NULL
100182 +devres_alloc_551 devres_alloc 2 551 NULL
100183 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
100184 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
100185 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
100186 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
100187 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
100188 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
100189 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
100190 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
100191 +isp1760_register_628 isp1760_register 1-2 628 NULL
100192 +clone_split_bio_633 clone_split_bio 6 633 NULL
100193 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
100194 +remap_to_cache_640 remap_to_cache 3 640 NULL
100195 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
100196 +unlink_queued_645 unlink_queued 3-4 645 NULL
100197 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
100198 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
100199 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
100200 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
100201 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
100202 +disk_max_parts_719 disk_max_parts 0 719 NULL
100203 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
100204 +dvb_video_write_754 dvb_video_write 3 754 NULL
100205 +if_writecmd_815 if_writecmd 2 815 NULL
100206 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
100207 +read_fifo_826 read_fifo 3 826 NULL
100208 +um_idi_read_850 um_idi_read 3 850 NULL
100209 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
100210 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
100211 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
100212 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
100213 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
100214 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
100215 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
100216 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
100217 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
100218 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
100219 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
100220 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
100221 +_do_truncate_1019 _do_truncate 2 1019 NULL
100222 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
100223 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
100224 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
100225 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
100226 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
100227 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
100228 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
100229 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
100230 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
100231 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
100232 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
100233 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
100234 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
100235 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
100236 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
100237 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
100238 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
100239 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
100240 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
100241 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
100242 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
100243 +nested_get_page_1252 nested_get_page 2 1252 NULL
100244 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
100245 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
100246 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
100247 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
100248 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
100249 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
100250 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
100251 +ffs_1322 ffs 0 1322 NULL
100252 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
100253 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
100254 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
100255 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
100256 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
100257 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
100258 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
100259 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
100260 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
100261 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
100262 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
100263 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
100264 +zone_page_state_1393 zone_page_state 0 1393 NULL
100265 +file_read_actor_1401 file_read_actor 4 1401 NULL
100266 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
100267 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
100268 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
100269 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
100270 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
100271 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
100272 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
100273 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
100274 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
100275 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
100276 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
100277 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
100278 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
100279 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
100280 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
100281 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
100282 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
100283 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
100284 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
100285 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
100286 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
100287 +rmap_add_1677 rmap_add 3 1677 NULL
100288 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
100289 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
100290 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
100291 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
100292 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
100293 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
100294 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
100295 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
100296 +cosa_write_1774 cosa_write 3 1774 NULL
100297 +update_macheader_1775 update_macheader 7 1775 NULL
100298 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
100299 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
100300 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
100301 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
100302 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
100303 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
100304 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
100305 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
100306 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
100307 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
100308 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
100309 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
100310 +read_swap_header_1957 read_swap_header 0 1957 NULL
100311 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
100312 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
100313 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
100314 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
100315 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
100316 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
100317 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
100318 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
100319 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
100320 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
100321 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
100322 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
100323 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
100324 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
100325 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
100326 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
100327 +audit_expand_2098 audit_expand 2 2098 NULL
100328 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
100329 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
100330 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
100331 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
100332 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
100333 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
100334 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
100335 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
100336 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
100337 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
100338 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
100339 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
100340 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
100341 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
100342 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
100343 +vhci_write_2224 vhci_write 3 2224 NULL
100344 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
100345 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
100346 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
100347 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
100348 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
100349 +do_update_counters_2259 do_update_counters 4 2259 NULL
100350 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
100351 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
100352 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
100353 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
100354 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
100355 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
100356 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
100357 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
100358 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
100359 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
100360 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
100361 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
100362 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
100363 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
100364 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
100365 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
100366 +raid1_size_2419 raid1_size 0-2 2419 NULL
100367 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
100368 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
100369 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
100370 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
100371 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
100372 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
100373 +update_pmkid_2481 update_pmkid 4 2481 NULL
100374 +wiphy_new_2482 wiphy_new 2 2482 NULL
100375 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
100376 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
100377 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
100378 +dm_write_2513 dm_write 3 2513 NULL
100379 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
100380 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
100381 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
100382 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
100383 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
100384 +slot_bytes_2609 slot_bytes 0 2609 NULL
100385 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
100386 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
100387 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
100388 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
100389 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
100390 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
100391 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
100392 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
100393 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
100394 +__next_cpu_2782 __next_cpu 1 2782 NULL
100395 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
100396 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
100397 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
100398 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
100399 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
100400 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
100401 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
100402 +mq_map_2871 mq_map 2 2871 NULL
100403 +nla_padlen_2883 nla_padlen 1 2883 NULL
100404 +cmm_write_2896 cmm_write 3 2896 NULL
100405 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
100406 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
100407 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
100408 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
100409 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
100410 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
100411 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
100412 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
100413 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
100414 +depth_write_3021 depth_write 3 3021 NULL
100415 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
100416 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
100417 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
100418 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
100419 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
100420 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
100421 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
100422 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
100423 +free_coherent_3082 free_coherent 4-2 3082 NULL
100424 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
100425 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
100426 +rb_alloc_3102 rb_alloc 1 3102 NULL
100427 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
100428 +print_time_3132 print_time 0 3132 NULL
100429 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
100430 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
100431 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
100432 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
100433 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
100434 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
100435 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
100436 +alloc_context_3194 alloc_context 1 3194 NULL
100437 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
100438 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
100439 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
100440 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
100441 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
100442 +key_key_read_3241 key_key_read 3 3241 NULL
100443 +number_3243 number 0 3243 NULL
100444 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
100445 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
100446 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
100447 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
100448 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
100449 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
100450 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
100451 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
100452 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
100453 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
100454 +scnprintf_3360 scnprintf 0-2 3360 NULL
100455 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
100456 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
100457 +send_stream_3397 send_stream 4 3397 NULL
100458 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
100459 +msix_map_region_3411 msix_map_region 3 3411 NULL
100460 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
100461 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
100462 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
100463 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
100464 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
100465 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
100466 +map_single_3449 map_single 0-2 3449 NULL
100467 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
100468 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
100469 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
100470 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
100471 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
100472 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
100473 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
100474 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
100475 +SyS_readv_3539 SyS_readv 3 3539 NULL
100476 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
100477 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
100478 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
100479 +evtchn_read_3569 evtchn_read 3 3569 NULL
100480 +vc_resize_3585 vc_resize 2-3 3585 NULL
100481 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
100482 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
100483 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
100484 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
100485 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
100486 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
100487 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
100488 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
100489 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
100490 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
100491 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
100492 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
100493 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
100494 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
100495 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
100496 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
100497 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
100498 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
100499 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
100500 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
100501 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
100502 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
100503 +get_fd_set_3866 get_fd_set 1 3866 NULL
100504 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
100505 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
100506 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
100507 +nvram_write_3894 nvram_write 3 3894 NULL
100508 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
100509 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
100510 +vcs_write_3910 vcs_write 3 3910 NULL
100511 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
100512 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
100513 +do_add_counters_3992 do_add_counters 3 3992 NULL
100514 +userspace_status_4004 userspace_status 4 4004 NULL
100515 +mei_write_4005 mei_write 3 4005 NULL nohasharray
100516 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
100517 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
100518 +mm_populate_4016 mm_populate 1 4016 NULL
100519 +blk_end_request_4024 blk_end_request 3 4024 NULL
100520 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
100521 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
100522 +read_file_queues_4078 read_file_queues 3 4078 NULL
100523 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
100524 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
100525 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
100526 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
100527 +tm6000_read_4151 tm6000_read 3 4151 NULL
100528 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
100529 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
100530 +get_alua_req_4166 get_alua_req 3 4166 NULL
100531 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
100532 +read_file_bool_4180 read_file_bool 3 4180 NULL
100533 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
100534 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
100535 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
100536 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
100537 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
100538 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
100539 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
100540 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
100541 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
100542 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
100543 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
100544 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
100545 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
100546 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
100547 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
100548 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
100549 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
100550 +memparse_4444 memparse 0 4444 NULL
100551 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
100552 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
100553 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
100554 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
100555 +set_link_security_4502 set_link_security 4 4502 NULL
100556 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
100557 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
100558 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
100559 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
100560 +tty_register_device_4544 tty_register_device 2 4544 NULL
100561 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
100562 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
100563 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
100564 +bch_alloc_4593 bch_alloc 1 4593 NULL
100565 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
100566 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
100567 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
100568 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
100569 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
100570 +kone_receive_4690 kone_receive 4 4690 NULL
100571 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
100572 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
100573 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
100574 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
100575 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
100576 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
100577 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
100578 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
100579 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
100580 +create_subvol_4791 create_subvol 4 4791 NULL
100581 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
100582 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
100583 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
100584 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
100585 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
100586 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
100587 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
100588 +sys_ipc_4889 sys_ipc 3 4889 NULL
100589 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
100590 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
100591 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
100592 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
100593 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
100594 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
100595 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
100596 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
100597 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
100598 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
100599 +do_mincore_5018 do_mincore 0-1 5018 NULL
100600 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
100601 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
100602 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
100603 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
100604 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
100605 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
100606 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
100607 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
100608 +sound_write_5102 sound_write 3 5102 NULL
100609 +clear_dirty_5105 clear_dirty 3 5105 NULL
100610 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
100611 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
100612 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
100613 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
100614 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
100615 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
100616 +skb_network_header_5203 skb_network_header 0 5203 NULL
100617 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
100618 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
100619 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
100620 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
100621 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
100622 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
100623 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
100624 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
100625 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
100626 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
100627 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
100628 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
100629 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
100630 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
100631 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
100632 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
100633 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
100634 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
100635 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
100636 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
100637 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
100638 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
100639 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
100640 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
100641 +tty_write_5494 tty_write 3 5494 NULL
100642 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
100643 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
100644 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
100645 +spidev_message_5518 spidev_message 3 5518 NULL
100646 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
100647 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
100648 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
100649 +le_readq_5557 le_readq 0 5557 NULL
100650 +inw_5558 inw 0 5558 NULL
100651 +fir16_create_5574 fir16_create 3 5574 NULL
100652 +bioset_create_5580 bioset_create 1 5580 NULL
100653 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
100654 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
100655 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
100656 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
100657 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
100658 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
100659 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
100660 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
100661 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
100662 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
100663 +get_arg_5694 get_arg 3 5694 NULL
100664 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
100665 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
100666 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
100667 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
100668 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
100669 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
100670 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
100671 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
100672 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
100673 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
100674 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
100675 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
100676 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
100677 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
100678 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
100679 +setup_req_5848 setup_req 3 5848 NULL
100680 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
100681 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
100682 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
100683 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
100684 +port_show_regs_5904 port_show_regs 3 5904 NULL
100685 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
100686 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
100687 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
100688 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
100689 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
100690 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
100691 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
100692 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
100693 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
100694 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
100695 +native_pte_val_5978 native_pte_val 0 5978 NULL
100696 +SyS_semop_5980 SyS_semop 3 5980 NULL
100697 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
100698 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
100699 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
100700 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
100701 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
100702 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
100703 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
100704 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
100705 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
100706 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
100707 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
100708 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
100709 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
100710 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
100711 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
100712 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
100713 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
100714 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
100715 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
100716 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
100717 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
100718 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
100719 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
100720 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
100721 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
100722 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
100723 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
100724 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
100725 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
100726 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
100727 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
100728 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
100729 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
100730 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
100731 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
100732 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
100733 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
100734 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
100735 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
100736 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
100737 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
100738 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
100739 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
100740 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
100741 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
100742 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
100743 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
100744 +mei_read_6507 mei_read 3 6507 NULL
100745 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
100746 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
100747 +wdm_read_6549 wdm_read 3 6549 NULL
100748 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
100749 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
100750 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
100751 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
100752 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
100753 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
100754 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
100755 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
100756 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
100757 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
100758 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
100759 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
100760 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
100761 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
100762 +mpeg_read_6708 mpeg_read 3 6708 NULL
100763 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
100764 +video_proc_write_6724 video_proc_write 3 6724 NULL
100765 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
100766 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
100767 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
100768 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
100769 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
100770 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
100771 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
100772 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
100773 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
100774 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
100775 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
100776 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
100777 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
100778 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
100779 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
100780 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
100781 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
100782 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
100783 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
100784 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
100785 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
100786 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
100787 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
100788 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
100789 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
100790 +request_key_async_6990 request_key_async 4 6990 NULL
100791 +tpl_write_6998 tpl_write 3 6998 NULL
100792 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
100793 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
100794 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
100795 +wimax_msg_7030 wimax_msg 4 7030 NULL
100796 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
100797 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
100798 +event_enable_read_7074 event_enable_read 3 7074 NULL
100799 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
100800 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
100801 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
100802 +check_header_7108 check_header 0 7108 NULL
100803 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
100804 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
100805 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
100806 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
100807 +get_param_h_7247 get_param_h 0 7247 NULL
100808 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
100809 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
100810 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
100811 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
100812 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
100813 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
100814 +mgmt_control_7349 mgmt_control 3 7349 NULL
100815 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
100816 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
100817 +hweight_long_7388 hweight_long 0-1 7388 NULL
100818 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
100819 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
100820 +readb_7401 readb 0 7401 NULL
100821 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
100822 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
100823 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
100824 +numa_emulation_7466 numa_emulation 2 7466 NULL
100825 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
100826 +garp_request_join_7471 garp_request_join 4 7471 NULL
100827 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
100828 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
100829 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
100830 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
100831 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
100832 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
100833 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
100834 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
100835 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
100836 +groups_alloc_7614 groups_alloc 1 7614 NULL
100837 +sg_virt_7616 sg_virt 0 7616 NULL
100838 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
100839 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
100840 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
100841 +dev_write_7708 dev_write 3 7708 NULL
100842 +unmap_region_7709 unmap_region 1 7709 NULL
100843 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
100844 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
100845 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
100846 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
100847 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
100848 +ioread32be_7773 ioread32be 0 7773 NULL
100849 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
100850 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
100851 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
100852 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
100853 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
100854 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
100855 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
100856 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
100857 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
100858 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
100859 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
100860 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
100861 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
100862 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
100863 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
100864 +sys_mbind_7990 sys_mbind 5 7990 NULL
100865 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
100866 +vcs_read_8017 vcs_read 3 8017 NULL
100867 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
100868 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
100869 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
100870 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
100871 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
100872 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
100873 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
100874 +venus_lookup_8121 venus_lookup 4 8121 NULL
100875 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
100876 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
100877 +ore_truncate_8181 ore_truncate 3 8181 NULL
100878 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
100879 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
100880 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
100881 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
100882 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
100883 +play_iframe_8219 play_iframe 3 8219 NULL
100884 +create_log_8225 create_log 2 8225 NULL nohasharray
100885 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
100886 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
100887 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
100888 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
100889 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
100890 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
100891 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
100892 +init_cdev_8274 init_cdev 1 8274 NULL
100893 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
100894 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
100895 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
100896 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
100897 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
100898 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
100899 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
100900 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
100901 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
100902 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
100903 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
100904 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
100905 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
100906 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
100907 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
100908 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
100909 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
100910 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
100911 +dev_config_8506 dev_config 3 8506 NULL
100912 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
100913 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
100914 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
100915 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
100916 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
100917 +user_on_off_8552 user_on_off 2 8552 NULL
100918 +profile_remove_8556 profile_remove 3 8556 NULL
100919 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
100920 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
100921 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
100922 +tower_write_8580 tower_write 3 8580 NULL
100923 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
100924 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
100925 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
100926 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
100927 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
100928 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
100929 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
100930 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
100931 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
100932 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
100933 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
100934 +arcfb_write_8702 arcfb_write 3 8702 NULL
100935 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
100936 +init_header_8703 init_header 0 8703 &i_size_read_8703
100937 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
100938 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
100939 +f_dupfd_8730 f_dupfd 1 8730 NULL
100940 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
100941 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
100942 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
100943 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
100944 +sys_prctl_8766 sys_prctl 4 8766 NULL
100945 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
100946 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
100947 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
100948 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
100949 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
100950 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
100951 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
100952 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
100953 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
100954 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
100955 +clear_bitset_8840 clear_bitset 2 8840 NULL
100956 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
100957 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
100958 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
100959 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
100960 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
100961 +layout_commit_8926 layout_commit 3 8926 NULL
100962 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
100963 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
100964 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
100965 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
100966 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
100967 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
100968 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
100969 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
100970 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
100971 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
100972 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
100973 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
100974 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
100975 +nla_put_9042 nla_put 3 9042 NULL
100976 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
100977 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
100978 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
100979 +string_9080 string 0 9080 NULL
100980 +create_queues_9088 create_queues 2-3 9088 NULL
100981 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
100982 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
100983 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
100984 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
100985 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
100986 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
100987 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
100988 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
100989 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
100990 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
100991 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
100992 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
100993 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
100994 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
100995 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
100996 +get_pfn_9207 get_pfn 1 9207 NULL
100997 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
100998 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
100999 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
101000 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
101001 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
101002 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
101003 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
101004 +flakey_status_9274 flakey_status 5 9274 NULL
101005 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
101006 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
101007 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
101008 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
101009 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
101010 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
101011 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
101012 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
101013 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
101014 +read_9397 read 3 9397 NULL
101015 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
101016 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
101017 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
101018 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
101019 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
101020 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
101021 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
101022 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
101023 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
101024 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
101025 +lp_write_9511 lp_write 3 9511 NULL
101026 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
101027 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
101028 +read_file_dma_9530 read_file_dma 3 9530 NULL
101029 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
101030 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
101031 +fw_node_create_9559 fw_node_create 2 9559 NULL
101032 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
101033 +kobj_map_9566 kobj_map 2-3 9566 NULL
101034 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
101035 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
101036 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
101037 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
101038 +do_sync_9604 do_sync 1 9604 NULL
101039 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
101040 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
101041 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
101042 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
101043 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
101044 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
101045 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
101046 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
101047 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
101048 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
101049 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
101050 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
101051 +is_hole_9694 is_hole 2 9694 NULL nohasharray
101052 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
101053 +fnb_9703 fnb 2-3 9703 NULL
101054 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
101055 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
101056 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
101057 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
101058 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
101059 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
101060 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
101061 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
101062 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
101063 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
101064 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
101065 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
101066 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
101067 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
101068 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
101069 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
101070 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
101071 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
101072 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
101073 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
101074 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
101075 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
101076 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
101077 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
101078 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
101079 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
101080 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
101081 +read_file_misc_9948 read_file_misc 3 9948 NULL
101082 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
101083 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
101084 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
101085 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
101086 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
101087 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
101088 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
101089 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
101090 +handle_request_10024 handle_request 9 10024 NULL
101091 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
101092 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
101093 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
101094 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
101095 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
101096 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
101097 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
101098 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
101099 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
101100 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
101101 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
101102 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
101103 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
101104 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
101105 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
101106 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
101107 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
101108 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
101109 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
101110 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
101111 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
101112 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
101113 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
101114 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
101115 +read_emulate_10310 read_emulate 2-4 10310 NULL
101116 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
101117 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
101118 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
101119 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
101120 +get_dump_page_10338 get_dump_page 1 10338 NULL
101121 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
101122 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
101123 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
101124 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
101125 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
101126 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
101127 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
101128 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
101129 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
101130 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
101131 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
101132 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
101133 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
101134 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
101135 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
101136 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
101137 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
101138 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
101139 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
101140 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
101141 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
101142 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
101143 +otp_read_10594 otp_read 2-4-5 10594 NULL
101144 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
101145 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
101146 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
101147 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
101148 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
101149 +parport_write_10669 parport_write 0 10669 NULL
101150 +inl_10708 inl 0 10708 NULL nohasharray
101151 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
101152 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
101153 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
101154 +spi_sync_10731 spi_sync 0 10731 NULL
101155 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
101156 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
101157 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
101158 +sys_syslog_10746 sys_syslog 3 10746 NULL
101159 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
101160 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
101161 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
101162 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
101163 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
101164 +sys_bind_10799 sys_bind 3 10799 NULL
101165 +compat_put_int_10828 compat_put_int 1 10828 NULL
101166 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
101167 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
101168 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
101169 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
101170 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
101171 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
101172 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
101173 +get_scq_10897 get_scq 2 10897 NULL
101174 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
101175 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
101176 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
101177 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
101178 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
101179 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
101180 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
101181 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
101182 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
101183 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
101184 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
101185 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
101186 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
101187 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
101188 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
101189 +count_argc_11083 count_argc 0 11083 NULL
101190 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
101191 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
101192 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
101193 +page_offset_11120 page_offset 0 11120 NULL
101194 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
101195 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
101196 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
101197 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
101198 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
101199 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
101200 +__swab16p_11220 __swab16p 0 11220 NULL
101201 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
101202 +mmap_region_11247 mmap_region 0-2 11247 NULL
101203 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
101204 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
101205 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
101206 +cru_detect_11272 cru_detect 1 11272 NULL
101207 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
101208 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
101209 +construct_key_11329 construct_key 3 11329 NULL nohasharray
101210 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
101211 +next_segment_11330 next_segment 0-2-1 11330 NULL
101212 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
101213 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
101214 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
101215 +sel_write_create_11353 sel_write_create 3 11353 NULL
101216 +handle_unit_11355 handle_unit 0-1 11355 NULL
101217 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
101218 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
101219 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
101220 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
101221 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
101222 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
101223 +str_to_user_11411 str_to_user 2 11411 NULL
101224 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
101225 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
101226 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
101227 +trace_options_read_11419 trace_options_read 3 11419 NULL
101228 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
101229 +prepare_image_11424 prepare_image 0 11424 NULL
101230 +vring_size_11426 vring_size 0-1-2 11426 NULL
101231 +bttv_read_11432 bttv_read 3 11432 NULL
101232 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
101233 +swp_offset_11475 swp_offset 0 11475 NULL
101234 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
101235 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
101236 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
101237 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
101238 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
101239 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
101240 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
101241 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
101242 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
101243 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
101244 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
101245 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
101246 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
101247 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
101248 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
101249 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
101250 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
101251 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
101252 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
101253 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
101254 +split_11691 split 2 11691 NULL
101255 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
101256 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
101257 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
101258 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
101259 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
101260 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
101261 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
101262 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
101263 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
101264 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
101265 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
101266 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
101267 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
101268 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
101269 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
101270 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
101271 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
101272 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
101273 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
101274 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
101275 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
101276 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
101277 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
101278 +atmel_read16_11981 atmel_read16 0 11981 NULL
101279 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
101280 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
101281 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
101282 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
101283 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
101284 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
101285 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
101286 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
101287 +set_powered_12129 set_powered 4 12129 NULL
101288 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
101289 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
101290 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
101291 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
101292 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
101293 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
101294 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
101295 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
101296 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
101297 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
101298 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
101299 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
101300 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
101301 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
101302 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
101303 +scaled_div_12201 scaled_div 1-2 12201 NULL
101304 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
101305 +receive_copy_12216 receive_copy 3 12216 NULL
101306 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
101307 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
101308 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
101309 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
101310 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
101311 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
101312 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
101313 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
101314 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
101315 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
101316 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
101317 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
101318 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
101319 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
101320 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
101321 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
101322 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
101323 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
101324 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
101325 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
101326 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
101327 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
101328 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
101329 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
101330 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
101331 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
101332 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
101333 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
101334 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
101335 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
101336 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
101337 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
101338 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
101339 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
101340 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
101341 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
101342 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
101343 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
101344 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
101345 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
101346 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
101347 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
101348 +wb_create_12651 wb_create 1 12651 NULL
101349 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
101350 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
101351 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
101352 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
101353 +ivtv_write_12721 ivtv_write 3 12721 NULL
101354 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
101355 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
101356 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
101357 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
101358 +listxattr_12769 listxattr 3 12769 NULL
101359 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
101360 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
101361 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
101362 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
101363 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
101364 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
101365 +readq_12825 readq 0 12825 NULL
101366 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
101367 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
101368 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
101369 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
101370 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
101371 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
101372 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
101373 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
101374 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
101375 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
101376 +bm_status_write_12964 bm_status_write 3 12964 NULL
101377 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
101378 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
101379 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
101380 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
101381 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
101382 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
101383 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
101384 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
101385 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
101386 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
101387 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
101388 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
101389 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
101390 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
101391 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
101392 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
101393 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
101394 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
101395 +blk_update_request_13146 blk_update_request 3 13146 NULL
101396 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
101397 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
101398 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
101399 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
101400 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
101401 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
101402 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
101403 +comedi_read_13199 comedi_read 3 13199 NULL
101404 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
101405 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
101406 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
101407 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
101408 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
101409 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
101410 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
101411 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
101412 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
101413 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
101414 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
101415 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
101416 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
101417 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
101418 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
101419 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
101420 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
101421 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
101422 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
101423 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
101424 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
101425 +cache_ctr_13364 cache_ctr 2 13364 NULL
101426 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
101427 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
101428 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
101429 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
101430 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
101431 +sky2_receive_13407 sky2_receive 2 13407 NULL
101432 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
101433 +keyring_read_13438 keyring_read 3 13438 NULL
101434 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
101435 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
101436 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
101437 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
101438 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
101439 +core_status_13515 core_status 4 13515 NULL
101440 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
101441 +bm_init_13529 bm_init 2 13529 NULL
101442 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
101443 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
101444 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
101445 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
101446 +sys_madvise_13569 sys_madvise 1 13569 NULL
101447 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
101448 +cache_write_13589 cache_write 3 13589 NULL
101449 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
101450 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
101451 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
101452 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
101453 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
101454 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
101455 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
101456 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
101457 +packet_snd_13634 packet_snd 3 13634 NULL
101458 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
101459 +cache_downcall_13666 cache_downcall 3 13666 NULL
101460 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
101461 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
101462 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
101463 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
101464 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
101465 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
101466 +random_read_13815 random_read 3 13815 NULL
101467 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
101468 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
101469 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
101470 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
101471 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
101472 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
101473 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
101474 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
101475 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
101476 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
101477 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
101478 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
101479 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
101480 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
101481 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
101482 +com90xx_found_13974 com90xx_found 3 13974 NULL
101483 +qcam_read_13977 qcam_read 3 13977 NULL
101484 +dsp_read_13980 dsp_read 2 13980 NULL
101485 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
101486 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
101487 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
101488 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
101489 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
101490 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
101491 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
101492 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
101493 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
101494 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
101495 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
101496 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
101497 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
101498 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
101499 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
101500 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
101501 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
101502 +em_canid_change_14150 em_canid_change 3 14150 NULL
101503 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
101504 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
101505 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
101506 +alloc_async_14208 alloc_async 1 14208 NULL
101507 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
101508 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
101509 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
101510 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
101511 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
101512 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
101513 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
101514 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
101515 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
101516 +rr_status_14293 rr_status 5 14293 NULL
101517 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
101518 +oo_objects_14319 oo_objects 0 14319 NULL
101519 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
101520 +scsi2int_14358 scsi2int 0 14358 NULL
101521 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
101522 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
101523 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
101524 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
101525 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
101526 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
101527 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
101528 +block_size_14443 block_size 0 14443 NULL
101529 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
101530 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
101531 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
101532 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
101533 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
101534 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
101535 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
101536 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
101537 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
101538 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
101539 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
101540 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
101541 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
101542 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
101543 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
101544 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
101545 +dbJoin_14644 dbJoin 0 14644 NULL
101546 +profile_replace_14652 profile_replace 3 14652 NULL
101547 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
101548 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
101549 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
101550 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
101551 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
101552 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
101553 +get_bio_block_14714 get_bio_block 0 14714 NULL
101554 +vfd_write_14717 vfd_write 3 14717 NULL
101555 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
101556 +raid1_resize_14740 raid1_resize 2 14740 NULL
101557 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
101558 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
101559 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
101560 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
101561 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
101562 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
101563 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
101564 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
101565 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
101566 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
101567 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
101568 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
101569 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
101570 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
101571 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
101572 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
101573 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
101574 +unifi_read_14899 unifi_read 3 14899 NULL
101575 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
101576 +krealloc_14908 krealloc 2 14908 NULL
101577 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
101578 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
101579 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
101580 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
101581 +queue_cnt_14951 queue_cnt 0 14951 NULL
101582 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
101583 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
101584 +setkey_14987 setkey 3 14987 NULL nohasharray
101585 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
101586 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
101587 +vmap_15025 vmap 2 15025 NULL
101588 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
101589 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
101590 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
101591 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
101592 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
101593 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
101594 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
101595 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
101596 +start_port_15124 start_port 0 15124 NULL
101597 +memchr_15126 memchr 0 15126 NULL
101598 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
101599 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
101600 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
101601 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
101602 +reserve_resources_15194 reserve_resources 3 15194 NULL
101603 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
101604 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
101605 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
101606 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
101607 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
101608 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
101609 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
101610 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
101611 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
101612 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
101613 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
101614 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
101615 +ioread16_15342 ioread16 0 15342 NULL
101616 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
101617 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
101618 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
101619 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
101620 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
101621 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
101622 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
101623 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
101624 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
101625 +get_modalias_15406 get_modalias 2 15406 NULL
101626 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
101627 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
101628 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
101629 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
101630 +memweight_15450 memweight 2 15450 NULL
101631 +vmalloc_15464 vmalloc 1 15464 NULL
101632 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
101633 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
101634 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
101635 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
101636 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
101637 +persistent_status_15574 persistent_status 4 15574 NULL
101638 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
101639 +vme_user_write_15587 vme_user_write 3 15587 NULL
101640 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
101641 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
101642 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
101643 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
101644 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
101645 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
101646 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
101647 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
101648 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
101649 +fs_path_add_15648 fs_path_add 3 15648 NULL
101650 +xsd_read_15653 xsd_read 3 15653 NULL
101651 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
101652 +unix_bind_15668 unix_bind 3 15668 NULL
101653 +dm_read_15674 dm_read 3 15674 NULL
101654 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
101655 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
101656 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
101657 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
101658 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
101659 +do_test_15766 do_test 1 15766 NULL
101660 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
101661 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
101662 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
101663 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
101664 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
101665 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
101666 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
101667 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
101668 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
101669 +table_size_15851 table_size 0-1-2 15851 NULL
101670 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
101671 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
101672 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
101673 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
101674 +native_read_msr_15905 native_read_msr 0 15905 NULL
101675 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
101676 +power_read_15939 power_read 3 15939 NULL
101677 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
101678 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
101679 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
101680 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
101681 +frame_alloc_15981 frame_alloc 4 15981 NULL
101682 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
101683 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
101684 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
101685 +got_frame_16028 got_frame 2 16028 NULL
101686 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
101687 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
101688 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
101689 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
101690 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
101691 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
101692 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
101693 +fsm_init_16134 fsm_init 2 16134 NULL
101694 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
101695 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
101696 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
101697 +mapping_level_16188 mapping_level 2 16188 NULL
101698 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
101699 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
101700 +create_table_16213 create_table 2 16213 NULL
101701 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
101702 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
101703 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
101704 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
101705 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
101706 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
101707 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
101708 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
101709 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
101710 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
101711 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
101712 +account_16283 account 0-2-4 16283 NULL nohasharray
101713 +mirror_status_16283 mirror_status 5 16283 &account_16283
101714 +retry_instruction_16285 retry_instruction 2 16285 NULL
101715 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
101716 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
101717 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
101718 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
101719 +wb_map_16301 wb_map 2 16301 NULL
101720 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
101721 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
101722 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
101723 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
101724 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
101725 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
101726 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
101727 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
101728 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
101729 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
101730 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
101731 +raid10_resize_16537 raid10_resize 2 16537 NULL
101732 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
101733 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
101734 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
101735 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
101736 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
101737 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
101738 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
101739 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
101740 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
101741 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
101742 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
101743 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
101744 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
101745 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
101746 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
101747 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
101748 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
101749 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
101750 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
101751 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
101752 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
101753 +st_write_16874 st_write 3 16874 NULL
101754 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
101755 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
101756 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
101757 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
101758 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
101759 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
101760 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
101761 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
101762 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
101763 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
101764 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
101765 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
101766 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
101767 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
101768 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
101769 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
101770 +mac_address_string_17091 mac_address_string 0 17091 NULL
101771 +entry_length_17093 entry_length 0 17093 NULL
101772 +sys_preadv_17100 sys_preadv 3 17100 NULL
101773 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
101774 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
101775 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
101776 +sep_read_17161 sep_read 3 17161 NULL
101777 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
101778 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
101779 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
101780 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
101781 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
101782 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
101783 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
101784 +to_oblock_17254 to_oblock 0-1 17254 NULL
101785 +unpack_value_17259 unpack_value 1 17259 NULL
101786 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
101787 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
101788 +alloc_ep_17269 alloc_ep 1 17269 NULL
101789 +pg_read_17276 pg_read 3 17276 NULL
101790 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
101791 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
101792 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
101793 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
101794 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
101795 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
101796 +skb_pad_17302 skb_pad 2 17302 NULL
101797 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
101798 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
101799 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
101800 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
101801 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
101802 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
101803 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
101804 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
101805 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
101806 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
101807 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
101808 +compat_cmd_17465 compat_cmd 2 17465 NULL
101809 +probe_bios_17467 probe_bios 1 17467 NULL
101810 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
101811 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
101812 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
101813 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
101814 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
101815 +copy_from_user_17559 copy_from_user 3 17559 NULL
101816 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
101817 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
101818 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
101819 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
101820 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
101821 +osst_execute_17607 osst_execute 7-6 17607 NULL
101822 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
101823 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
101824 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
101825 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
101826 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
101827 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
101828 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
101829 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
101830 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
101831 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
101832 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
101833 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
101834 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
101835 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
101836 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
101837 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
101838 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
101839 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
101840 +perf_clock_17787 perf_clock 0 17787 NULL
101841 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
101842 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
101843 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
101844 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
101845 +count_leafs_17842 count_leafs 0 17842 NULL
101846 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
101847 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
101848 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
101849 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
101850 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
101851 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
101852 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
101853 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
101854 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
101855 +recover_head_17904 recover_head 3 17904 NULL
101856 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
101857 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
101858 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
101859 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
101860 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
101861 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
101862 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
101863 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
101864 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
101865 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
101866 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
101867 +fill_read_18019 fill_read 0 18019 NULL
101868 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
101869 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
101870 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
101871 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
101872 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
101873 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
101874 +packet_came_18072 packet_came 3 18072 NULL
101875 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
101876 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
101877 +get_vm_area_18080 get_vm_area 1 18080 NULL
101878 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
101879 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
101880 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
101881 +svc_getnl_18120 svc_getnl 0 18120 NULL
101882 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
101883 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
101884 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
101885 +_has_tag_18169 _has_tag 2 18169 NULL
101886 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
101887 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
101888 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
101889 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
101890 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
101891 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
101892 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
101893 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
101894 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
101895 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
101896 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
101897 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
101898 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
101899 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
101900 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
101901 +um_idi_write_18293 um_idi_write 3 18293 NULL
101902 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
101903 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
101904 +vga_r_18310 vga_r 0 18310 NULL
101905 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
101906 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
101907 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
101908 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
101909 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
101910 +ep_io_18367 ep_io 0 18367 NULL
101911 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
101912 +ci_role_write_18388 ci_role_write 3 18388 NULL
101913 +__video_register_device_18399 __video_register_device 3 18399 NULL
101914 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
101915 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
101916 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
101917 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
101918 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
101919 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
101920 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
101921 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
101922 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
101923 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
101924 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
101925 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
101926 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
101927 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
101928 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
101929 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
101930 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
101931 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
101932 +debug_output_18575 debug_output 3 18575 NULL
101933 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
101934 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
101935 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
101936 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
101937 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
101938 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
101939 +from_buffer_18625 from_buffer 3 18625 NULL
101940 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
101941 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
101942 +unmap_page_18665 unmap_page 2-3 18665 NULL
101943 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
101944 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
101945 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
101946 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
101947 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
101948 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
101949 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
101950 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
101951 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
101952 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
101953 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
101954 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
101955 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
101956 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
101957 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
101958 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
101959 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
101960 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
101961 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
101962 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
101963 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
101964 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
101965 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
101966 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
101967 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
101968 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
101969 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
101970 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
101971 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
101972 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
101973 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
101974 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
101975 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
101976 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
101977 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
101978 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
101979 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
101980 +huge_page_size_19008 huge_page_size 0 19008 NULL
101981 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
101982 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
101983 +revalidate_19043 revalidate 2 19043 NULL
101984 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
101985 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
101986 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
101987 +msix_map_region_19072 msix_map_region 2 19072 NULL
101988 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
101989 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
101990 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
101991 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
101992 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
101993 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
101994 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
101995 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
101996 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
101997 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
101998 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
101999 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
102000 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
102001 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
102002 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
102003 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
102004 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
102005 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
102006 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
102007 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
102008 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
102009 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
102010 +qc_capture_19298 qc_capture 3 19298 NULL
102011 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
102012 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
102013 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
102014 +debug_read_19322 debug_read 3 19322 NULL
102015 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
102016 +closure_sub_19359 closure_sub 2 19359 NULL
102017 +read_zero_19366 read_zero 3 19366 NULL
102018 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
102019 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
102020 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
102021 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
102022 +__phys_addr_19434 __phys_addr 0 19434 NULL
102023 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
102024 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
102025 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
102026 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
102027 +sky2_read16_19475 sky2_read16 0 19475 NULL
102028 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
102029 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
102030 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
102031 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
102032 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
102033 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
102034 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
102035 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
102036 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
102037 +nfsd_read_19568 nfsd_read 5 19568 NULL
102038 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
102039 +bm_status_read_19583 bm_status_read 3 19583 NULL
102040 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
102041 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
102042 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
102043 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
102044 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
102045 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
102046 +bio_detain_19690 bio_detain 2 19690 NULL
102047 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
102048 +read_reg_19723 read_reg 0 19723 NULL
102049 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
102050 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
102051 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
102052 +p9_client_read_19750 p9_client_read 5 19750 NULL
102053 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
102054 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
102055 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
102056 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
102057 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
102058 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
102059 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
102060 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
102061 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
102062 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
102063 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
102064 +__nla_put_19857 __nla_put 3 19857 NULL
102065 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
102066 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
102067 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
102068 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
102069 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
102070 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
102071 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
102072 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
102073 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
102074 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
102075 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
102076 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
102077 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
102078 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
102079 +team_options_register_20091 team_options_register 3 20091 NULL
102080 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
102081 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
102082 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
102083 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
102084 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
102085 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
102086 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
102087 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
102088 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
102089 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
102090 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
102091 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
102092 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
102093 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
102094 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
102095 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
102096 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
102097 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
102098 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
102099 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
102100 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
102101 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
102102 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
102103 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
102104 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
102105 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
102106 +read_buf_20469 read_buf 2 20469 NULL
102107 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
102108 +fast_user_write_20494 fast_user_write 5 20494 NULL
102109 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
102110 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
102111 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
102112 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
102113 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
102114 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
102115 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
102116 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
102117 +venus_create_20555 venus_create 4 20555 NULL
102118 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
102119 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
102120 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
102121 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
102122 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
102123 +lirc_write_20604 lirc_write 3 20604 NULL
102124 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
102125 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
102126 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
102127 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
102128 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
102129 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
102130 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
102131 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
102132 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
102133 +cpumask_size_20683 cpumask_size 0 20683 NULL
102134 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
102135 +gru_vtop_20689 gru_vtop 2 20689 NULL
102136 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
102137 +__maestro_read_20700 __maestro_read 0 20700 NULL
102138 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
102139 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
102140 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
102141 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
102142 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
102143 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
102144 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
102145 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
102146 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
102147 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
102148 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
102149 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
102150 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
102151 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
102152 +sys_sendto_20809 sys_sendto 6 20809 NULL
102153 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
102154 +strndup_user_20819 strndup_user 2 20819 NULL
102155 +calc_layout_20829 calc_layout 3 20829 NULL
102156 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
102157 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
102158 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
102159 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
102160 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
102161 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
102162 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
102163 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
102164 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
102165 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
102166 +htable_bits_20933 htable_bits 0 20933 NULL
102167 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
102168 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
102169 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
102170 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
102171 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
102172 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
102173 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
102174 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
102175 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
102176 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
102177 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
102178 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
102179 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
102180 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
102181 +multipath_status_21094 multipath_status 5 21094 NULL
102182 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
102183 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
102184 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
102185 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
102186 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
102187 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
102188 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
102189 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
102190 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
102191 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
102192 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
102193 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
102194 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
102195 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
102196 +input_ff_create_21240 input_ff_create 2 21240 NULL
102197 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
102198 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
102199 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
102200 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
102201 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
102202 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
102203 +add_res_range_21310 add_res_range 4 21310 NULL
102204 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
102205 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
102206 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
102207 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
102208 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
102209 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
102210 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
102211 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
102212 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
102213 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
102214 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
102215 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
102216 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
102217 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
102218 +concat_writev_21451 concat_writev 3 21451 NULL
102219 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
102220 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
102221 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
102222 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
102223 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
102224 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
102225 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
102226 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
102227 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
102228 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
102229 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
102230 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
102231 +validate_nnode_21638 validate_nnode 0 21638 NULL
102232 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
102233 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
102234 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
102235 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
102236 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
102237 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
102238 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
102239 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
102240 +vm_brk_21739 vm_brk 1 21739 NULL
102241 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
102242 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
102243 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
102244 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
102245 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
102246 +min_odd_21802 min_odd 0 21802 NULL
102247 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
102248 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
102249 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
102250 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
102251 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
102252 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
102253 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
102254 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
102255 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
102256 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
102257 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
102258 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
102259 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
102260 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
102261 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
102262 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
102263 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
102264 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
102265 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
102266 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
102267 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
102268 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
102269 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
102270 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
102271 +write_opcode_22082 write_opcode 2 22082 NULL
102272 +mem_rw_22085 mem_rw 3 22085 NULL
102273 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
102274 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
102275 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
102276 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
102277 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
102278 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
102279 +compat_insn_22142 compat_insn 2 22142 NULL
102280 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
102281 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
102282 +fls_22210 fls 0 22210 NULL
102283 +mem_write_22232 mem_write 3 22232 NULL
102284 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
102285 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
102286 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
102287 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
102288 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
102289 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
102290 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
102291 +extend_brk_22301 extend_brk 0 22301 NULL
102292 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
102293 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
102294 +get_segment_base_22324 get_segment_base 0 22324 NULL
102295 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
102296 +atomic_read_22342 atomic_read 0 22342 NULL
102297 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
102298 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
102299 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
102300 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
102301 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
102302 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
102303 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
102304 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
102305 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
102306 +zoran_write_22404 zoran_write 3 22404 NULL
102307 +queue_reply_22416 queue_reply 3 22416 NULL
102308 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
102309 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
102310 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
102311 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
102312 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
102313 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
102314 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
102315 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
102316 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
102317 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
102318 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
102319 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
102320 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
102321 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
102322 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
102323 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
102324 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
102325 +snapshot_read_22601 snapshot_read 3 22601 NULL
102326 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
102327 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
102328 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
102329 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
102330 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
102331 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
102332 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
102333 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
102334 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
102335 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
102336 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
102337 +map_22700 map 2 22700 NULL
102338 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
102339 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
102340 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
102341 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
102342 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
102343 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
102344 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
102345 +print_frame_22769 print_frame 0 22769 NULL
102346 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
102347 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
102348 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
102349 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
102350 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
102351 +create_attr_set_22861 create_attr_set 1 22861 NULL
102352 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
102353 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
102354 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
102355 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
102356 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
102357 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
102358 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
102359 +vme_get_size_22964 vme_get_size 0 22964 NULL
102360 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
102361 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
102362 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
102363 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
102364 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
102365 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
102366 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
102367 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
102368 +st_status_23032 st_status 5 23032 NULL
102369 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
102370 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
102371 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
102372 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
102373 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
102374 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
102375 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
102376 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
102377 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
102378 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
102379 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
102380 +fls_long_23096 fls_long 0 23096 NULL
102381 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
102382 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
102383 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
102384 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
102385 +__clear_user_23118 __clear_user 0 23118 NULL
102386 +dm_write_async_23120 dm_write_async 3 23120 NULL
102387 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
102388 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
102389 +read_file_ani_23161 read_file_ani 3 23161 NULL
102390 +ioremap_23172 ioremap 1-2 23172 NULL
102391 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
102392 +usblp_write_23178 usblp_write 3 23178 NULL
102393 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
102394 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
102395 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
102396 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
102397 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
102398 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
102399 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
102400 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
102401 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
102402 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
102403 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
102404 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
102405 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
102406 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
102407 +doc_probe_23285 doc_probe 1 23285 NULL
102408 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
102409 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
102410 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
102411 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
102412 +page_readlink_23346 page_readlink 3 23346 NULL
102413 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
102414 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
102415 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
102416 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
102417 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
102418 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
102419 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
102420 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
102421 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
102422 +event_filter_read_23494 event_filter_read 3 23494 NULL
102423 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
102424 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
102425 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
102426 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
102427 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
102428 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
102429 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
102430 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
102431 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
102432 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
102433 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
102434 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
102435 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
102436 +sInW_23663 sInW 0 23663 NULL
102437 +SyS_connect_23669 SyS_connect 3 23669 NULL
102438 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
102439 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
102440 +cx18_read_23699 cx18_read 3 23699 NULL
102441 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
102442 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
102443 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
102444 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
102445 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
102446 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
102447 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
102448 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
102449 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
102450 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
102451 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
102452 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
102453 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
102454 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
102455 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
102456 +p54_init_common_23850 p54_init_common 1 23850 NULL
102457 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
102458 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
102459 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
102460 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
102461 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
102462 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
102463 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
102464 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
102465 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
102466 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
102467 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
102468 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
102469 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
102470 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
102471 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
102472 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
102473 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
102474 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
102475 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
102476 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
102477 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
102478 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
102479 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
102480 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
102481 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
102482 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
102483 +mpu401_read_24126 mpu401_read 3 24126 NULL
102484 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
102485 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
102486 +set_discard_24162 set_discard 2 24162 NULL
102487 +adu_read_24177 adu_read 3 24177 NULL
102488 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
102489 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
102490 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
102491 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
102492 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
102493 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
102494 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
102495 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
102496 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
102497 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
102498 +thin_status_24278 thin_status 5 24278 NULL
102499 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
102500 +msg_size_24288 msg_size 0 24288 NULL
102501 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
102502 +map_page_24298 map_page 3-4 24298 NULL
102503 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
102504 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
102505 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
102506 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
102507 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
102508 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
102509 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
102510 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
102511 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
102512 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
102513 +igetword_24373 igetword 0 24373 NULL
102514 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
102515 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
102516 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
102517 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
102518 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
102519 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
102520 +smk_user_access_24440 smk_user_access 3 24440 NULL
102521 +page_address_24444 page_address 0 24444 NULL
102522 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
102523 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
102524 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
102525 +pd_video_read_24510 pd_video_read 3 24510 NULL
102526 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
102527 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
102528 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
102529 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
102530 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
102531 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
102532 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
102533 +count_preds_24600 count_preds 0 24600 NULL
102534 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
102535 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
102536 +context_alloc_24645 context_alloc 3 24645 NULL
102537 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
102538 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
102539 +read_fs_24717 read_fs 0 24717 NULL
102540 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
102541 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
102542 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
102543 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
102544 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
102545 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
102546 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
102547 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
102548 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
102549 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
102550 +cache_read_24790 cache_read 3 24790 NULL
102551 +unpack_str_24798 unpack_str 0 24798 NULL
102552 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
102553 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
102554 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
102555 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
102556 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
102557 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
102558 +setup_buffering_24872 setup_buffering 3 24872 NULL
102559 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
102560 +queues_read_24877 queues_read 3 24877 NULL nohasharray
102561 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
102562 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
102563 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
102564 +next_token_24929 next_token 0 24929 NULL
102565 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
102566 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
102567 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
102568 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
102569 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
102570 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
102571 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
102572 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
102573 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
102574 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
102575 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
102576 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
102577 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
102578 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
102579 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
102580 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
102581 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
102582 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
102583 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
102584 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
102585 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
102586 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
102587 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
102588 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
102589 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
102590 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
102591 +stripe_status_25259 stripe_status 5 25259 NULL
102592 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
102593 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
102594 +vfs_writev_25278 vfs_writev 3 25278 NULL
102595 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
102596 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
102597 +help_25316 help 5 25316 NULL nohasharray
102598 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
102599 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
102600 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
102601 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
102602 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
102603 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
102604 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
102605 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
102606 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
102607 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
102608 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
102609 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
102610 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
102611 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
102612 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
102613 +sb_permission_25523 sb_permission 0 25523 NULL
102614 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
102615 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
102616 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
102617 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
102618 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
102619 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
102620 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
102621 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
102622 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
102623 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
102624 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
102625 +__direct_map_25647 __direct_map 5-6 25647 NULL
102626 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
102627 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
102628 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
102629 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
102630 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
102631 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
102632 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
102633 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
102634 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
102635 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
102636 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
102637 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
102638 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
102639 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
102640 +sg_read_25799 sg_read 3 25799 NULL
102641 +system_enable_read_25815 system_enable_read 3 25815 NULL
102642 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
102643 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
102644 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
102645 +parport_read_25855 parport_read 0 25855 NULL
102646 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
102647 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
102648 +key_attr_size_25865 key_attr_size 0 25865 NULL
102649 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
102650 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
102651 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
102652 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
102653 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
102654 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
102655 +rcname_read_25919 rcname_read 3 25919 NULL
102656 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
102657 +key_flags_read_25931 key_flags_read 3 25931 NULL
102658 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
102659 +flush_25957 flush 2 25957 NULL
102660 +video_register_device_25971 video_register_device 3 25971 NULL
102661 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
102662 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
102663 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
102664 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
102665 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
102666 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
102667 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
102668 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
102669 +tun_do_read_26047 tun_do_read 5 26047 NULL
102670 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
102671 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
102672 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
102673 +skb_cow_26138 skb_cow 2 26138 NULL
102674 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
102675 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
102676 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
102677 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
102678 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
102679 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
102680 +disk_devt_26180 disk_devt 0 26180 NULL
102681 +get_registers_26187 get_registers 3 26187 NULL
102682 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
102683 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
102684 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
102685 +mce_write_26201 mce_write 3 26201 NULL
102686 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
102687 +bio_split_26235 bio_split 2 26235 NULL
102688 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
102689 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
102690 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
102691 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
102692 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
102693 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
102694 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
102695 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
102696 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
102697 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
102698 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
102699 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
102700 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
102701 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
102702 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
102703 +read_vmcore_26501 read_vmcore 3 26501 NULL
102704 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
102705 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
102706 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
102707 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
102708 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
102709 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
102710 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
102711 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
102712 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
102713 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
102714 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
102715 +pack_value_26625 pack_value 1 26625 NULL
102716 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
102717 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
102718 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
102719 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
102720 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
102721 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
102722 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
102723 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
102724 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
102725 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
102726 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
102727 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
102728 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
102729 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
102730 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
102731 +smk_write_load_26829 smk_write_load 3 26829 NULL
102732 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
102733 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
102734 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
102735 +scnprint_id_26842 scnprint_id 3 26842 NULL
102736 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
102737 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
102738 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
102739 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
102740 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
102741 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
102742 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
102743 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
102744 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
102745 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
102746 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
102747 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
102748 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
102749 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
102750 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
102751 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
102752 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
102753 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
102754 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
102755 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
102756 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
102757 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
102758 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
102759 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
102760 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
102761 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
102762 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
102763 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
102764 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
102765 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
102766 +pms_capture_27142 pms_capture 4 27142 NULL
102767 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
102768 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
102769 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
102770 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
102771 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
102772 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
102773 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
102774 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
102775 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
102776 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
102777 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
102778 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
102779 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
102780 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
102781 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
102782 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
102783 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
102784 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
102785 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
102786 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
102787 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
102788 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
102789 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
102790 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
102791 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
102792 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
102793 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
102794 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
102795 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
102796 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
102797 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
102798 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
102799 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
102800 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
102801 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
102802 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
102803 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
102804 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
102805 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
102806 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
102807 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
102808 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
102809 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
102810 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
102811 +qword_get_27670 qword_get 0 27670 NULL
102812 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
102813 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
102814 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
102815 +evm_write_key_27715 evm_write_key 3 27715 NULL
102816 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
102817 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
102818 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
102819 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
102820 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
102821 +kcalloc_27770 kcalloc 1-2 27770 NULL
102822 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
102823 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
102824 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
102825 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
102826 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
102827 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
102828 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
102829 +read_profile_27859 read_profile 3 27859 NULL
102830 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
102831 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
102832 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
102833 +gluebi_write_27905 gluebi_write 3 27905 NULL
102834 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
102835 +bm_find_next_27929 bm_find_next 2 27929 NULL
102836 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
102837 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
102838 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
102839 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
102840 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
102841 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
102842 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
102843 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
102844 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
102845 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
102846 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
102847 +pool_status_28055 pool_status 5 28055 NULL
102848 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
102849 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
102850 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
102851 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
102852 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
102853 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
102854 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
102855 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
102856 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
102857 +video_read_28148 video_read 3 28148 NULL
102858 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
102859 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
102860 +vread_28173 vread 0 28173 NULL
102861 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
102862 +d_path_28198 d_path 0 28198 NULL
102863 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
102864 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
102865 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
102866 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
102867 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
102868 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
102869 +usemap_size_28281 usemap_size 0 28281 NULL
102870 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
102871 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
102872 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
102873 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
102874 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
102875 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
102876 +snapshot_write_28351 snapshot_write 3 28351 NULL
102877 +sys_writev_28384 sys_writev 3 28384 NULL
102878 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
102879 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
102880 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
102881 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
102882 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
102883 +__split_large_page_28429 __split_large_page 2 28429 NULL
102884 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
102885 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
102886 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
102887 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
102888 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
102889 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
102890 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
102891 +max_response_pages_28492 max_response_pages 0 28492 NULL
102892 +clear_discard_28494 clear_discard 2 28494 NULL
102893 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
102894 +__next_node_28521 __next_node 1 28521 NULL
102895 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
102896 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
102897 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
102898 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
102899 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
102900 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
102901 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
102902 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
102903 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
102904 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
102905 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
102906 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
102907 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
102908 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
102909 +_set_range_28627 _set_range 3 28627 NULL
102910 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
102911 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
102912 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
102913 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
102914 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
102915 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
102916 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
102917 +spi_execute_28736 spi_execute 5 28736 NULL
102918 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
102919 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
102920 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
102921 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
102922 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
102923 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
102924 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
102925 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
102926 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
102927 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
102928 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
102929 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
102930 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
102931 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
102932 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
102933 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
102934 +to_cblock_28899 to_cblock 0-1 28899 NULL
102935 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
102936 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
102937 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
102938 +push_rx_28939 push_rx 3 28939 NULL
102939 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
102940 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
102941 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
102942 +bin_uuid_28999 bin_uuid 3 28999 NULL
102943 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
102944 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
102945 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
102946 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
102947 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
102948 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
102949 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
102950 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
102951 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
102952 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
102953 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
102954 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
102955 +snprintf_29125 snprintf 0 29125 NULL
102956 +iov_shorten_29130 iov_shorten 0 29130 NULL
102957 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
102958 +reshape_ring_29147 reshape_ring 2 29147 NULL
102959 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
102960 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
102961 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
102962 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
102963 +__mm_populate_29204 __mm_populate 1 29204 NULL
102964 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
102965 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
102966 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
102967 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
102968 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
102969 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
102970 +recover_peb_29238 recover_peb 6-7 29238 NULL
102971 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
102972 +block_div_29268 block_div 0-1-2 29268 NULL
102973 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
102974 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
102975 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
102976 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
102977 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
102978 +tun_put_user_29337 tun_put_user 5 29337 NULL
102979 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
102980 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
102981 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
102982 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
102983 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
102984 +mempool_create_29437 mempool_create 1 29437 NULL
102985 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
102986 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
102987 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
102988 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
102989 +do_register_entry_29478 do_register_entry 4 29478 NULL
102990 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
102991 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
102992 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
102993 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
102994 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
102995 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
102996 +set_brk_29551 set_brk 1 29551 NULL nohasharray
102997 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
102998 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
102999 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
103000 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
103001 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
103002 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
103003 +slots_per_page_29601 slots_per_page 0 29601 NULL
103004 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
103005 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
103006 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
103007 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
103008 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
103009 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
103010 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
103011 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
103012 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
103013 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
103014 +probes_write_29711 probes_write 3 29711 NULL
103015 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
103016 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
103017 +std_nic_write_29752 std_nic_write 3 29752 NULL
103018 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
103019 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
103020 +dbAlloc_29794 dbAlloc 0 29794 NULL
103021 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
103022 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
103023 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
103024 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
103025 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
103026 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
103027 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
103028 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
103029 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
103030 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
103031 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
103032 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
103033 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
103034 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
103035 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
103036 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
103037 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
103038 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
103039 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
103040 +drp_wmove_30043 drp_wmove 4 30043 NULL
103041 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
103042 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
103043 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
103044 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
103045 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
103046 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
103047 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
103048 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
103049 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
103050 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
103051 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
103052 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
103053 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
103054 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
103055 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
103056 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
103057 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
103058 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
103059 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
103060 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
103061 +compat_readv_30273 compat_readv 3 30273 NULL
103062 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
103063 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
103064 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
103065 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
103066 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
103067 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
103068 +resource_from_user_30341 resource_from_user 3 30341 NULL
103069 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
103070 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
103071 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
103072 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
103073 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
103074 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
103075 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
103076 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
103077 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
103078 +mq_create_30425 mq_create 1 30425 NULL
103079 +enable_write_30456 enable_write 3 30456 NULL
103080 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
103081 +urandom_read_30462 urandom_read 3 30462 NULL
103082 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
103083 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
103084 +write_head_30481 write_head 4 30481 NULL
103085 +adu_write_30487 adu_write 3 30487 NULL
103086 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
103087 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
103088 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
103089 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
103090 +set_le_30581 set_le 4 30581 NULL
103091 +from_cblock_30582 from_cblock 0-1 30582 NULL
103092 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
103093 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
103094 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
103095 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
103096 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
103097 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
103098 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
103099 +agp_remap_30665 agp_remap 2 30665 NULL
103100 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
103101 +il_free_pages_30692 il_free_pages 2 30692 NULL
103102 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
103103 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
103104 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
103105 +snapshot_status_30744 snapshot_status 5 30744 NULL
103106 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
103107 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
103108 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
103109 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
103110 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
103111 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
103112 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
103113 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
103114 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
103115 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
103116 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
103117 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
103118 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
103119 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
103120 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
103121 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
103122 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
103123 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
103124 +sys_mincore_31079 sys_mincore 1 31079 NULL
103125 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
103126 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
103127 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
103128 +depth_read_31112 depth_read 3 31112 NULL
103129 +ssb_read16_31139 ssb_read16 0 31139 NULL
103130 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
103131 +size_inside_page_31141 size_inside_page 0 31141 NULL
103132 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
103133 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
103134 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
103135 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
103136 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
103137 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
103138 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
103139 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
103140 +__read_reg_31216 __read_reg 0 31216 NULL
103141 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
103142 +cyy_readb_31240 cyy_readb 0 31240 NULL
103143 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
103144 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
103145 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
103146 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
103147 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
103148 +command_file_write_31318 command_file_write 3 31318 NULL
103149 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
103150 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
103151 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
103152 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
103153 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
103154 +inb_31388 inb 0 31388 NULL
103155 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
103156 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
103157 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
103158 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
103159 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
103160 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
103161 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
103162 +do_fcntl_31468 do_fcntl 3 31468 NULL
103163 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
103164 +alg_setkey_31485 alg_setkey 3 31485 NULL
103165 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
103166 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
103167 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
103168 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
103169 +hidraw_write_31536 hidraw_write 3 31536 NULL
103170 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
103171 +usbvision_read_31555 usbvision_read 3 31555 NULL
103172 +normalize_31566 normalize 0-1-2 31566 NULL
103173 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
103174 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
103175 +osst_write_31581 osst_write 3 31581 NULL
103176 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
103177 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
103178 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
103179 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
103180 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
103181 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
103182 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
103183 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
103184 +__lgread_31668 __lgread 4 31668 NULL
103185 +symbol_string_31670 symbol_string 0 31670 NULL
103186 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
103187 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
103188 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
103189 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
103190 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
103191 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
103192 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
103193 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
103194 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
103195 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
103196 +muldiv64_31743 muldiv64 2-3 31743 NULL
103197 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
103198 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
103199 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
103200 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
103201 +get_count_order_31800 get_count_order 0 31800 NULL
103202 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
103203 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
103204 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
103205 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
103206 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
103207 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
103208 +xattr_permission_31907 xattr_permission 0 31907 NULL
103209 +new_dir_31919 new_dir 3 31919 NULL
103210 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
103211 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
103212 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
103213 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
103214 +vb2_write_31948 vb2_write 3 31948 NULL
103215 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
103216 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
103217 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
103218 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
103219 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
103220 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
103221 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
103222 +calc_hmac_32010 calc_hmac 3 32010 NULL
103223 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
103224 +aead_len_32021 aead_len 0 32021 NULL
103225 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
103226 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
103227 +stk_read_32038 stk_read 3 32038 NULL
103228 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
103229 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
103230 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
103231 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
103232 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
103233 +bio_alloc_32095 bio_alloc 2 32095 NULL
103234 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
103235 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
103236 +disk_status_32120 disk_status 4 32120 NULL
103237 +venus_link_32165 venus_link 5 32165 NULL
103238 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
103239 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
103240 +load_header_32183 load_header 0 32183 NULL
103241 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
103242 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
103243 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
103244 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
103245 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
103246 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
103247 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
103248 +hex_string_32310 hex_string 0 32310 NULL
103249 +SyS_select_32319 SyS_select 1 32319 NULL
103250 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
103251 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
103252 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
103253 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
103254 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
103255 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
103256 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
103257 +local_clock_32385 local_clock 0 32385 NULL
103258 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
103259 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
103260 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
103261 +log_text_32428 log_text 0 32428 NULL
103262 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
103263 +hid_input_report_32458 hid_input_report 4 32458 NULL
103264 +cache_status_32462 cache_status 5 32462 NULL
103265 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
103266 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
103267 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
103268 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
103269 +disconnect_32521 disconnect 4 32521 NULL
103270 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
103271 +ilo_read_32531 ilo_read 3 32531 NULL
103272 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
103273 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
103274 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
103275 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
103276 +__first_node_32558 __first_node 0 32558 NULL
103277 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
103278 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
103279 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
103280 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
103281 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
103282 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
103283 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
103284 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
103285 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
103286 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
103287 +kvmalloc_32646 kvmalloc 1 32646 NULL
103288 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
103289 +generic_readlink_32654 generic_readlink 3 32654 NULL
103290 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
103291 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
103292 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
103293 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
103294 +get_arg_page_32746 get_arg_page 2 32746 NULL
103295 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
103296 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
103297 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
103298 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
103299 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
103300 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
103301 +vga_rseq_32848 vga_rseq 0 32848 NULL
103302 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
103303 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
103304 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
103305 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
103306 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
103307 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
103308 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
103309 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
103310 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
103311 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
103312 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
103313 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
103314 +compat_filldir_32999 compat_filldir 3 32999 NULL
103315 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
103316 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
103317 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
103318 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
103319 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
103320 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
103321 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
103322 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
103323 +alloc_tio_33077 alloc_tio 3 33077 NULL
103324 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
103325 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
103326 +write_node_33121 write_node 4 33121 NULL
103327 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
103328 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
103329 +__len_within_target_33132 __len_within_target 0 33132 NULL
103330 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
103331 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
103332 +pp_read_33210 pp_read 3 33210 NULL
103333 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
103334 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
103335 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
103336 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
103337 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
103338 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
103339 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
103340 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
103341 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
103342 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
103343 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
103344 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
103345 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
103346 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
103347 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
103348 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
103349 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
103350 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
103351 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
103352 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
103353 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
103354 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
103355 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
103356 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
103357 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
103358 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
103359 +create_entry_33479 create_entry 2 33479 NULL
103360 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
103361 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
103362 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
103363 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
103364 +res_counter_read_33499 res_counter_read 4 33499 NULL
103365 +fb_read_33506 fb_read 3 33506 NULL
103366 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
103367 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
103368 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
103369 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
103370 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
103371 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
103372 +dup_array_33551 dup_array 3 33551 NULL
103373 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
103374 +count_subheaders_33591 count_subheaders 0 33591 NULL
103375 +scsi_execute_33596 scsi_execute 5 33596 NULL
103376 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
103377 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
103378 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
103379 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
103380 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
103381 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
103382 +inw_p_33668 inw_p 0 33668 NULL
103383 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
103384 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
103385 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
103386 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
103387 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
103388 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
103389 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
103390 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
103391 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
103392 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
103393 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
103394 +Read_hfc_33755 Read_hfc 0 33755 NULL
103395 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
103396 +hashtab_create_33769 hashtab_create 3 33769 NULL
103397 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
103398 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
103399 +find_next_offset_33804 find_next_offset 3 33804 NULL
103400 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
103401 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
103402 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
103403 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
103404 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
103405 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
103406 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
103407 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
103408 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
103409 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
103410 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
103411 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
103412 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
103413 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
103414 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
103415 +ppp_write_34034 ppp_write 3 34034 NULL
103416 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
103417 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
103418 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
103419 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
103420 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
103421 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
103422 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
103423 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
103424 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
103425 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
103426 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
103427 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
103428 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
103429 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
103430 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
103431 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
103432 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
103433 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
103434 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
103435 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
103436 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
103437 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
103438 +__insert_34349 __insert 2-3 34349 NULL
103439 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
103440 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
103441 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
103442 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
103443 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
103444 +ea_read_34378 ea_read 0 34378 NULL
103445 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
103446 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
103447 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
103448 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
103449 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
103450 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
103451 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
103452 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
103453 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
103454 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
103455 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
103456 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
103457 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
103458 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
103459 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
103460 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
103461 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
103462 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
103463 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
103464 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
103465 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
103466 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
103467 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
103468 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
103469 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
103470 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
103471 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
103472 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
103473 +port_print_34704 port_print 3 34704 NULL
103474 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
103475 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
103476 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
103477 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
103478 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
103479 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
103480 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
103481 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
103482 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
103483 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
103484 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
103485 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
103486 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
103487 +msg_print_text_34889 msg_print_text 0 34889 NULL
103488 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
103489 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
103490 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
103491 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
103492 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
103493 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
103494 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
103495 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
103496 +Realloc_34961 Realloc 2 34961 NULL
103497 +mq_lookup_34990 mq_lookup 2 34990 NULL
103498 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
103499 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
103500 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
103501 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
103502 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
103503 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
103504 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
103505 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
103506 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
103507 +store_ifalias_35088 store_ifalias 4 35088 NULL
103508 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
103509 +capi_write_35104 capi_write 3 35104 NULL nohasharray
103510 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
103511 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
103512 +pointer_35138 pointer 0 35138 NULL
103513 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
103514 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
103515 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
103516 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
103517 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
103518 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
103519 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
103520 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
103521 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
103522 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
103523 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
103524 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
103525 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
103526 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
103527 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
103528 +set_fd_set_35249 set_fd_set 1 35249 NULL
103529 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
103530 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
103531 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
103532 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
103533 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
103534 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
103535 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
103536 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
103537 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
103538 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
103539 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
103540 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
103541 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
103542 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
103543 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
103544 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
103545 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
103546 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
103547 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
103548 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
103549 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
103550 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
103551 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
103552 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
103553 +async_setkey_35521 async_setkey 3 35521 NULL
103554 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
103555 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
103556 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
103557 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
103558 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
103559 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
103560 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
103561 +ReadZReg_35604 ReadZReg 0 35604 NULL
103562 +kernel_readv_35617 kernel_readv 3 35617 NULL
103563 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
103564 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
103565 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
103566 +store_debug_level_35652 store_debug_level 3 35652 NULL
103567 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
103568 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
103569 +dm_table_create_35687 dm_table_create 3 35687 NULL
103570 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
103571 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
103572 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
103573 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
103574 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
103575 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
103576 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
103577 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
103578 +fls64_35862 fls64 0 35862 NULL
103579 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
103580 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
103581 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
103582 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
103583 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
103584 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
103585 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
103586 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
103587 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
103588 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
103589 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
103590 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
103591 +acl_alloc_35979 acl_alloc 1 35979 NULL
103592 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
103593 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
103594 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
103595 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
103596 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
103597 +account_shadowed_36048 account_shadowed 2 36048 NULL
103598 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
103599 +write_emulate_36065 write_emulate 2-4 36065 NULL
103600 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
103601 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
103602 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
103603 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
103604 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
103605 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
103606 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
103607 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
103608 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
103609 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
103610 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
103611 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
103612 +twl_set_36154 twl_set 2 36154 NULL
103613 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
103614 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
103615 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
103616 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
103617 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
103618 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
103619 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
103620 +is_dirty_36223 is_dirty 2 36223 NULL
103621 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
103622 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
103623 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
103624 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
103625 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
103626 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
103627 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
103628 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
103629 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
103630 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
103631 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
103632 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
103633 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
103634 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
103635 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
103636 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
103637 +lc_create_36332 lc_create 4 36332 NULL
103638 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
103639 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
103640 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
103641 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
103642 +to_sector_36361 to_sector 0-1 36361 NULL
103643 +tunables_read_36385 tunables_read 3 36385 NULL
103644 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
103645 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
103646 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
103647 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
103648 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
103649 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
103650 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
103651 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
103652 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
103653 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
103654 +get_param_l_36518 get_param_l 0 36518 NULL
103655 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
103656 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
103657 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
103658 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
103659 +get_entry_len_36549 get_entry_len 0 36549 NULL
103660 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
103661 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
103662 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
103663 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
103664 +__erst_read_36579 __erst_read 0 36579 NULL
103665 +put_cmsg_36589 put_cmsg 4 36589 NULL
103666 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
103667 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
103668 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
103669 +format_decode_36638 format_decode 0 36638 NULL
103670 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
103671 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
103672 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
103673 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
103674 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
103675 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
103676 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
103677 +sched_clock_36717 sched_clock 0 36717 NULL
103678 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
103679 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
103680 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
103681 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
103682 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
103683 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
103684 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
103685 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
103686 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
103687 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
103688 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
103689 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
103690 +cm_write_36858 cm_write 3 36858 NULL
103691 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
103692 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
103693 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
103694 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
103695 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
103696 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
103697 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
103698 +build_key_36931 build_key 1 36931 NULL
103699 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
103700 +write_leb_36957 write_leb 5 36957 NULL
103701 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
103702 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
103703 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
103704 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
103705 +setxattr_37006 setxattr 4 37006 NULL
103706 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
103707 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
103708 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
103709 +parse_command_37079 parse_command 2 37079 NULL
103710 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
103711 +tun_get_user_37094 tun_get_user 5 37094 NULL
103712 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
103713 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
103714 +msg_word_37164 msg_word 0 37164 NULL
103715 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
103716 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
103717 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
103718 +__do_replace_37227 __do_replace 5 37227 NULL
103719 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
103720 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
103721 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
103722 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
103723 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
103724 +c101_run_37279 c101_run 2 37279 NULL
103725 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
103726 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
103727 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
103728 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
103729 +send_msg_37323 send_msg 4 37323 NULL
103730 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
103731 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
103732 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
103733 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
103734 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
103735 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
103736 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
103737 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
103738 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
103739 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
103740 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
103741 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
103742 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
103743 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
103744 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
103745 +__remove_37457 __remove 2 37457 NULL
103746 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
103747 +get_est_timing_37484 get_est_timing 0 37484 NULL
103748 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
103749 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
103750 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
103751 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
103752 +hdr_size_37536 hdr_size 0 37536 NULL
103753 +a2p_37544 a2p 0-1 37544 NULL
103754 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
103755 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
103756 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
103757 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
103758 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
103759 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
103760 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
103761 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
103762 +check_pt_base_37635 check_pt_base 3 37635 NULL
103763 +alloc_fd_37637 alloc_fd 1 37637 NULL
103764 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
103765 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
103766 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
103767 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
103768 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
103769 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
103770 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
103771 +nametbl_header_37698 nametbl_header 2 37698 NULL
103772 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
103773 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
103774 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
103775 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
103776 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
103777 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
103778 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
103779 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
103780 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
103781 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
103782 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
103783 +deny_write_access_37813 deny_write_access 0 37813 NULL
103784 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
103785 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
103786 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
103787 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
103788 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
103789 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
103790 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
103791 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
103792 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
103793 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
103794 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
103795 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
103796 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
103797 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
103798 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
103799 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
103800 +vfs_readv_38011 vfs_readv 3 38011 NULL
103801 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
103802 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
103803 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
103804 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
103805 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
103806 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
103807 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
103808 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
103809 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
103810 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
103811 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
103812 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
103813 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
103814 +ep0_read_38095 ep0_read 3 38095 NULL
103815 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
103816 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
103817 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
103818 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
103819 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
103820 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
103821 +cdev_add_38176 cdev_add 2-3 38176 NULL
103822 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
103823 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
103824 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
103825 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
103826 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
103827 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
103828 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
103829 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
103830 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
103831 +from_dblock_38256 from_dblock 0-1 38256 NULL
103832 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
103833 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
103834 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
103835 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
103836 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
103837 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
103838 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
103839 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
103840 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
103841 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
103842 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
103843 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
103844 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
103845 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
103846 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
103847 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
103848 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
103849 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
103850 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
103851 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
103852 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
103853 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
103854 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
103855 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
103856 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
103857 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
103858 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
103859 +dev_names_read_38509 dev_names_read 3 38509 NULL
103860 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
103861 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
103862 +set_queue_count_38519 set_queue_count 0 38519 NULL
103863 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
103864 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
103865 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
103866 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
103867 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
103868 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
103869 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
103870 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
103871 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
103872 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
103873 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
103874 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
103875 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
103876 +cma_create_area_38642 cma_create_area 2 38642 NULL
103877 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
103878 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
103879 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
103880 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
103881 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
103882 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
103883 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
103884 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
103885 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
103886 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
103887 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
103888 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
103889 +udf_readpages_38761 udf_readpages 4 38761 NULL
103890 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
103891 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
103892 +err_decode_38804 err_decode 2 38804 NULL
103893 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
103894 +sys_select_38827 sys_select 1 38827 NULL
103895 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
103896 +direct_entry_38836 direct_entry 3 38836 NULL
103897 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
103898 +interfaces_38859 interfaces 2 38859 NULL
103899 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
103900 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
103901 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
103902 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
103903 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
103904 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
103905 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
103906 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
103907 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
103908 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
103909 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
103910 +udf_new_block_38999 udf_new_block 4 38999 NULL
103911 +get_nodes_39012 get_nodes 3 39012 NULL
103912 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
103913 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
103914 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
103915 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
103916 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
103917 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
103918 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
103919 +ea_foreach_39133 ea_foreach 0 39133 NULL
103920 +generic_permission_39150 generic_permission 0 39150 NULL
103921 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
103922 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
103923 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
103924 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
103925 +init_list_set_39188 init_list_set 2-3 39188 NULL
103926 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
103927 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
103928 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
103929 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
103930 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
103931 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
103932 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
103933 +drm_order_39244 drm_order 0 39244 NULL
103934 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
103935 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
103936 +__skb_cow_39254 __skb_cow 2 39254 NULL
103937 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
103938 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
103939 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
103940 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
103941 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
103942 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
103943 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
103944 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
103945 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
103946 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
103947 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
103948 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
103949 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
103950 +__send_to_port_39386 __send_to_port 3 39386 NULL
103951 +user_power_read_39414 user_power_read 3 39414 NULL
103952 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
103953 +sys_semop_39457 sys_semop 3 39457 NULL
103954 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
103955 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
103956 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
103957 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
103958 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
103959 +int_proc_write_39542 int_proc_write 3 39542 NULL
103960 +pp_write_39554 pp_write 3 39554 NULL
103961 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
103962 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
103963 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
103964 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
103965 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
103966 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
103967 +ext_depth_39607 ext_depth 0 39607 NULL
103968 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
103969 +sdio_readb_39618 sdio_readb 0 39618 NULL
103970 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
103971 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
103972 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
103973 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
103974 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
103975 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
103976 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
103977 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
103978 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
103979 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
103980 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
103981 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
103982 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
103983 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
103984 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
103985 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
103986 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
103987 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
103988 +pkt_add_39897 pkt_add 3 39897 NULL
103989 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
103990 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
103991 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
103992 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
103993 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
103994 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
103995 +__spi_async_39932 __spi_async 0 39932 NULL
103996 +__get_order_39935 __get_order 0 39935 NULL
103997 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
103998 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
103999 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
104000 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
104001 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
104002 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
104003 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
104004 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
104005 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
104006 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
104007 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
104008 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
104009 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
104010 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
104011 +add_tty_40055 add_tty 1 40055 NULL nohasharray
104012 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
104013 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
104014 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
104015 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
104016 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
104017 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
104018 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
104019 +pt_write_40159 pt_write 3 40159 NULL
104020 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
104021 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
104022 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
104023 +allocate_probes_40204 allocate_probes 1 40204 NULL
104024 +compat_put_long_40214 compat_put_long 1 40214 NULL
104025 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
104026 +osst_read_40237 osst_read 3 40237 NULL
104027 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
104028 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
104029 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
104030 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
104031 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
104032 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
104033 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
104034 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
104035 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
104036 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
104037 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
104038 +mmio_read_40348 mmio_read 4 40348 NULL
104039 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
104040 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
104041 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
104042 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
104043 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
104044 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
104045 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
104046 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
104047 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
104048 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
104049 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
104050 +tty_write_room_40495 tty_write_room 0 40495 NULL
104051 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
104052 +sg_phys_40507 sg_phys 0 40507 NULL
104053 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
104054 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
104055 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
104056 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
104057 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
104058 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
104059 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
104060 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
104061 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
104062 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
104063 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
104064 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
104065 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
104066 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
104067 +fops_read_40672 fops_read 3 40672 NULL
104068 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
104069 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
104070 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
104071 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
104072 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
104073 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
104074 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
104075 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
104076 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
104077 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
104078 +card_send_command_40757 card_send_command 3 40757 NULL
104079 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
104080 +pg_write_40766 pg_write 3 40766 NULL
104081 +show_list_40775 show_list 3 40775 NULL
104082 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
104083 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
104084 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
104085 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
104086 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
104087 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
104088 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
104089 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
104090 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
104091 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
104092 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
104093 +read_file_queue_40895 read_file_queue 3 40895 NULL
104094 +waiters_read_40902 waiters_read 3 40902 NULL
104095 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
104096 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
104097 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
104098 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
104099 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
104100 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
104101 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
104102 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
104103 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
104104 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
104105 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
104106 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
104107 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
104108 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
104109 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
104110 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
104111 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
104112 +dma_attach_41094 dma_attach 5-6 41094 NULL
104113 +provide_user_output_41105 provide_user_output 3 41105 NULL
104114 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
104115 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
104116 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
104117 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
104118 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
104119 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
104120 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
104121 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
104122 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
104123 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
104124 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
104125 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
104126 +erst_read_41260 erst_read 0 41260 NULL
104127 +__fprog_create_41263 __fprog_create 2 41263 NULL
104128 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
104129 +alloc_context_41283 alloc_context 1 41283 NULL
104130 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
104131 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
104132 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
104133 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
104134 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
104135 +kmp_init_41373 kmp_init 2 41373 NULL
104136 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
104137 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
104138 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
104139 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
104140 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
104141 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
104142 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
104143 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
104144 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
104145 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
104146 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
104147 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
104148 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
104149 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
104150 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
104151 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
104152 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
104153 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
104154 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
104155 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
104156 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
104157 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
104158 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
104159 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
104160 +vga_io_r_41609 vga_io_r 0 41609 NULL
104161 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
104162 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
104163 +a2mp_send_41615 a2mp_send 4 41615 NULL
104164 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
104165 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
104166 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
104167 +get_std_timing_41654 get_std_timing 0 41654 NULL
104168 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
104169 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
104170 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
104171 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
104172 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
104173 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
104174 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
104175 +fillonedir_41746 fillonedir 3 41746 NULL
104176 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
104177 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
104178 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
104179 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
104180 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
104181 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
104182 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
104183 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
104184 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
104185 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
104186 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
104187 +get_packet_41914 get_packet 3 41914 NULL
104188 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
104189 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
104190 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
104191 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
104192 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
104193 +read_gssp_41947 read_gssp 3 41947 NULL
104194 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
104195 +portnames_read_41958 portnames_read 3 41958 NULL
104196 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
104197 +dst_mtu_41969 dst_mtu 0 41969 NULL
104198 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
104199 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
104200 +lguest_map_42008 lguest_map 1-2 42008 NULL
104201 +pool_allocate_42012 pool_allocate 3 42012 NULL
104202 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
104203 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
104204 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
104205 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
104206 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
104207 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
104208 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
104209 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
104210 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
104211 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
104212 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
104213 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
104214 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
104215 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
104216 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
104217 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
104218 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
104219 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
104220 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
104221 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
104222 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
104223 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
104224 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
104225 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
104226 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
104227 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
104228 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
104229 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
104230 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
104231 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
104232 +free_cblock_42318 free_cblock 2 42318 NULL
104233 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
104234 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
104235 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
104236 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
104237 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
104238 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
104239 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
104240 +krng_get_random_42420 krng_get_random 3 42420 NULL
104241 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
104242 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
104243 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
104244 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
104245 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
104246 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
104247 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
104248 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
104249 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
104250 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
104251 +bypass_write_42498 bypass_write 3 42498 NULL
104252 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
104253 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
104254 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
104255 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
104256 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
104257 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
104258 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
104259 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
104260 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
104261 +map_state_42602 map_state 1 42602 NULL nohasharray
104262 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
104263 +nd_get_link_42603 nd_get_link 0 42603 NULL
104264 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
104265 +resp_write_42628 resp_write 2 42628 NULL
104266 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
104267 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
104268 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
104269 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
104270 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
104271 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
104272 +vb2_read_42703 vb2_read 3 42703 NULL
104273 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
104274 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
104275 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
104276 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
104277 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
104278 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
104279 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
104280 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
104281 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
104282 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
104283 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
104284 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
104285 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
104286 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
104287 +set_arg_42824 set_arg 3 42824 NULL
104288 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
104289 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
104290 +prandom_u32_42853 prandom_u32 0 42853 NULL
104291 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
104292 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
104293 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
104294 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
104295 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
104296 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
104297 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
104298 +hd_end_request_42904 hd_end_request 2 42904 NULL
104299 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
104300 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
104301 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
104302 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
104303 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
104304 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
104305 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
104306 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
104307 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
104308 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
104309 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
104310 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
104311 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
104312 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
104313 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
104314 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
104315 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
104316 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
104317 +uuid_string_43154 uuid_string 0 43154 NULL
104318 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
104319 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
104320 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
104321 +process_measurement_43190 process_measurement 0 43190 NULL
104322 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
104323 +uio_write_43202 uio_write 3 43202 NULL
104324 +iso_callback_43208 iso_callback 3 43208 NULL
104325 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
104326 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
104327 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
104328 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
104329 +fixup_leb_43256 fixup_leb 3 43256 NULL
104330 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
104331 +evtchn_write_43278 evtchn_write 3 43278 NULL
104332 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
104333 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
104334 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
104335 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
104336 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
104337 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
104338 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
104339 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
104340 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
104341 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
104342 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
104343 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
104344 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
104345 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
104346 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
104347 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
104348 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
104349 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
104350 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
104351 +do_readlink_43518 do_readlink 2 43518 NULL
104352 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
104353 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
104354 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
104355 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
104356 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
104357 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
104358 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
104359 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
104360 +proc_read_43614 proc_read 3 43614 NULL
104361 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
104362 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
104363 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
104364 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
104365 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
104366 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
104367 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
104368 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
104369 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
104370 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
104371 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
104372 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
104373 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
104374 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
104375 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
104376 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
104377 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
104378 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
104379 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
104380 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
104381 +read_flush_43851 read_flush 3 43851 NULL
104382 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
104383 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
104384 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
104385 +SendString_43928 SendString 3 43928 NULL
104386 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
104387 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
104388 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
104389 +nla_reserve_43984 nla_reserve 3 43984 NULL
104390 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
104391 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
104392 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
104393 +emit_flags_44006 emit_flags 4-3 44006 NULL
104394 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
104395 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
104396 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
104397 +load_discard_44083 load_discard 3 44083 NULL
104398 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
104399 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
104400 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
104401 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
104402 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
104403 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
104404 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
104405 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
104406 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
104407 +__set_free_44211 __set_free 2 44211 NULL
104408 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
104409 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
104410 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
104411 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
104412 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
104413 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
104414 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
104415 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
104416 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
104417 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
104418 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
104419 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
104420 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
104421 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
104422 +__is_discarded_44359 __is_discarded 2 44359 NULL
104423 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
104424 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
104425 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
104426 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
104427 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
104428 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
104429 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
104430 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
104431 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
104432 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
104433 +bio_advance_44496 bio_advance 2 44496 NULL
104434 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
104435 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
104436 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
104437 +spidev_write_44510 spidev_write 3 44510 NULL
104438 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
104439 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
104440 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
104441 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
104442 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
104443 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
104444 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
104445 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
104446 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
104447 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
104448 +mpi_resize_44674 mpi_resize 2 44674 NULL
104449 +ts_read_44687 ts_read 3 44687 NULL
104450 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
104451 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
104452 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
104453 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
104454 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
104455 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
104456 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
104457 +set_brk_44749 set_brk 1 44749 NULL
104458 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
104459 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
104460 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
104461 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
104462 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
104463 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
104464 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
104465 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
104466 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
104467 +sisusb_write_44834 sisusb_write 3 44834 NULL
104468 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
104469 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
104470 +cubic_root_44848 cubic_root 1 44848 NULL
104471 +copydesc_user_44855 copydesc_user 3 44855 NULL
104472 +skb_availroom_44883 skb_availroom 0 44883 NULL
104473 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
104474 +do_tty_write_44896 do_tty_write 5 44896 NULL
104475 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
104476 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
104477 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
104478 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
104479 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
104480 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
104481 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
104482 +sel_write_user_45060 sel_write_user 3 45060 NULL
104483 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
104484 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
104485 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
104486 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
104487 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
104488 +usbdev_read_45114 usbdev_read 3 45114 NULL
104489 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
104490 +send_to_tty_45141 send_to_tty 3 45141 NULL
104491 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
104492 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
104493 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
104494 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
104495 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
104496 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
104497 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
104498 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
104499 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
104500 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
104501 +add_child_45201 add_child 4 45201 NULL
104502 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
104503 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
104504 +__dirty_45228 __dirty 2 45228 NULL
104505 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
104506 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
104507 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
104508 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
104509 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
104510 +pte_val_45313 pte_val 0 45313 NULL
104511 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
104512 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
104513 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
104514 +keymap_store_45406 keymap_store 4 45406 NULL
104515 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
104516 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
104517 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
104518 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
104519 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
104520 +__node_remap_45458 __node_remap 4 45458 NULL
104521 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
104522 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
104523 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
104524 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
104525 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
104526 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
104527 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
104528 +copy_macs_45534 copy_macs 4 45534 NULL
104529 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
104530 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
104531 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
104532 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
104533 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
104534 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
104535 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
104536 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
104537 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
104538 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
104539 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
104540 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
104541 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
104542 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
104543 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
104544 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
104545 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
104546 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
104547 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
104548 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
104549 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
104550 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
104551 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
104552 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
104553 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
104554 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
104555 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
104556 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
104557 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
104558 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
104559 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
104560 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
104561 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
104562 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
104563 +isdn_write_45863 isdn_write 3 45863 NULL
104564 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
104565 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
104566 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
104567 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
104568 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
104569 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
104570 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
104571 +alloc_mr_45935 alloc_mr 1 45935 NULL
104572 +split_large_page_45941 split_large_page 2 45941 NULL
104573 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
104574 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
104575 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
104576 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
104577 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
104578 +get_free_entries_46030 get_free_entries 1 46030 NULL
104579 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
104580 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
104581 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
104582 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
104583 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
104584 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
104585 +slhc_toss_46066 slhc_toss 0 46066 NULL
104586 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
104587 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
104588 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
104589 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
104590 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
104591 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
104592 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
104593 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
104594 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
104595 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
104596 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
104597 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
104598 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
104599 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
104600 +add_conn_list_46197 add_conn_list 3 46197 NULL
104601 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
104602 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
104603 +dsp_write_46218 dsp_write 2 46218 NULL
104604 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
104605 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
104606 +ReadReg_46277 ReadReg 0 46277 NULL
104607 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
104608 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
104609 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
104610 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
104611 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
104612 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
104613 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
104614 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
104615 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
104616 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
104617 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
104618 +filldir64_46469 filldir64 3 46469 NULL
104619 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
104620 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
104621 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
104622 +kmsg_read_46514 kmsg_read 3 46514 NULL
104623 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
104624 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
104625 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
104626 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
104627 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
104628 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
104629 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
104630 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
104631 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
104632 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
104633 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
104634 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
104635 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
104636 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
104637 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
104638 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
104639 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
104640 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
104641 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
104642 +prepare_copy_46725 prepare_copy 2 46725 NULL
104643 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
104644 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
104645 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
104646 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
104647 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
104648 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
104649 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
104650 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
104651 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
104652 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
104653 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
104654 +spi_async_46857 spi_async 0 46857 NULL
104655 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
104656 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
104657 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
104658 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
104659 +rvmalloc_46873 rvmalloc 1 46873 NULL
104660 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
104661 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
104662 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
104663 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
104664 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
104665 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
104666 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
104667 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
104668 +fb_write_46924 fb_write 3 46924 NULL
104669 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
104670 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
104671 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
104672 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
104673 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
104674 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
104675 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
104676 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
104677 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
104678 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
104679 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
104680 +__map_single_47020 __map_single 3-4-7 47020 NULL
104681 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
104682 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
104683 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
104684 +fs_path_len_47060 fs_path_len 0 47060 NULL
104685 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
104686 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
104687 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
104688 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
104689 +mousedev_read_47123 mousedev_read 3 47123 NULL
104690 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
104691 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
104692 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
104693 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
104694 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
104695 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
104696 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
104697 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
104698 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
104699 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
104700 +l2headersize_47238 l2headersize 0 47238 NULL
104701 +options_write_47243 options_write 3 47243 NULL
104702 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
104703 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
104704 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
104705 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
104706 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
104707 +vsnprintf_47291 vsnprintf 0 47291 NULL
104708 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
104709 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
104710 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
104711 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
104712 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
104713 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
104714 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
104715 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
104716 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
104717 +nametbl_list_47391 nametbl_list 2 47391 NULL
104718 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
104719 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
104720 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
104721 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
104722 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
104723 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
104724 +vzalloc_47421 vzalloc 1 47421 NULL
104725 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
104726 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
104727 +__load_mapping_47460 __load_mapping 2 47460 NULL
104728 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
104729 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
104730 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
104731 +core_sys_select_47494 core_sys_select 1 47494 NULL
104732 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
104733 +unlink_simple_47506 unlink_simple 3 47506 NULL
104734 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
104735 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
104736 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
104737 +oz_events_read_47535 oz_events_read 3 47535 NULL
104738 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
104739 +read_ldt_47570 read_ldt 2 47570 NULL
104740 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
104741 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
104742 +pci_iomap_47575 pci_iomap 3 47575 NULL
104743 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
104744 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
104745 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
104746 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
104747 +uea_request_47613 uea_request 4 47613 NULL
104748 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
104749 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
104750 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
104751 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
104752 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
104753 +save_microcode_47717 save_microcode 3 47717 NULL
104754 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
104755 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
104756 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
104757 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
104758 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
104759 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
104760 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
104761 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
104762 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
104763 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
104764 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
104765 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
104766 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
104767 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
104768 +vhci_read_47878 vhci_read 3 47878 NULL
104769 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
104770 +load_mapping_47904 load_mapping 3 47904 NULL
104771 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
104772 +comedi_write_47926 comedi_write 3 47926 NULL
104773 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
104774 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
104775 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
104776 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
104777 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
104778 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
104779 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
104780 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
104781 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
104782 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
104783 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
104784 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
104785 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
104786 +disc_write_48070 disc_write 3 48070 NULL
104787 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
104788 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
104789 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
104790 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
104791 +set_discoverable_48141 set_discoverable 4 48141 NULL
104792 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
104793 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
104794 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
104795 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
104796 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
104797 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
104798 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
104799 +init_ipath_48187 init_ipath 1 48187 NULL
104800 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
104801 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
104802 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
104803 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
104804 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
104805 +read_file_recv_48232 read_file_recv 3 48232 NULL
104806 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
104807 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
104808 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
104809 +send_set_info_48288 send_set_info 7 48288 NULL
104810 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
104811 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
104812 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
104813 +hash_setkey_48310 hash_setkey 3 48310 NULL
104814 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
104815 +skb_add_data_48363 skb_add_data 3 48363 NULL
104816 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
104817 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
104818 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
104819 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
104820 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
104821 +print_filtered_48442 print_filtered 2-0 48442 NULL
104822 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
104823 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
104824 +send_control_msg_48498 send_control_msg 6 48498 NULL
104825 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
104826 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
104827 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
104828 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
104829 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
104830 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
104831 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
104832 +named_distribute_48544 named_distribute 4 48544 NULL
104833 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
104834 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
104835 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
104836 +mtd_read_48655 mtd_read 0 48655 NULL
104837 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
104838 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
104839 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
104840 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
104841 +altera_drscan_48698 altera_drscan 2 48698 NULL
104842 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
104843 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
104844 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
104845 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
104846 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
104847 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
104848 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
104849 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
104850 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
104851 +azx_get_position_48841 azx_get_position 0 48841 NULL
104852 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
104853 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
104854 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
104855 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
104856 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
104857 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
104858 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
104859 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
104860 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
104861 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
104862 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
104863 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
104864 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
104865 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
104866 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
104867 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
104868 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
104869 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
104870 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
104871 +transient_status_49027 transient_status 4 49027 NULL
104872 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
104873 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
104874 +ubi_read_49061 ubi_read 0 49061 NULL
104875 +scsi_register_49094 scsi_register 2 49094 NULL
104876 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
104877 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
104878 +check_exists_49119 check_exists 2 49119 NULL nohasharray
104879 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
104880 +pt_read_49136 pt_read 3 49136 NULL
104881 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
104882 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
104883 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
104884 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
104885 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
104886 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
104887 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
104888 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
104889 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
104890 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
104891 +resp_write_same_49217 resp_write_same 2 49217 NULL
104892 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
104893 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
104894 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
104895 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
104896 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
104897 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
104898 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
104899 +uio_read_49300 uio_read 3 49300 NULL
104900 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
104901 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
104902 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
104903 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
104904 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
104905 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
104906 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
104907 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
104908 +px_raw_event_49371 px_raw_event 4 49371 NULL
104909 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
104910 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
104911 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
104912 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
104913 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
104914 +md_domain_init_49432 md_domain_init 2 49432 NULL
104915 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
104916 +get_lru_size_49441 get_lru_size 0 49441 NULL
104917 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
104918 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
104919 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
104920 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
104921 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
104922 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
104923 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
104924 +smk_write_access_49561 smk_write_access 3 49561 NULL
104925 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
104926 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
104927 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
104928 +tap_write_49595 tap_write 3 49595 NULL
104929 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
104930 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
104931 +heap_init_49617 heap_init 2 49617 NULL
104932 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
104933 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
104934 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
104935 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
104936 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
104937 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
104938 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
104939 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
104940 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
104941 +check_frame_49741 check_frame 0 49741 NULL
104942 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
104943 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
104944 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
104945 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
104946 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
104947 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
104948 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
104949 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
104950 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
104951 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
104952 +add_uuid_49831 add_uuid 4 49831 NULL
104953 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
104954 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
104955 +twl4030_write_49846 twl4030_write 2 49846 NULL
104956 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
104957 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
104958 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
104959 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
104960 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
104961 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
104962 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
104963 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
104964 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
104965 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
104966 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
104967 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
104968 +__module_alloc_50004 __module_alloc 1 50004 NULL
104969 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
104970 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
104971 +isdn_read_50021 isdn_read 3 50021 NULL
104972 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
104973 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
104974 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
104975 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
104976 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
104977 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
104978 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
104979 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
104980 +read_file_slot_50111 read_file_slot 3 50111 NULL
104981 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
104982 +copy_items_50140 copy_items 6 50140 NULL
104983 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
104984 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
104985 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
104986 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
104987 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
104988 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
104989 +odev_update_50169 odev_update 2 50169 NULL
104990 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
104991 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
104992 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
104993 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
104994 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
104995 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
104996 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
104997 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
104998 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
104999 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
105000 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
105001 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
105002 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
105003 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
105004 +do_launder_page_50329 do_launder_page 0 50329 NULL
105005 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
105006 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
105007 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
105008 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
105009 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
105010 +tpm_read_50344 tpm_read 3 50344 NULL
105011 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
105012 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
105013 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
105014 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
105015 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
105016 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
105017 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
105018 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
105019 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
105020 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
105021 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
105022 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
105023 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
105024 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
105025 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
105026 +force_mapping_50464 force_mapping 2 50464 NULL
105027 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
105028 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
105029 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
105030 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
105031 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
105032 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
105033 +fat_readpages_50582 fat_readpages 4 50582 NULL
105034 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
105035 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
105036 +sge_rx_50594 sge_rx 3 50594 NULL
105037 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
105038 +__ffs_50625 __ffs 0 50625 NULL
105039 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
105040 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
105041 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
105042 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
105043 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
105044 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
105045 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
105046 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
105047 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
105048 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
105049 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
105050 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
105051 +skb_padto_50759 skb_padto 2 50759 NULL
105052 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
105053 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
105054 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
105055 +tpm_write_50798 tpm_write 3 50798 NULL
105056 +write_flush_50803 write_flush 3 50803 NULL
105057 +dvb_play_50814 dvb_play 3 50814 NULL
105058 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
105059 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
105060 +SetArea_50835 SetArea 4 50835 NULL nohasharray
105061 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
105062 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
105063 +self_check_write_50856 self_check_write 5 50856 NULL
105064 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
105065 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
105066 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
105067 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
105068 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
105069 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
105070 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
105071 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
105072 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
105073 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
105074 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
105075 +timeout_write_50991 timeout_write 3 50991 NULL
105076 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
105077 +proc_write_51003 proc_write 3 51003 NULL
105078 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
105079 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
105080 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
105081 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
105082 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
105083 +dump_midi_51040 dump_midi 3 51040 NULL
105084 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
105085 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
105086 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
105087 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
105088 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
105089 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
105090 +ti_recv_51110 ti_recv 3 51110 NULL
105091 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
105092 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
105093 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
105094 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
105095 +set_dirty_51144 set_dirty 3 51144 NULL
105096 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
105097 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
105098 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
105099 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
105100 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
105101 +tipc_send_51238 tipc_send 4 51238 NULL
105102 +drm_property_create_51239 drm_property_create 4 51239 NULL
105103 +st_read_51251 st_read 3 51251 NULL
105104 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
105105 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
105106 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
105107 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
105108 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
105109 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
105110 +get_cell_51316 get_cell 2 51316 NULL
105111 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
105112 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
105113 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
105114 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
105115 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
105116 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
105117 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
105118 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
105119 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
105120 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
105121 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
105122 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
105123 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
105124 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
105125 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
105126 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
105127 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
105128 +vaddr_51480 vaddr 0 51480 NULL
105129 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
105130 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
105131 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
105132 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
105133 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
105134 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
105135 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
105136 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
105137 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
105138 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
105139 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
105140 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
105141 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
105142 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
105143 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
105144 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
105145 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
105146 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
105147 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
105148 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
105149 +sel_write_access_51704 sel_write_access 3 51704 NULL
105150 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
105151 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
105152 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
105153 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
105154 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
105155 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
105156 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
105157 +if_write_51756 if_write 3 51756 NULL
105158 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
105159 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
105160 +to_ratio_51809 to_ratio 2-1 51809 NULL
105161 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
105162 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
105163 +ioread32_51847 ioread32 0 51847 NULL nohasharray
105164 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
105165 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
105166 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
105167 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
105168 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
105169 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
105170 +user_read_51881 user_read 3 51881 NULL
105171 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
105172 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
105173 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
105174 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
105175 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
105176 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
105177 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
105178 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
105179 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
105180 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
105181 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
105182 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
105183 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
105184 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
105185 +rdmalt_52022 rdmalt 0 52022 NULL
105186 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
105187 +override_release_52032 override_release 2 52032 NULL
105188 +end_port_52042 end_port 0 52042 NULL
105189 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
105190 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
105191 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
105192 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
105193 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
105194 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
105195 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
105196 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
105197 +retry_count_read_52129 retry_count_read 3 52129 NULL
105198 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
105199 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
105200 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
105201 +htable_size_52148 htable_size 0-1 52148 NULL
105202 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
105203 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
105204 +alix_present_52165 alix_present 1 52165 NULL
105205 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
105206 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
105207 +print_prefix_52176 print_prefix 0 52176 NULL
105208 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
105209 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
105210 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
105211 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
105212 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
105213 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
105214 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
105215 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
105216 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
105217 +atomic64_read_52300 atomic64_read 0 52300 NULL
105218 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
105219 +read_file_reset_52310 read_file_reset 3 52310 NULL
105220 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
105221 +hwflags_read_52318 hwflags_read 3 52318 NULL
105222 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
105223 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
105224 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
105225 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
105226 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
105227 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
105228 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
105229 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
105230 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
105231 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
105232 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
105233 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
105234 +delay_status_52431 delay_status 5 52431 NULL
105235 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
105236 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
105237 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
105238 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
105239 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
105240 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
105241 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
105242 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
105243 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
105244 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
105245 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
105246 +from_oblock_52546 from_oblock 0-1 52546 NULL
105247 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
105248 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
105249 +emit_code_52583 emit_code 0-3 52583 NULL
105250 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
105251 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
105252 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
105253 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
105254 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
105255 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
105256 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
105257 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
105258 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
105259 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
105260 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
105261 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
105262 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
105263 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
105264 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
105265 +twlreg_write_52880 twlreg_write 3 52880 NULL
105266 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
105267 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
105268 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
105269 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
105270 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
105271 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
105272 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
105273 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
105274 +send_packet_52960 send_packet 4 52960 NULL
105275 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
105276 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
105277 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
105278 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
105279 +num_node_state_52989 num_node_state 0 52989 NULL
105280 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
105281 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
105282 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
105283 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
105284 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
105285 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
105286 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
105287 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
105288 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
105289 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
105290 +verity_status_53120 verity_status 5 53120 NULL
105291 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
105292 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
105293 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
105294 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
105295 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
105296 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
105297 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
105298 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
105299 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
105300 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
105301 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
105302 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
105303 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
105304 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
105305 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
105306 +vm_mmap_53339 vm_mmap 0 53339 NULL
105307 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
105308 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
105309 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
105310 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
105311 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
105312 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
105313 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
105314 +n2_run_53459 n2_run 3 53459 NULL
105315 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
105316 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
105317 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
105318 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
105319 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
105320 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
105321 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
105322 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
105323 +check_acl_53512 check_acl 0 53512 NULL
105324 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
105325 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
105326 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
105327 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
105328 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
105329 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
105330 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
105331 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
105332 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
105333 +_preload_range_53676 _preload_range 2-3 53676 NULL
105334 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
105335 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
105336 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
105337 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
105338 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
105339 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
105340 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
105341 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
105342 +wdm_write_53735 wdm_write 3 53735 NULL
105343 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
105344 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
105345 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
105346 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
105347 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
105348 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
105349 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
105350 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
105351 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
105352 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
105353 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
105354 +pms_read_53873 pms_read 3 53873 NULL
105355 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
105356 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
105357 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
105358 +proc_file_read_53905 proc_file_read 3 53905 NULL
105359 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
105360 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
105361 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
105362 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
105363 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
105364 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
105365 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
105366 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
105367 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
105368 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
105369 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
105370 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
105371 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
105372 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
105373 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
105374 +_malloc_54077 _malloc 1 54077 NULL
105375 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
105376 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
105377 +create_xattr_54106 create_xattr 5 54106 NULL
105378 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
105379 +strn_len_54122 strn_len 0 54122 NULL
105380 +isku_receive_54130 isku_receive 4 54130 NULL
105381 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
105382 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
105383 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
105384 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
105385 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
105386 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
105387 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
105388 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
105389 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
105390 +reada_add_block_54247 reada_add_block 2 54247 NULL
105391 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
105392 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
105393 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
105394 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
105395 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
105396 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
105397 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
105398 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
105399 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
105400 +sprintf_54306 sprintf 0 54306 NULL
105401 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
105402 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
105403 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
105404 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
105405 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
105406 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
105407 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
105408 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
105409 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
105410 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
105411 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
105412 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
105413 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
105414 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
105415 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
105416 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
105417 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
105418 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
105419 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
105420 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
105421 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
105422 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
105423 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
105424 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
105425 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
105426 +viacam_read_54526 viacam_read 3 54526 NULL
105427 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
105428 +setsockopt_54539 setsockopt 5 54539 NULL
105429 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
105430 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
105431 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
105432 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
105433 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
105434 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
105435 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
105436 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
105437 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
105438 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
105439 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
105440 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
105441 +evm_read_key_54674 evm_read_key 3 54674 NULL
105442 +resource_string_54699 resource_string 0 54699 NULL
105443 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
105444 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
105445 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
105446 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
105447 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
105448 +kzalloc_54740 kzalloc 1 54740 NULL
105449 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
105450 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
105451 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
105452 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
105453 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
105454 +domain_init_54797 domain_init 2 54797 NULL
105455 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
105456 +get_dev_size_54807 get_dev_size 0 54807 NULL
105457 +nfsd_write_54809 nfsd_write 6 54809 NULL
105458 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
105459 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
105460 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
105461 +write_rio_54837 write_rio 3 54837 NULL
105462 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
105463 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
105464 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
105465 +printer_read_54851 printer_read 3 54851 NULL
105466 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
105467 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
105468 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
105469 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
105470 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
105471 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
105472 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
105473 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
105474 +add_port_54941 add_port 2 54941 NULL
105475 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
105476 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
105477 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
105478 +c4_add_card_54968 c4_add_card 3 54968 NULL
105479 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
105480 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
105481 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
105482 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
105483 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
105484 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
105485 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
105486 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
105487 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
105488 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
105489 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
105490 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
105491 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
105492 +corrupt_data_55120 corrupt_data 0 55120 NULL
105493 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
105494 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
105495 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
105496 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
105497 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
105498 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
105499 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
105500 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
105501 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
105502 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
105503 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
105504 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
105505 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
105506 +dump_command_55220 dump_command 1 55220 NULL
105507 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
105508 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
105509 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
105510 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
105511 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
105512 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
105513 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
105514 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
105515 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
105516 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
105517 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
105518 +do_shmat_55336 do_shmat 5 55336 NULL
105519 +vme_user_read_55338 vme_user_read 3 55338 NULL
105520 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
105521 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
105522 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
105523 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
105524 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
105525 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
105526 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
105527 +alloc_skb_55439 alloc_skb 1 55439 NULL
105528 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
105529 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
105530 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
105531 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
105532 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
105533 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
105534 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
105535 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
105536 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
105537 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
105538 +ea_get_55522 ea_get 0 55522 NULL
105539 +buffer_size_55534 buffer_size 0 55534 NULL
105540 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
105541 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
105542 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
105543 +add_partition_55588 add_partition 2 55588 NULL
105544 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
105545 +free_pages_55603 free_pages 1 55603 NULL
105546 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
105547 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
105548 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
105549 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
105550 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
105551 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
105552 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
105553 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
105554 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
105555 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
105556 +read_oldmem_55658 read_oldmem 3 55658 NULL
105557 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
105558 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
105559 +get_info_55681 get_info 3 55681 NULL
105560 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
105561 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
105562 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
105563 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
105564 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
105565 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
105566 +set_local_name_55757 set_local_name 4 55757 NULL
105567 +strlen_55778 strlen 0 55778 NULL
105568 +set_spte_55783 set_spte 5-4 55783 NULL
105569 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
105570 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
105571 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
105572 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
105573 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
105574 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
105575 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
105576 +hsc_write_55875 hsc_write 3 55875 NULL
105577 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
105578 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
105579 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
105580 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
105581 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
105582 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
105583 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
105584 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
105585 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
105586 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
105587 +__set_discard_56081 __set_discard 2 56081 NULL
105588 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
105589 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
105590 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
105591 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
105592 +map_addr_56144 map_addr 7 56144 NULL
105593 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
105594 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
105595 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
105596 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
105597 +skb_headroom_56200 skb_headroom 0 56200 NULL
105598 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
105599 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
105600 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
105601 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
105602 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
105603 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
105604 +fd_copyin_56247 fd_copyin 3 56247 NULL
105605 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
105606 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
105607 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
105608 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
105609 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
105610 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
105611 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
105612 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
105613 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
105614 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
105615 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
105616 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
105617 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
105618 +dev_read_56369 dev_read 3 56369 NULL
105619 +write_gssp_56404 write_gssp 3 56404 NULL
105620 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
105621 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
105622 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
105623 +store_msg_56417 store_msg 3 56417 NULL
105624 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
105625 +fl_create_56435 fl_create 5 56435 NULL
105626 +gnttab_map_56439 gnttab_map 2 56439 NULL
105627 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
105628 +set_connectable_56458 set_connectable 4 56458 NULL
105629 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
105630 +putused_user_56467 putused_user 3 56467 NULL
105631 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
105632 +global_rt_period_56476 global_rt_period 0 56476 NULL
105633 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
105634 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
105635 +init_map_ip_56508 init_map_ip 5 56508 NULL
105636 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
105637 +ip_options_get_56538 ip_options_get 4 56538 NULL
105638 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
105639 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
105640 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
105641 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
105642 +event_filter_write_56609 event_filter_write 3 56609 NULL
105643 +gather_array_56641 gather_array 3 56641 NULL
105644 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
105645 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
105646 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
105647 +build_map_info_56696 build_map_info 2 56696 NULL
105648 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
105649 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
105650 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
105651 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
105652 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
105653 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
105654 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
105655 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
105656 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
105657 +hash_lookup_56792 hash_lookup 2 56792 NULL
105658 +do_syslog_56807 do_syslog 3 56807 NULL
105659 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
105660 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
105661 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
105662 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
105663 +wb_lookup_56858 wb_lookup 2 56858 NULL
105664 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
105665 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
105666 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
105667 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
105668 +strcspn_56913 strcspn 0 56913 NULL
105669 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
105670 +check_header_56930 check_header 2 56930 NULL
105671 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
105672 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
105673 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
105674 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
105675 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
105676 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
105677 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
105678 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
105679 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
105680 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
105681 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
105682 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
105683 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
105684 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
105685 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
105686 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
105687 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
105688 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
105689 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
105690 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
105691 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
105692 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
105693 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
105694 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
105695 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
105696 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
105697 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
105698 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
105699 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
105700 +flush_space_57241 flush_space 3 57241 NULL
105701 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
105702 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
105703 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
105704 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
105705 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
105706 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
105707 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
105708 +fw_file_size_57307 fw_file_size 0 57307 NULL
105709 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
105710 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
105711 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
105712 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
105713 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
105714 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
105715 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
105716 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
105717 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
105718 +read_file_blob_57406 read_file_blob 3 57406 NULL
105719 +enclosure_register_57412 enclosure_register 3 57412 NULL
105720 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
105721 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
105722 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
105723 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
105724 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
105725 +ReadReg_57453 ReadReg 0 57453 NULL
105726 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
105727 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
105728 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
105729 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
105730 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
105731 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
105732 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
105733 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
105734 +skb_headlen_57501 skb_headlen 0 57501 NULL
105735 +copy_in_user_57502 copy_in_user 3 57502 NULL
105736 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
105737 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
105738 +init_tag_map_57515 init_tag_map 3 57515 NULL
105739 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
105740 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
105741 +inode_permission_57531 inode_permission 0 57531 NULL
105742 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
105743 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
105744 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
105745 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
105746 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
105747 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
105748 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
105749 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
105750 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
105751 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
105752 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
105753 +mem_read_57631 mem_read 3 57631 NULL
105754 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
105755 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
105756 +r3964_write_57662 r3964_write 4 57662 NULL
105757 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
105758 +__lgwrite_57669 __lgwrite 4 57669 NULL
105759 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
105760 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
105761 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
105762 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
105763 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
105764 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
105765 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
105766 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
105767 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
105768 +ld2_57794 ld2 0 57794 NULL
105769 +ivtv_read_57796 ivtv_read 3 57796 NULL
105770 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
105771 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
105772 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
105773 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
105774 +copy_to_user_57835 copy_to_user 3 57835 NULL
105775 +flash_read_57843 flash_read 3 57843 NULL
105776 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
105777 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
105778 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
105779 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
105780 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
105781 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
105782 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
105783 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
105784 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
105785 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
105786 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
105787 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
105788 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
105789 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
105790 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
105791 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
105792 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
105793 +mce_async_out_58056 mce_async_out 3 58056 NULL
105794 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
105795 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
105796 +cm4040_write_58079 cm4040_write 3 58079 NULL
105797 +udi_log_event_58105 udi_log_event 3 58105 NULL
105798 +savemem_58129 savemem 3 58129 NULL
105799 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
105800 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
105801 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
105802 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
105803 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
105804 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
105805 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
105806 +read_file_debug_58256 read_file_debug 3 58256 NULL
105807 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
105808 +profile_load_58267 profile_load 3 58267 NULL
105809 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
105810 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
105811 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
105812 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
105813 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
105814 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
105815 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
105816 +next_pidmap_58347 next_pidmap 2 58347 NULL
105817 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
105818 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
105819 +save_hint_58359 save_hint 2 58359 NULL
105820 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
105821 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
105822 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
105823 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
105824 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
105825 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
105826 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
105827 +capabilities_read_58457 capabilities_read 3 58457 NULL
105828 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
105829 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
105830 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
105831 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
105832 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
105833 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
105834 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
105835 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
105836 +__clear_discard_58546 __clear_discard 2 58546 NULL
105837 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
105838 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
105839 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
105840 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
105841 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
105842 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
105843 +xip_file_read_58592 xip_file_read 3 58592 NULL
105844 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
105845 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
105846 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
105847 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
105848 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
105849 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
105850 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
105851 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
105852 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
105853 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
105854 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
105855 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
105856 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
105857 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
105858 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
105859 +acpi_map_58725 acpi_map 1-2 58725 NULL
105860 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
105861 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
105862 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
105863 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
105864 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
105865 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
105866 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
105867 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
105868 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
105869 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
105870 +ep_read_58813 ep_read 3 58813 NULL
105871 +command_write_58841 command_write 3 58841 NULL
105872 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
105873 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
105874 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
105875 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
105876 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
105877 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
105878 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
105879 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
105880 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
105881 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
105882 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
105883 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
105884 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
105885 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
105886 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
105887 +ep_write_59008 ep_write 3 59008 NULL
105888 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
105889 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
105890 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
105891 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
105892 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
105893 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
105894 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
105895 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
105896 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
105897 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
105898 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
105899 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
105900 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
105901 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
105902 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
105903 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
105904 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
105905 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
105906 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
105907 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
105908 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
105909 +dt3155_read_59226 dt3155_read 3 59226 NULL
105910 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
105911 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
105912 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
105913 +nla_len_59258 nla_len 0 59258 NULL
105914 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
105915 +fd_copyout_59323 fd_copyout 3 59323 NULL
105916 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
105917 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
105918 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
105919 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
105920 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
105921 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
105922 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
105923 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
105924 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
105925 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
105926 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
105927 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
105928 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
105929 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
105930 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
105931 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
105932 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
105933 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
105934 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
105935 +tunables_write_59563 tunables_write 3 59563 NULL
105936 +memdup_user_59590 memdup_user 2 59590 NULL
105937 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
105938 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
105939 +mtrr_write_59622 mtrr_write 3 59622 NULL
105940 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
105941 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
105942 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
105943 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
105944 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
105945 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
105946 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
105947 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
105948 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
105949 +sriov_enable_59689 sriov_enable 2 59689 NULL
105950 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
105951 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
105952 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
105953 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
105954 +strnlen_59746 strnlen 0 59746 NULL
105955 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
105956 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
105957 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
105958 +venus_remove_59781 venus_remove 4 59781 NULL
105959 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
105960 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
105961 +ipw_write_59807 ipw_write 3 59807 NULL
105962 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
105963 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
105964 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
105965 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
105966 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
105967 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
105968 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
105969 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
105970 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
105971 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
105972 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
105973 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
105974 +lookup_node_59953 lookup_node 2 59953 NULL
105975 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
105976 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
105977 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
105978 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
105979 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
105980 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
105981 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
105982 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
105983 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
105984 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
105985 +register_device_60015 register_device 2-3 60015 NULL
105986 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
105987 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
105988 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
105989 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
105990 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
105991 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
105992 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
105993 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
105994 +compat_writev_60063 compat_writev 3 60063 NULL
105995 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
105996 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
105997 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
105998 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
105999 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
106000 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
106001 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
106002 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
106003 +init_state_60165 init_state 2 60165 NULL
106004 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
106005 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
106006 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
106007 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
106008 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
106009 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
106010 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
106011 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
106012 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
106013 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
106014 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
106015 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
106016 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
106017 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
106018 +printer_write_60276 printer_write 3 60276 NULL
106019 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
106020 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
106021 +getDataLength_60301 getDataLength 0 60301 NULL
106022 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
106023 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
106024 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
106025 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
106026 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
106027 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
106028 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
106029 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
106030 +driver_names_read_60399 driver_names_read 3 60399 NULL
106031 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
106032 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
106033 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
106034 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
106035 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
106036 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
106037 +rx_data_60442 rx_data 4 60442 NULL nohasharray
106038 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
106039 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
106040 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
106041 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
106042 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
106043 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
106044 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
106045 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
106046 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
106047 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
106048 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
106049 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
106050 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
106051 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
106052 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
106053 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
106054 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
106055 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
106056 +init_data_container_60709 init_data_container 1 60709 NULL
106057 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
106058 +raid_status_60755 raid_status 5 60755 NULL
106059 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
106060 +opticon_write_60775 opticon_write 4 60775 NULL
106061 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
106062 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
106063 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
106064 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
106065 +generic_writepages_60871 generic_writepages 0 60871 NULL
106066 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
106067 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
106068 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
106069 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
106070 +sys_mlock_60932 sys_mlock 1 60932 NULL
106071 +pti_char_write_60960 pti_char_write 3 60960 NULL
106072 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
106073 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
106074 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
106075 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
106076 +symtab_init_61050 symtab_init 2 61050 NULL
106077 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
106078 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
106079 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
106080 +get_derived_key_61100 get_derived_key 4 61100 NULL
106081 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
106082 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
106083 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
106084 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
106085 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
106086 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
106087 +__vmalloc_61168 __vmalloc 1 61168 NULL
106088 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
106089 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
106090 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
106091 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
106092 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
106093 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
106094 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
106095 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
106096 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
106097 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
106098 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
106099 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
106100 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
106101 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
106102 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
106103 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
106104 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
106105 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
106106 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
106107 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
106108 +change_xattr_61390 change_xattr 5 61390 NULL
106109 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
106110 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
106111 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
106112 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
106113 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
106114 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
106115 +erst_errno_61526 erst_errno 0 61526 NULL
106116 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
106117 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
106118 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
106119 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
106120 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
106121 +seq_open_private_61589 seq_open_private 3 61589 NULL
106122 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
106123 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
106124 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
106125 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
106126 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
106127 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
106128 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
106129 +resize_stripes_61650 resize_stripes 2 61650 NULL
106130 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
106131 +insert_one_name_61668 insert_one_name 7 61668 NULL
106132 +lock_loop_61681 lock_loop 1 61681 NULL
106133 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
106134 +filter_read_61692 filter_read 3 61692 NULL
106135 +iov_length_61716 iov_length 0 61716 NULL
106136 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
106137 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
106138 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
106139 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
106140 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
106141 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
106142 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
106143 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
106144 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
106145 +get_fw_name_61874 get_fw_name 3 61874 NULL
106146 +free_init_pages_61875 free_init_pages 2 61875 NULL
106147 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
106148 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
106149 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
106150 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
106151 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
106152 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
106153 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
106154 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
106155 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
106156 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
106157 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
106158 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
106159 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
106160 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
106161 +cow_file_range_61979 cow_file_range 3 61979 NULL
106162 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
106163 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
106164 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
106165 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
106166 +SYSC_select_62024 SYSC_select 1 62024 NULL
106167 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
106168 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
106169 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
106170 +do_pselect_62061 do_pselect 1 62061 NULL
106171 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
106172 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
106173 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
106174 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
106175 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
106176 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
106177 +ql_status_62135 ql_status 5 62135 NULL
106178 +video_usercopy_62151 video_usercopy 2 62151 NULL
106179 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
106180 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
106181 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
106182 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
106183 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
106184 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
106185 +allocate_partition_62245 allocate_partition 4 62245 NULL
106186 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
106187 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
106188 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
106189 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
106190 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
106191 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
106192 +subseq_list_62332 subseq_list 3-0 62332 NULL
106193 +flash_write_62354 flash_write 3 62354 NULL
106194 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
106195 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
106196 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
106197 +altera_irscan_62396 altera_irscan 2 62396 NULL
106198 +set_ssp_62411 set_ssp 4 62411 NULL
106199 +unmap_single_62423 unmap_single 2 62423 NULL
106200 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
106201 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
106202 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
106203 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
106204 +remove_mapping_62491 remove_mapping 2 62491 NULL
106205 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
106206 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
106207 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
106208 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
106209 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
106210 +debugfs_read_62535 debugfs_read 3 62535 NULL
106211 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
106212 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
106213 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
106214 +get_subdir_62581 get_subdir 3 62581 NULL
106215 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
106216 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
106217 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
106218 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
106219 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
106220 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
106221 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
106222 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
106223 +write_62671 write 3 62671 NULL
106224 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
106225 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
106226 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
106227 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
106228 +rdm_62719 rdm 0 62719 NULL
106229 +key_replays_read_62746 key_replays_read 3 62746 NULL
106230 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
106231 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
106232 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
106233 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
106234 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
106235 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
106236 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
106237 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
106238 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
106239 +set_swbp_62853 set_swbp 3 62853 NULL
106240 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
106241 +aoechr_write_62883 aoechr_write 3 62883 NULL
106242 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
106243 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
106244 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
106245 +getdqbuf_62908 getdqbuf 1 62908 NULL
106246 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
106247 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
106248 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
106249 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
106250 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
106251 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
106252 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
106253 +unlink1_63059 unlink1 3 63059 NULL
106254 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
106255 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
106256 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
106257 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
106258 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
106259 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
106260 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
106261 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
106262 +vme_master_read_63221 vme_master_read 0 63221 NULL
106263 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
106264 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
106265 +ptp_read_63251 ptp_read 4 63251 NULL
106266 +raid5_resize_63306 raid5_resize 2 63306 NULL
106267 +proc_info_read_63344 proc_info_read 3 63344 NULL
106268 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
106269 +idmouse_read_63374 idmouse_read 3 63374 NULL
106270 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
106271 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
106272 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
106273 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
106274 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
106275 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
106276 +kone_send_63435 kone_send 4 63435 NULL
106277 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
106278 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
106279 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
106280 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
106281 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
106282 +read_kcore_63488 read_kcore 3 63488 NULL
106283 +save_hint_63497 save_hint 2 63497 NULL
106284 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
106285 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
106286 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
106287 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
106288 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
106289 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
106290 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
106291 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
106292 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
106293 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
106294 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
106295 +module_alloc_63630 module_alloc 1 63630 NULL
106296 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
106297 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
106298 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
106299 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
106300 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
106301 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
106302 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
106303 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
106304 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
106305 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
106306 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
106307 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
106308 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
106309 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
106310 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
106311 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
106312 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
106313 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
106314 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
106315 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
106316 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
106317 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
106318 +prepare_copy_63826 prepare_copy 2 63826 NULL
106319 +sel_write_load_63830 sel_write_load 3 63830 NULL
106320 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
106321 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
106322 +divas_write_63901 divas_write 3 63901 NULL
106323 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
106324 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
106325 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
106326 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
106327 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
106328 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
106329 +__team_options_register_63941 __team_options_register 3 63941 NULL
106330 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
106331 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
106332 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
106333 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
106334 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
106335 +kmemdup_64015 kmemdup 2 64015 NULL
106336 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
106337 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
106338 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
106339 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
106340 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
106341 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
106342 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
106343 +get_u8_64076 get_u8 0 64076 NULL
106344 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
106345 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
106346 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
106347 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
106348 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
106349 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
106350 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
106351 +init_bch_64130 init_bch 1-2 64130 NULL
106352 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
106353 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
106354 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
106355 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
106356 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
106357 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
106358 +read_pulse_64227 read_pulse 0-3 64227 NULL
106359 +header_len_64232 header_len 0 64232 NULL
106360 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
106361 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
106362 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
106363 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
106364 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
106365 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
106366 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
106367 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
106368 +ffz_64324 ffz 0 64324 NULL
106369 +map_region_64328 map_region 1 64328 NULL
106370 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
106371 +ts_write_64336 ts_write 3 64336 NULL
106372 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
106373 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
106374 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
106375 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
106376 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
106377 +ilo_write_64378 ilo_write 3 64378 NULL
106378 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
106379 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
106380 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
106381 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
106382 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
106383 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
106384 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
106385 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
106386 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
106387 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
106388 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
106389 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
106390 +cap_capable_64462 cap_capable 0 64462 NULL
106391 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
106392 +single_open_size_64483 single_open_size 4 64483 NULL
106393 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
106394 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
106395 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
106396 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
106397 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
106398 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
106399 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
106400 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
106401 +SyS_bind_64544 SyS_bind 3 64544 NULL
106402 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
106403 +__spi_sync_64561 __spi_sync 0 64561 NULL
106404 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
106405 +fanotify_write_64623 fanotify_write 3 64623 NULL
106406 +to_dblock_64655 to_dblock 0-1 64655 NULL
106407 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
106408 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
106409 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
106410 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
106411 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
106412 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
106413 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
106414 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
106415 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
106416 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
106417 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
106418 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
106419 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
106420 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
106421 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
106422 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
106423 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
106424 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
106425 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
106426 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
106427 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
106428 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
106429 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
106430 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
106431 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
106432 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
106433 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
106434 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
106435 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
106436 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
106437 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
106438 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
106439 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
106440 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
106441 +pskb_pull_65005 pskb_pull 2 65005 NULL
106442 +unifi_write_65012 unifi_write 3 65012 NULL
106443 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
106444 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
106445 +insert_dent_65034 insert_dent 7 65034 NULL
106446 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
106447 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
106448 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
106449 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
106450 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
106451 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
106452 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
106453 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
106454 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
106455 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
106456 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
106457 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
106458 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
106459 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
106460 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
106461 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
106462 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
106463 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
106464 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
106465 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
106466 +get_var_len_65304 get_var_len 0 65304 NULL
106467 +unpack_array_65318 unpack_array 0 65318 NULL
106468 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
106469 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
106470 +init_list_set_65351 init_list_set 2-3 65351 NULL
106471 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
106472 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
106473 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
106474 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
106475 +strchr_65372 strchr 0 65372 NULL nohasharray
106476 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
106477 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
106478 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
106479 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
106480 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
106481 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
106482 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
106483 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
106484 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
106485 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
106486 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
106487 +alloc_dr_65495 alloc_dr 2 65495 NULL
106488 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
106489 new file mode 100644
106490 index 0000000..9db0d0e
106491 --- /dev/null
106492 +++ b/tools/gcc/size_overflow_plugin.c
106493 @@ -0,0 +1,2114 @@
106494 +/*
106495 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
106496 + * Licensed under the GPL v2, or (at your option) v3
106497 + *
106498 + * Homepage:
106499 + * http://www.grsecurity.net/~ephox/overflow_plugin/
106500 + *
106501 + * Documentation:
106502 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
106503 + *
106504 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
106505 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
106506 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
106507 + *
106508 + * Usage:
106509 + * $ 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
106510 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
106511 + */
106512 +
106513 +#include "gcc-plugin.h"
106514 +#include "config.h"
106515 +#include "system.h"
106516 +#include "coretypes.h"
106517 +#include "tree.h"
106518 +#include "tree-pass.h"
106519 +#include "intl.h"
106520 +#include "plugin-version.h"
106521 +#include "tm.h"
106522 +#include "toplev.h"
106523 +#include "function.h"
106524 +#include "tree-flow.h"
106525 +#include "plugin.h"
106526 +#include "gimple.h"
106527 +#include "diagnostic.h"
106528 +#include "cfgloop.h"
106529 +
106530 +#if BUILDING_GCC_VERSION >= 4008
106531 +#define TODO_dump_func 0
106532 +#endif
106533 +
106534 +struct size_overflow_hash {
106535 + const struct size_overflow_hash * const next;
106536 + const char * const name;
106537 + const unsigned int param;
106538 +};
106539 +
106540 +#include "size_overflow_hash.h"
106541 +
106542 +enum mark {
106543 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
106544 +};
106545 +
106546 +enum err_code_conditions {
106547 + CAST_ONLY, FROM_CONST
106548 +};
106549 +
106550 +static unsigned int call_count = 0;
106551 +
106552 +#define __unused __attribute__((__unused__))
106553 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
106554 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
106555 +#define BEFORE_STMT true
106556 +#define AFTER_STMT false
106557 +#define CREATE_NEW_VAR NULL_TREE
106558 +#define CODES_LIMIT 32
106559 +#define MAX_PARAM 31
106560 +#define MY_STMT GF_PLF_1
106561 +#define NO_CAST_CHECK GF_PLF_2
106562 +#define FROM_ARG true
106563 +#define FROM_RET false
106564 +
106565 +#if BUILDING_GCC_VERSION == 4005
106566 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
106567 +#endif
106568 +
106569 +int plugin_is_GPL_compatible;
106570 +void debug_gimple_stmt(gimple gs);
106571 +
106572 +static tree expand(struct pointer_set_t *visited, tree lhs);
106573 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
106574 +static tree report_size_overflow_decl;
106575 +static const_tree const_char_ptr_type_node;
106576 +static unsigned int handle_function(void);
106577 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
106578 +static tree get_size_overflow_type(gimple stmt, const_tree node);
106579 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
106580 +static void print_missing_msg(tree func, unsigned int argnum);
106581 +
106582 +static struct plugin_info size_overflow_plugin_info = {
106583 + .version = "20130410beta",
106584 + .help = "no-size-overflow\tturn off size overflow checking\n",
106585 +};
106586 +
106587 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
106588 +{
106589 + unsigned int arg_count;
106590 + enum tree_code code = TREE_CODE(*node);
106591 +
106592 + switch (code) {
106593 + case FUNCTION_DECL:
106594 + arg_count = type_num_arguments(TREE_TYPE(*node));
106595 + break;
106596 + case FUNCTION_TYPE:
106597 + case METHOD_TYPE:
106598 + arg_count = type_num_arguments(*node);
106599 + break;
106600 + default:
106601 + *no_add_attrs = true;
106602 + error("%s: %qE attribute only applies to functions", __func__, name);
106603 + return NULL_TREE;
106604 + }
106605 +
106606 + for (; args; args = TREE_CHAIN(args)) {
106607 + tree position = TREE_VALUE(args);
106608 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
106609 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
106610 + *no_add_attrs = true;
106611 + }
106612 + }
106613 + return NULL_TREE;
106614 +}
106615 +
106616 +static const char* get_asm_name(tree node)
106617 +{
106618 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
106619 +}
106620 +
106621 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
106622 +{
106623 + unsigned int arg_count, arg_num;
106624 + enum tree_code code = TREE_CODE(*node);
106625 +
106626 + switch (code) {
106627 + case FUNCTION_DECL:
106628 + arg_count = type_num_arguments(TREE_TYPE(*node));
106629 + break;
106630 + case FUNCTION_TYPE:
106631 + case METHOD_TYPE:
106632 + arg_count = type_num_arguments(*node);
106633 + break;
106634 + case FIELD_DECL:
106635 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
106636 + if (arg_num != 0) {
106637 + *no_add_attrs = true;
106638 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
106639 + }
106640 + return NULL_TREE;
106641 + default:
106642 + *no_add_attrs = true;
106643 + error("%qE attribute only applies to functions", name);
106644 + return NULL_TREE;
106645 + }
106646 +
106647 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
106648 + return NULL_TREE;
106649 +
106650 + for (; args; args = TREE_CHAIN(args)) {
106651 + tree position = TREE_VALUE(args);
106652 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
106653 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
106654 + *no_add_attrs = true;
106655 + }
106656 + }
106657 + return NULL_TREE;
106658 +}
106659 +
106660 +static struct attribute_spec size_overflow_attr = {
106661 + .name = "size_overflow",
106662 + .min_length = 1,
106663 + .max_length = -1,
106664 + .decl_required = true,
106665 + .type_required = false,
106666 + .function_type_required = false,
106667 + .handler = handle_size_overflow_attribute,
106668 +#if BUILDING_GCC_VERSION >= 4007
106669 + .affects_type_identity = false
106670 +#endif
106671 +};
106672 +
106673 +static struct attribute_spec intentional_overflow_attr = {
106674 + .name = "intentional_overflow",
106675 + .min_length = 1,
106676 + .max_length = -1,
106677 + .decl_required = true,
106678 + .type_required = false,
106679 + .function_type_required = false,
106680 + .handler = handle_intentional_overflow_attribute,
106681 +#if BUILDING_GCC_VERSION >= 4007
106682 + .affects_type_identity = false
106683 +#endif
106684 +};
106685 +
106686 +static void register_attributes(void __unused *event_data, void __unused *data)
106687 +{
106688 + register_attribute(&size_overflow_attr);
106689 + register_attribute(&intentional_overflow_attr);
106690 +}
106691 +
106692 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
106693 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
106694 +{
106695 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
106696 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
106697 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
106698 +
106699 + unsigned int m = 0x57559429;
106700 + unsigned int n = 0x5052acdb;
106701 + const unsigned int *key4 = (const unsigned int *)key;
106702 + unsigned int h = len;
106703 + unsigned int k = len + seed + n;
106704 + unsigned long long p;
106705 +
106706 + while (len >= 8) {
106707 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
106708 + len -= 8;
106709 + }
106710 + if (len >= 4) {
106711 + cwmixb(key4[0]) key4 += 1;
106712 + len -= 4;
106713 + }
106714 + if (len)
106715 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
106716 + cwmixb(h ^ (k + n));
106717 + return k ^ h;
106718 +
106719 +#undef cwfold
106720 +#undef cwmixa
106721 +#undef cwmixb
106722 +}
106723 +
106724 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
106725 +{
106726 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
106727 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
106728 + return fn ^ codes;
106729 +}
106730 +
106731 +static inline tree get_original_function_decl(tree fndecl)
106732 +{
106733 + if (DECL_ABSTRACT_ORIGIN(fndecl))
106734 + return DECL_ABSTRACT_ORIGIN(fndecl);
106735 + return fndecl;
106736 +}
106737 +
106738 +static inline gimple get_def_stmt(const_tree node)
106739 +{
106740 + gcc_assert(node != NULL_TREE);
106741 + if (TREE_CODE(node) != SSA_NAME)
106742 + return NULL;
106743 + return SSA_NAME_DEF_STMT(node);
106744 +}
106745 +
106746 +static unsigned char get_tree_code(const_tree type)
106747 +{
106748 + switch (TREE_CODE(type)) {
106749 + case ARRAY_TYPE:
106750 + return 0;
106751 + case BOOLEAN_TYPE:
106752 + return 1;
106753 + case ENUMERAL_TYPE:
106754 + return 2;
106755 + case FUNCTION_TYPE:
106756 + return 3;
106757 + case INTEGER_TYPE:
106758 + return 4;
106759 + case POINTER_TYPE:
106760 + return 5;
106761 + case RECORD_TYPE:
106762 + return 6;
106763 + case UNION_TYPE:
106764 + return 7;
106765 + case VOID_TYPE:
106766 + return 8;
106767 + case REAL_TYPE:
106768 + return 9;
106769 + case VECTOR_TYPE:
106770 + return 10;
106771 + case REFERENCE_TYPE:
106772 + return 11;
106773 + case OFFSET_TYPE:
106774 + return 12;
106775 + case COMPLEX_TYPE:
106776 + return 13;
106777 + default:
106778 + debug_tree((tree)type);
106779 + gcc_unreachable();
106780 + }
106781 +}
106782 +
106783 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
106784 +{
106785 + gcc_assert(type != NULL_TREE);
106786 +
106787 + while (type && len < CODES_LIMIT) {
106788 + tree_codes[len] = get_tree_code(type);
106789 + len++;
106790 + type = TREE_TYPE(type);
106791 + }
106792 + return len;
106793 +}
106794 +
106795 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
106796 +{
106797 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
106798 + enum tree_code code = TREE_CODE(type);
106799 + size_t len = 0;
106800 +
106801 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
106802 +
106803 + arg = TYPE_ARG_TYPES(type);
106804 + // skip builtins __builtin_constant_p
106805 + if (!arg && DECL_BUILT_IN(fndecl))
106806 + return 0;
106807 +
106808 + if (TREE_CODE_CLASS(code) == tcc_type)
106809 + result = type;
106810 + else
106811 + result = DECL_RESULT(fndecl);
106812 +
106813 + gcc_assert(result != NULL_TREE);
106814 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
106815 +
106816 + if (arg == NULL_TREE) {
106817 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
106818 + arg_field = DECL_ARGUMENT_FLD(fndecl);
106819 + if (arg_field == NULL_TREE)
106820 + return 0;
106821 + arg = TREE_TYPE(arg_field);
106822 + len = add_type_codes(arg, tree_codes, len);
106823 + gcc_assert(len != 0);
106824 + return len;
106825 + }
106826 +
106827 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
106828 + while (arg && len < CODES_LIMIT) {
106829 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
106830 + arg = TREE_CHAIN(arg);
106831 + }
106832 +
106833 + gcc_assert(len != 0);
106834 + return len;
106835 +}
106836 +
106837 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
106838 +{
106839 + unsigned int hash;
106840 + const struct size_overflow_hash *entry;
106841 + unsigned char tree_codes[CODES_LIMIT];
106842 + size_t len;
106843 + const char *func_name;
106844 +
106845 + fndecl = get_original_function_decl(fndecl);
106846 + len = get_function_decl(fndecl, tree_codes);
106847 + if (len == 0)
106848 + return NULL;
106849 +
106850 + func_name = get_asm_name(fndecl);
106851 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
106852 +
106853 + entry = size_overflow_hash[hash];
106854 + while (entry) {
106855 + if (!strcmp(entry->name, func_name))
106856 + return entry;
106857 + entry = entry->next;
106858 + }
106859 +
106860 + return NULL;
106861 +}
106862 +
106863 +static bool is_bool(const_tree node)
106864 +{
106865 + const_tree type;
106866 +
106867 + if (node == NULL_TREE)
106868 + return false;
106869 +
106870 + type = TREE_TYPE(node);
106871 + if (!INTEGRAL_TYPE_P(type))
106872 + return false;
106873 + if (TREE_CODE(type) == BOOLEAN_TYPE)
106874 + return true;
106875 + if (TYPE_PRECISION(type) == 1)
106876 + return true;
106877 + return false;
106878 +}
106879 +
106880 +static bool skip_types(const_tree var)
106881 +{
106882 + tree type;
106883 +
106884 + if (is_gimple_constant(var))
106885 + return true;
106886 +
106887 + switch (TREE_CODE(var)) {
106888 + case ADDR_EXPR:
106889 +#if BUILDING_GCC_VERSION >= 4006
106890 + case MEM_REF:
106891 +#endif
106892 + case ARRAY_REF:
106893 + case BIT_FIELD_REF:
106894 + case INDIRECT_REF:
106895 + case TARGET_MEM_REF:
106896 + return true;
106897 + case PARM_DECL:
106898 + case VAR_DECL:
106899 + case COMPONENT_REF:
106900 + return false;
106901 + default:
106902 + break;
106903 + }
106904 +
106905 + gcc_assert(TREE_CODE(var) == SSA_NAME);
106906 +
106907 + type = TREE_TYPE(var);
106908 + switch (TREE_CODE(type)) {
106909 + case INTEGER_TYPE:
106910 + case ENUMERAL_TYPE:
106911 + return false;
106912 + case BOOLEAN_TYPE:
106913 + return is_bool(var);
106914 + default:
106915 + break;
106916 + }
106917 +
106918 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
106919 +
106920 + type = TREE_TYPE(type);
106921 + gcc_assert(type != NULL_TREE);
106922 + switch (TREE_CODE(type)) {
106923 + case RECORD_TYPE:
106924 + case POINTER_TYPE:
106925 + case ARRAY_TYPE:
106926 + return true;
106927 + case VOID_TYPE:
106928 + case INTEGER_TYPE:
106929 + case UNION_TYPE:
106930 + return false;
106931 + default:
106932 + break;
106933 + }
106934 +
106935 + debug_tree((tree)var);
106936 + gcc_unreachable();
106937 +}
106938 +
106939 +static unsigned int find_arg_number(const_tree arg, tree func)
106940 +{
106941 + tree var;
106942 + unsigned int argnum = 1;
106943 +
106944 + if (TREE_CODE(arg) == SSA_NAME)
106945 + arg = SSA_NAME_VAR(arg);
106946 +
106947 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
106948 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
106949 + continue;
106950 + if (!skip_types(var))
106951 + return argnum;
106952 + }
106953 +
106954 + return 0;
106955 +}
106956 +
106957 +static tree create_new_var(tree type)
106958 +{
106959 + tree new_var = create_tmp_var(type, "cicus");
106960 +
106961 +#if BUILDING_GCC_VERSION <= 4007
106962 + add_referenced_var(new_var);
106963 + mark_sym_for_renaming(new_var);
106964 +#endif
106965 + return new_var;
106966 +}
106967 +
106968 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
106969 +{
106970 + gimple assign;
106971 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
106972 + tree type = TREE_TYPE(rhs1);
106973 + tree lhs = create_new_var(type);
106974 +
106975 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
106976 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
106977 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
106978 +
106979 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
106980 + update_stmt(assign);
106981 + gimple_set_plf(assign, MY_STMT, true);
106982 + return assign;
106983 +}
106984 +
106985 +static tree cast_a_tree(tree type, tree var)
106986 +{
106987 + gcc_assert(type != NULL_TREE);
106988 + gcc_assert(var != NULL_TREE);
106989 + gcc_assert(fold_convertible_p(type, var));
106990 +
106991 + return fold_convert(type, var);
106992 +}
106993 +
106994 +static tree get_lhs(const_gimple stmt)
106995 +{
106996 + switch (gimple_code(stmt)) {
106997 + case GIMPLE_ASSIGN:
106998 + return gimple_get_lhs(stmt);
106999 + case GIMPLE_PHI:
107000 + return gimple_phi_result(stmt);
107001 + case GIMPLE_CALL:
107002 + return gimple_call_lhs(stmt);
107003 + default:
107004 + return NULL_TREE;
107005 + }
107006 +}
107007 +
107008 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
107009 +{
107010 + const_gimple def_stmt = get_def_stmt(rhs);
107011 +
107012 + if (force)
107013 + return false;
107014 +
107015 + if (is_gimple_constant(rhs))
107016 + return false;
107017 +
107018 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
107019 + return false;
107020 +
107021 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
107022 + return false;
107023 +
107024 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
107025 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
107026 + return false;
107027 +
107028 + return true;
107029 +}
107030 +
107031 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
107032 +{
107033 + gimple assign, def_stmt;
107034 +
107035 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
107036 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
107037 + gcc_unreachable();
107038 +
107039 + def_stmt = get_def_stmt(rhs);
107040 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
107041 + return def_stmt;
107042 +
107043 + if (lhs == CREATE_NEW_VAR)
107044 + lhs = create_new_var(dst_type);
107045 +
107046 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
107047 +
107048 + if (!gsi_end_p(*gsi)) {
107049 + location_t loc = gimple_location(gsi_stmt(*gsi));
107050 + gimple_set_location(assign, loc);
107051 + }
107052 +
107053 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
107054 +
107055 + if (before)
107056 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
107057 + else
107058 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
107059 + update_stmt(assign);
107060 + gimple_set_plf(assign, MY_STMT, true);
107061 +
107062 + return assign;
107063 +}
107064 +
107065 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
107066 +{
107067 + gimple_stmt_iterator gsi;
107068 + tree lhs;
107069 + const_gimple new_stmt;
107070 +
107071 + if (rhs == NULL_TREE)
107072 + return NULL_TREE;
107073 +
107074 + gsi = gsi_for_stmt(stmt);
107075 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
107076 +
107077 + lhs = get_lhs(new_stmt);
107078 + gcc_assert(lhs != NULL_TREE);
107079 + return lhs;
107080 +}
107081 +
107082 +static tree cast_to_TI_type(gimple stmt, tree node)
107083 +{
107084 + gimple_stmt_iterator gsi;
107085 + gimple cast_stmt;
107086 + tree type = TREE_TYPE(node);
107087 +
107088 + if (types_compatible_p(type, intTI_type_node))
107089 + return node;
107090 +
107091 + gsi = gsi_for_stmt(stmt);
107092 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
107093 + return gimple_get_lhs(cast_stmt);
107094 +}
107095 +
107096 +static void check_function_hash(const_gimple stmt)
107097 +{
107098 + tree func;
107099 + const struct size_overflow_hash *hash;
107100 +
107101 + if (gimple_code(stmt) != GIMPLE_CALL)
107102 + return;
107103 +
107104 + func = gimple_call_fndecl(stmt);
107105 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
107106 + if (func == NULL_TREE)
107107 + return;
107108 +
107109 + hash = get_function_hash(func);
107110 + if (!hash)
107111 + print_missing_msg(func, 0);
107112 +}
107113 +
107114 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
107115 +{
107116 + tree lhs, new_lhs;
107117 + gimple_stmt_iterator gsi;
107118 +
107119 + if (rhs1 == NULL_TREE) {
107120 + debug_gimple_stmt(oldstmt);
107121 + error("%s: rhs1 is NULL_TREE", __func__);
107122 + gcc_unreachable();
107123 + }
107124 +
107125 + switch (gimple_code(oldstmt)) {
107126 + case GIMPLE_ASM:
107127 + lhs = rhs1;
107128 + break;
107129 + case GIMPLE_CALL:
107130 + lhs = gimple_call_lhs(oldstmt);
107131 + break;
107132 + case GIMPLE_ASSIGN:
107133 + lhs = gimple_get_lhs(oldstmt);
107134 + break;
107135 + default:
107136 + debug_gimple_stmt(oldstmt);
107137 + gcc_unreachable();
107138 + }
107139 +
107140 + gsi = gsi_for_stmt(oldstmt);
107141 + pointer_set_insert(visited, oldstmt);
107142 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
107143 + basic_block next_bb, cur_bb;
107144 + const_edge e;
107145 +
107146 + gcc_assert(before == false);
107147 + gcc_assert(stmt_can_throw_internal(oldstmt));
107148 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
107149 + gcc_assert(!gsi_end_p(gsi));
107150 +
107151 + cur_bb = gimple_bb(oldstmt);
107152 + next_bb = cur_bb->next_bb;
107153 + e = find_edge(cur_bb, next_bb);
107154 + gcc_assert(e != NULL);
107155 + gcc_assert(e->flags & EDGE_FALLTHRU);
107156 +
107157 + gsi = gsi_after_labels(next_bb);
107158 + gcc_assert(!gsi_end_p(gsi));
107159 +
107160 + before = true;
107161 + oldstmt = gsi_stmt(gsi);
107162 + }
107163 +
107164 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
107165 + return new_lhs;
107166 +}
107167 +
107168 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
107169 +{
107170 + gimple stmt;
107171 + gimple_stmt_iterator gsi;
107172 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
107173 +
107174 + if (gimple_plf(oldstmt, MY_STMT))
107175 + return lhs;
107176 +
107177 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
107178 + rhs1 = gimple_assign_rhs1(oldstmt);
107179 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
107180 + }
107181 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
107182 + rhs2 = gimple_assign_rhs2(oldstmt);
107183 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
107184 + }
107185 +
107186 + stmt = gimple_copy(oldstmt);
107187 + gimple_set_location(stmt, gimple_location(oldstmt));
107188 + gimple_set_plf(stmt, MY_STMT, true);
107189 +
107190 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
107191 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
107192 +
107193 + size_overflow_type = get_size_overflow_type(oldstmt, node);
107194 +
107195 + new_var = create_new_var(size_overflow_type);
107196 + new_var = make_ssa_name(new_var, stmt);
107197 + gimple_set_lhs(stmt, new_var);
107198 +
107199 + if (rhs1 != NULL_TREE)
107200 + gimple_assign_set_rhs1(stmt, rhs1);
107201 +
107202 + if (rhs2 != NULL_TREE)
107203 + gimple_assign_set_rhs2(stmt, rhs2);
107204 +#if BUILDING_GCC_VERSION >= 4007
107205 + if (rhs3 != NULL_TREE)
107206 + gimple_assign_set_rhs3(stmt, rhs3);
107207 +#endif
107208 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
107209 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
107210 +
107211 + gsi = gsi_for_stmt(oldstmt);
107212 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
107213 + update_stmt(stmt);
107214 + pointer_set_insert(visited, oldstmt);
107215 + return gimple_get_lhs(stmt);
107216 +}
107217 +
107218 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
107219 +{
107220 + basic_block first_bb;
107221 + gimple assign;
107222 + gimple_stmt_iterator gsi;
107223 +
107224 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
107225 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
107226 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
107227 +
107228 + gsi = gsi_start_bb(first_bb);
107229 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
107230 + return gimple_get_lhs(assign);
107231 +}
107232 +
107233 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
107234 +{
107235 + gimple_stmt_iterator gsi;
107236 + const_gimple assign;
107237 + gimple def_stmt = get_def_stmt(new_arg);
107238 +
107239 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
107240 + gsi = gsi_after_labels(gimple_bb(def_stmt));
107241 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
107242 + } else {
107243 + gsi = gsi_for_stmt(def_stmt);
107244 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
107245 + }
107246 +
107247 + return gimple_get_lhs(assign);
107248 +}
107249 +
107250 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
107251 +{
107252 + basic_block bb;
107253 + gimple_stmt_iterator gsi;
107254 + const_gimple assign, def_stmt;
107255 +
107256 + def_stmt = get_def_stmt(arg);
107257 + bb = gimple_bb(def_stmt);
107258 + gcc_assert(bb->index != 0);
107259 + gsi = gsi_after_labels(bb);
107260 +
107261 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
107262 + return gimple_get_lhs(assign);
107263 +}
107264 +
107265 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
107266 +{
107267 + tree size_overflow_type;
107268 + const_gimple def_stmt = get_def_stmt(arg);
107269 +
107270 + if (phi_ssa_name != NULL_TREE)
107271 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
107272 +
107273 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
107274 +
107275 + if (new_arg != NULL_TREE) {
107276 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
107277 + return use_phi_ssa_name(phi_ssa_name, new_arg);
107278 + }
107279 +
107280 + switch(gimple_code(def_stmt)) {
107281 + case GIMPLE_PHI:
107282 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
107283 + case GIMPLE_NOP:
107284 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
107285 + default:
107286 + debug_gimple_stmt((gimple)def_stmt);
107287 + gcc_unreachable();
107288 + }
107289 +}
107290 +
107291 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
107292 +{
107293 + basic_block bb;
107294 + gimple phi;
107295 + gimple_seq seq;
107296 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
107297 +
107298 + bb = gsi_bb(gsi);
107299 +
107300 + phi = create_phi_node(result, bb);
107301 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
107302 + seq = phi_nodes(bb);
107303 + gsi = gsi_last(seq);
107304 + gsi_remove(&gsi, false);
107305 +
107306 + gsi = gsi_for_stmt(oldstmt);
107307 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
107308 + gimple_set_bb(phi, bb);
107309 + gimple_set_plf(phi, MY_STMT, true);
107310 + return phi;
107311 +}
107312 +
107313 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
107314 +{
107315 + gimple new_phi = NULL;
107316 + gimple oldstmt = get_def_stmt(orig_result);
107317 + tree phi_ssa_name = NULL_TREE;
107318 + unsigned int i;
107319 +
107320 + pointer_set_insert(visited, oldstmt);
107321 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
107322 + tree arg, new_arg;
107323 +
107324 + arg = gimple_phi_arg_def(oldstmt, i);
107325 +
107326 + new_arg = expand(visited, arg);
107327 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
107328 + if (i == 0) {
107329 + phi_ssa_name = new_arg;
107330 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
107331 + }
107332 +
107333 + gcc_assert(new_phi != NULL);
107334 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
107335 + }
107336 +
107337 + gcc_assert(new_phi != NULL);
107338 + update_stmt(new_phi);
107339 + return gimple_phi_result(new_phi);
107340 +}
107341 +
107342 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
107343 +{
107344 + const_gimple assign;
107345 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
107346 + tree origtype = TREE_TYPE(orig_rhs);
107347 +
107348 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
107349 +
107350 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
107351 + return gimple_get_lhs(assign);
107352 +}
107353 +
107354 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
107355 +{
107356 + const_tree rhs1, lhs, rhs1_type, lhs_type;
107357 + enum machine_mode lhs_mode, rhs_mode;
107358 + gimple def_stmt = get_def_stmt(no_const_rhs);
107359 +
107360 + if (!gimple_assign_cast_p(def_stmt))
107361 + return false;
107362 +
107363 + rhs1 = gimple_assign_rhs1(def_stmt);
107364 + lhs = gimple_get_lhs(def_stmt);
107365 + rhs1_type = TREE_TYPE(rhs1);
107366 + lhs_type = TREE_TYPE(lhs);
107367 + rhs_mode = TYPE_MODE(rhs1_type);
107368 + lhs_mode = TYPE_MODE(lhs_type);
107369 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
107370 + return false;
107371 +
107372 + return true;
107373 +}
107374 +
107375 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
107376 +{
107377 + tree rhs1 = gimple_assign_rhs1(stmt);
107378 + tree lhs = gimple_get_lhs(stmt);
107379 + const_tree rhs1_type = TREE_TYPE(rhs1);
107380 + const_tree lhs_type = TREE_TYPE(lhs);
107381 +
107382 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
107383 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107384 +
107385 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
107386 +}
107387 +
107388 +static bool no_uses(tree node)
107389 +{
107390 + imm_use_iterator imm_iter;
107391 + use_operand_p use_p;
107392 +
107393 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
107394 + const_gimple use_stmt = USE_STMT(use_p);
107395 + if (use_stmt == NULL)
107396 + return true;
107397 + if (is_gimple_debug(use_stmt))
107398 + continue;
107399 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
107400 + continue;
107401 + return false;
107402 + }
107403 + return true;
107404 +}
107405 +
107406 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
107407 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
107408 +{
107409 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
107410 + gimple def_stmt = get_def_stmt(lhs);
107411 +
107412 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
107413 + return false;
107414 +
107415 + rhs1 = gimple_assign_rhs1(def_stmt);
107416 + rhs_type = TREE_TYPE(rhs1);
107417 + lhs_type = TREE_TYPE(lhs);
107418 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
107419 + return false;
107420 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
107421 + return false;
107422 +
107423 + def_stmt = get_def_stmt(rhs1);
107424 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
107425 + return false;
107426 +
107427 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
107428 + return false;
107429 +
107430 + rhs1 = gimple_assign_rhs1(def_stmt);
107431 + rhs2 = gimple_assign_rhs2(def_stmt);
107432 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
107433 + return false;
107434 +
107435 + if (is_gimple_constant(rhs2))
107436 + not_const_rhs = rhs1;
107437 + else
107438 + not_const_rhs = rhs2;
107439 +
107440 + return no_uses(not_const_rhs);
107441 +}
107442 +
107443 +static bool skip_lhs_cast_check(const_gimple stmt)
107444 +{
107445 + const_tree rhs = gimple_assign_rhs1(stmt);
107446 + const_gimple def_stmt = get_def_stmt(rhs);
107447 +
107448 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
107449 + if (gimple_code(def_stmt) == GIMPLE_ASM)
107450 + return true;
107451 +
107452 + if (is_const_plus_unsigned_signed_truncation(rhs))
107453 + return true;
107454 +
107455 + return false;
107456 +}
107457 +
107458 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
107459 +{
107460 + bool cast_lhs, cast_rhs;
107461 + tree lhs = gimple_get_lhs(stmt);
107462 + tree rhs = gimple_assign_rhs1(stmt);
107463 + const_tree lhs_type = TREE_TYPE(lhs);
107464 + const_tree rhs_type = TREE_TYPE(rhs);
107465 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
107466 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
107467 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
107468 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
107469 +
107470 + static bool check_lhs[3][4] = {
107471 + // ss su us uu
107472 + { false, true, true, false }, // lhs > rhs
107473 + { false, false, false, false }, // lhs = rhs
107474 + { true, true, true, true }, // lhs < rhs
107475 + };
107476 +
107477 + static bool check_rhs[3][4] = {
107478 + // ss su us uu
107479 + { true, false, true, true }, // lhs > rhs
107480 + { true, false, true, true }, // lhs = rhs
107481 + { true, false, true, true }, // lhs < rhs
107482 + };
107483 +
107484 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
107485 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
107486 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107487 +
107488 + if (lhs_size > rhs_size) {
107489 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107490 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107491 + } else if (lhs_size == rhs_size) {
107492 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107493 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107494 + } else {
107495 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107496 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107497 + }
107498 +
107499 + if (!cast_lhs && !cast_rhs)
107500 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
107501 +
107502 + if (cast_lhs && !skip_lhs_cast_check(stmt))
107503 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
107504 +
107505 + if (cast_rhs)
107506 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
107507 +
107508 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
107509 +}
107510 +
107511 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
107512 +{
107513 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
107514 +
107515 + if (gimple_plf(stmt, MY_STMT))
107516 + return lhs;
107517 +
107518 + rhs1 = gimple_assign_rhs1(stmt);
107519 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
107520 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107521 +
107522 + new_rhs1 = expand(visited, rhs1);
107523 +
107524 + if (new_rhs1 == NULL_TREE)
107525 + return create_cast_assign(visited, stmt);
107526 +
107527 + if (gimple_plf(stmt, NO_CAST_CHECK))
107528 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
107529 +
107530 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
107531 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
107532 +
107533 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
107534 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
107535 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107536 + }
107537 +
107538 + if (!gimple_assign_cast_p(stmt))
107539 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
107540 +
107541 + return create_cast_overflow_check(visited, new_rhs1, stmt);
107542 +}
107543 +
107544 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
107545 +{
107546 + tree rhs1, lhs = gimple_get_lhs(stmt);
107547 + gimple def_stmt = get_def_stmt(lhs);
107548 +
107549 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
107550 + rhs1 = gimple_assign_rhs1(def_stmt);
107551 +
107552 + if (is_gimple_constant(rhs1))
107553 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
107554 +
107555 + switch (TREE_CODE(rhs1)) {
107556 + case SSA_NAME:
107557 + return handle_unary_rhs(visited, def_stmt);
107558 + case ARRAY_REF:
107559 + case BIT_FIELD_REF:
107560 + case ADDR_EXPR:
107561 + case COMPONENT_REF:
107562 + case INDIRECT_REF:
107563 +#if BUILDING_GCC_VERSION >= 4006
107564 + case MEM_REF:
107565 +#endif
107566 + case TARGET_MEM_REF:
107567 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
107568 + case PARM_DECL:
107569 + case VAR_DECL:
107570 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107571 +
107572 + default:
107573 + debug_gimple_stmt(def_stmt);
107574 + debug_tree(rhs1);
107575 + gcc_unreachable();
107576 + }
107577 +}
107578 +
107579 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
107580 +{
107581 + gimple cond_stmt;
107582 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
107583 +
107584 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
107585 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
107586 + update_stmt(cond_stmt);
107587 +}
107588 +
107589 +static tree create_string_param(tree string)
107590 +{
107591 + tree i_type, a_type;
107592 + const int length = TREE_STRING_LENGTH(string);
107593 +
107594 + gcc_assert(length > 0);
107595 +
107596 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
107597 + a_type = build_array_type(char_type_node, i_type);
107598 +
107599 + TREE_TYPE(string) = a_type;
107600 + TREE_CONSTANT(string) = 1;
107601 + TREE_READONLY(string) = 1;
107602 +
107603 + return build1(ADDR_EXPR, ptr_type_node, string);
107604 +}
107605 +
107606 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
107607 +{
107608 + gimple func_stmt;
107609 + const_gimple def_stmt;
107610 + const_tree loc_line;
107611 + tree loc_file, ssa_name, current_func;
107612 + expanded_location xloc;
107613 + char *ssa_name_buf;
107614 + int len;
107615 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
107616 +
107617 + def_stmt = get_def_stmt(arg);
107618 + xloc = expand_location(gimple_location(def_stmt));
107619 +
107620 + if (!gimple_has_location(def_stmt)) {
107621 + xloc = expand_location(gimple_location(stmt));
107622 + if (!gimple_has_location(stmt))
107623 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
107624 + }
107625 +
107626 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
107627 +
107628 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
107629 + loc_file = create_string_param(loc_file);
107630 +
107631 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
107632 + current_func = create_string_param(current_func);
107633 +
107634 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
107635 + call_count++;
107636 + 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);
107637 + gcc_assert(len > 0);
107638 + ssa_name = build_string(len + 1, ssa_name_buf);
107639 + free(ssa_name_buf);
107640 + ssa_name = create_string_param(ssa_name);
107641 +
107642 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
107643 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
107644 +
107645 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
107646 +}
107647 +
107648 +static void __unused print_the_code_insertions(const_gimple stmt)
107649 +{
107650 + location_t loc = gimple_location(stmt);
107651 +
107652 + inform(loc, "Integer size_overflow check applied here.");
107653 +}
107654 +
107655 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
107656 +{
107657 + basic_block cond_bb, join_bb, bb_true;
107658 + edge e;
107659 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
107660 +
107661 + cond_bb = gimple_bb(stmt);
107662 + if (before)
107663 + gsi_prev(&gsi);
107664 + if (gsi_end_p(gsi))
107665 + e = split_block_after_labels(cond_bb);
107666 + else
107667 + e = split_block(cond_bb, gsi_stmt(gsi));
107668 + cond_bb = e->src;
107669 + join_bb = e->dest;
107670 + e->flags = EDGE_FALSE_VALUE;
107671 + e->probability = REG_BR_PROB_BASE;
107672 +
107673 + bb_true = create_empty_bb(cond_bb);
107674 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
107675 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
107676 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
107677 +
107678 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
107679 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
107680 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
107681 +
107682 + if (current_loops != NULL) {
107683 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
107684 + add_bb_to_loop(bb_true, cond_bb->loop_father);
107685 + }
107686 +
107687 + insert_cond(cond_bb, arg, cond_code, type_value);
107688 + insert_cond_result(bb_true, stmt, arg, min);
107689 +
107690 +// print_the_code_insertions(stmt);
107691 +}
107692 +
107693 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
107694 +{
107695 + const_tree rhs_type = TREE_TYPE(rhs);
107696 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
107697 +
107698 + gcc_assert(rhs_type != NULL_TREE);
107699 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
107700 + return;
107701 +
107702 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
107703 +
107704 + if (is_const_plus_unsigned_signed_truncation(rhs))
107705 + return;
107706 +
107707 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
107708 + // typemax (-1) < typemin (0)
107709 + if (TREE_OVERFLOW(type_max))
107710 + return;
107711 +
107712 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
107713 +
107714 + cast_rhs_type = TREE_TYPE(cast_rhs);
107715 + type_max_type = TREE_TYPE(type_max);
107716 + type_min_type = TREE_TYPE(type_min);
107717 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
107718 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
107719 +
107720 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
107721 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
107722 +}
107723 +
107724 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
107725 +{
107726 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
107727 + return false;
107728 + if (!is_gimple_constant(rhs))
107729 + return false;
107730 + return true;
107731 +}
107732 +
107733 +static tree get_def_stmt_rhs(const_tree var)
107734 +{
107735 + tree rhs1, def_stmt_rhs1;
107736 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
107737 +
107738 + def_stmt = get_def_stmt(var);
107739 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
107740 +
107741 + rhs1 = gimple_assign_rhs1(def_stmt);
107742 + rhs1_def_stmt = get_def_stmt(rhs1);
107743 + if (!gimple_assign_cast_p(rhs1_def_stmt))
107744 + return rhs1;
107745 +
107746 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
107747 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
107748 +
107749 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
107750 + case GIMPLE_CALL:
107751 + case GIMPLE_NOP:
107752 + case GIMPLE_ASM:
107753 + case GIMPLE_PHI:
107754 + return def_stmt_rhs1;
107755 + case GIMPLE_ASSIGN:
107756 + return rhs1;
107757 + default:
107758 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
107759 + gcc_unreachable();
107760 + }
107761 +}
107762 +
107763 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
107764 +{
107765 + tree new_rhs, orig_rhs;
107766 + void (*gimple_assign_set_rhs)(gimple, tree);
107767 + tree rhs1 = gimple_assign_rhs1(stmt);
107768 + tree rhs2 = gimple_assign_rhs2(stmt);
107769 + tree lhs = gimple_get_lhs(stmt);
107770 +
107771 + if (!check_overflow)
107772 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107773 +
107774 + if (change_rhs == NULL_TREE)
107775 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107776 +
107777 + if (new_rhs2 == NULL_TREE) {
107778 + orig_rhs = rhs1;
107779 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
107780 + } else {
107781 + orig_rhs = rhs2;
107782 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
107783 + }
107784 +
107785 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
107786 +
107787 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
107788 + gimple_assign_set_rhs(stmt, new_rhs);
107789 + update_stmt(stmt);
107790 +
107791 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107792 +}
107793 +
107794 +static bool is_subtraction_special(const_gimple stmt)
107795 +{
107796 + gimple rhs1_def_stmt, rhs2_def_stmt;
107797 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
107798 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
107799 + const_tree rhs1 = gimple_assign_rhs1(stmt);
107800 + const_tree rhs2 = gimple_assign_rhs2(stmt);
107801 +
107802 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
107803 + return false;
107804 +
107805 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
107806 +
107807 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
107808 + return false;
107809 +
107810 + rhs1_def_stmt = get_def_stmt(rhs1);
107811 + rhs2_def_stmt = get_def_stmt(rhs2);
107812 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
107813 + return false;
107814 +
107815 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
107816 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
107817 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
107818 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
107819 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
107820 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
107821 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
107822 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
107823 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
107824 + return false;
107825 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
107826 + return false;
107827 +
107828 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
107829 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
107830 + return true;
107831 +}
107832 +
107833 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
107834 +{
107835 + tree new_rhs1, new_rhs2;
107836 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
107837 + gimple assign, stmt = get_def_stmt(lhs);
107838 + tree rhs1 = gimple_assign_rhs1(stmt);
107839 + tree rhs2 = gimple_assign_rhs2(stmt);
107840 +
107841 + if (!is_subtraction_special(stmt))
107842 + return NULL_TREE;
107843 +
107844 + new_rhs1 = expand(visited, rhs1);
107845 + new_rhs2 = expand(visited, rhs2);
107846 +
107847 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
107848 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
107849 +
107850 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
107851 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
107852 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
107853 + }
107854 +
107855 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
107856 + new_lhs = gimple_get_lhs(assign);
107857 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
107858 +
107859 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
107860 +}
107861 +
107862 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
107863 +{
107864 + const_gimple def_stmt;
107865 +
107866 + if (TREE_CODE(rhs) != SSA_NAME)
107867 + return false;
107868 +
107869 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
107870 + return false;
107871 +
107872 + def_stmt = get_def_stmt(rhs);
107873 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
107874 + return false;
107875 +
107876 + return true;
107877 +}
107878 +
107879 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
107880 +{
107881 + tree rhs1, rhs2, new_lhs;
107882 + gimple def_stmt = get_def_stmt(lhs);
107883 + tree new_rhs1 = NULL_TREE;
107884 + tree new_rhs2 = NULL_TREE;
107885 +
107886 + rhs1 = gimple_assign_rhs1(def_stmt);
107887 + rhs2 = gimple_assign_rhs2(def_stmt);
107888 +
107889 + /* no DImode/TImode division in the 32/64 bit kernel */
107890 + switch (gimple_assign_rhs_code(def_stmt)) {
107891 + case RDIV_EXPR:
107892 + case TRUNC_DIV_EXPR:
107893 + case CEIL_DIV_EXPR:
107894 + case FLOOR_DIV_EXPR:
107895 + case ROUND_DIV_EXPR:
107896 + case TRUNC_MOD_EXPR:
107897 + case CEIL_MOD_EXPR:
107898 + case FLOOR_MOD_EXPR:
107899 + case ROUND_MOD_EXPR:
107900 + case EXACT_DIV_EXPR:
107901 + case POINTER_PLUS_EXPR:
107902 + case BIT_AND_EXPR:
107903 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
107904 + default:
107905 + break;
107906 + }
107907 +
107908 + new_lhs = handle_integer_truncation(visited, lhs);
107909 + if (new_lhs != NULL_TREE)
107910 + return new_lhs;
107911 +
107912 + if (TREE_CODE(rhs1) == SSA_NAME)
107913 + new_rhs1 = expand(visited, rhs1);
107914 + if (TREE_CODE(rhs2) == SSA_NAME)
107915 + new_rhs2 = expand(visited, rhs2);
107916 +
107917 + if (is_a_neg_overflow(def_stmt, rhs2))
107918 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
107919 + if (is_a_neg_overflow(def_stmt, rhs1))
107920 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
107921 +
107922 +
107923 + if (is_a_constant_overflow(def_stmt, rhs2))
107924 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
107925 + if (is_a_constant_overflow(def_stmt, rhs1))
107926 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
107927 +
107928 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
107929 +}
107930 +
107931 +#if BUILDING_GCC_VERSION >= 4007
107932 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
107933 +{
107934 + if (is_gimple_constant(rhs))
107935 + return cast_a_tree(size_overflow_type, rhs);
107936 + if (TREE_CODE(rhs) != SSA_NAME)
107937 + return NULL_TREE;
107938 + return expand(visited, rhs);
107939 +}
107940 +
107941 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
107942 +{
107943 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
107944 + gimple def_stmt = get_def_stmt(lhs);
107945 +
107946 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
107947 +
107948 + rhs1 = gimple_assign_rhs1(def_stmt);
107949 + rhs2 = gimple_assign_rhs2(def_stmt);
107950 + rhs3 = gimple_assign_rhs3(def_stmt);
107951 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
107952 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
107953 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
107954 +
107955 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
107956 +}
107957 +#endif
107958 +
107959 +static tree get_size_overflow_type(gimple stmt, const_tree node)
107960 +{
107961 + const_tree type;
107962 + tree new_type;
107963 +
107964 + gcc_assert(node != NULL_TREE);
107965 +
107966 + type = TREE_TYPE(node);
107967 +
107968 + if (gimple_plf(stmt, MY_STMT))
107969 + return TREE_TYPE(node);
107970 +
107971 + switch (TYPE_MODE(type)) {
107972 + case QImode:
107973 + new_type = intHI_type_node;
107974 + break;
107975 + case HImode:
107976 + new_type = intSI_type_node;
107977 + break;
107978 + case SImode:
107979 + new_type = intDI_type_node;
107980 + break;
107981 + case DImode:
107982 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
107983 + new_type = intDI_type_node;
107984 + else
107985 + new_type = intTI_type_node;
107986 + break;
107987 + default:
107988 + debug_tree((tree)node);
107989 + error("%s: unsupported gcc configuration.", __func__);
107990 + gcc_unreachable();
107991 + }
107992 +
107993 + if (TYPE_QUALS(type) != 0)
107994 + return build_qualified_type(new_type, TYPE_QUALS(type));
107995 + return new_type;
107996 +}
107997 +
107998 +static tree expand_visited(gimple def_stmt)
107999 +{
108000 + const_gimple next_stmt;
108001 + gimple_stmt_iterator gsi;
108002 + enum gimple_code code = gimple_code(def_stmt);
108003 +
108004 + if (code == GIMPLE_ASM)
108005 + return NULL_TREE;
108006 +
108007 + gsi = gsi_for_stmt(def_stmt);
108008 + gsi_next(&gsi);
108009 +
108010 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
108011 + return NULL_TREE;
108012 + gcc_assert(!gsi_end_p(gsi));
108013 + next_stmt = gsi_stmt(gsi);
108014 +
108015 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
108016 + return NULL_TREE;
108017 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
108018 +
108019 + return get_lhs(next_stmt);
108020 +}
108021 +
108022 +static tree expand(struct pointer_set_t *visited, tree lhs)
108023 +{
108024 + gimple def_stmt;
108025 +
108026 + if (skip_types(lhs))
108027 + return NULL_TREE;
108028 +
108029 + def_stmt = get_def_stmt(lhs);
108030 +
108031 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
108032 + return NULL_TREE;
108033 +
108034 + if (gimple_plf(def_stmt, MY_STMT))
108035 + return lhs;
108036 +
108037 + if (pointer_set_contains(visited, def_stmt))
108038 + return expand_visited(def_stmt);
108039 +
108040 + switch (gimple_code(def_stmt)) {
108041 + case GIMPLE_PHI:
108042 + return handle_phi(visited, lhs);
108043 + case GIMPLE_CALL:
108044 + case GIMPLE_ASM:
108045 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
108046 + case GIMPLE_ASSIGN:
108047 + switch (gimple_num_ops(def_stmt)) {
108048 + case 2:
108049 + return handle_unary_ops(visited, def_stmt);
108050 + case 3:
108051 + return handle_binary_ops(visited, lhs);
108052 +#if BUILDING_GCC_VERSION >= 4007
108053 + case 4:
108054 + return handle_ternary_ops(visited, lhs);
108055 +#endif
108056 + }
108057 + default:
108058 + debug_gimple_stmt(def_stmt);
108059 + error("%s: unknown gimple code", __func__);
108060 + gcc_unreachable();
108061 + }
108062 +}
108063 +
108064 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
108065 +{
108066 + const_gimple assign;
108067 + tree orig_type = TREE_TYPE(orig_node);
108068 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108069 +
108070 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108071 + return gimple_get_lhs(assign);
108072 +}
108073 +
108074 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
108075 +{
108076 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
108077 + update_stmt(stmt);
108078 +}
108079 +
108080 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
108081 +{
108082 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
108083 + update_stmt(stmt);
108084 +}
108085 +
108086 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
108087 +{
108088 + tree arg;
108089 + const_tree origarg;
108090 +
108091 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
108092 + return true;
108093 +
108094 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
108095 + while (origarg && *argnum) {
108096 + (*argnum)--;
108097 + origarg = TREE_CHAIN(origarg);
108098 + }
108099 +
108100 + gcc_assert(*argnum == 0);
108101 +
108102 + gcc_assert(origarg != NULL_TREE);
108103 + *argnum = 0;
108104 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
108105 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
108106 + return true;
108107 + return false;
108108 +}
108109 +
108110 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
108111 +{
108112 + gimple phi = get_def_stmt(result);
108113 + unsigned int i, n = gimple_phi_num_args(phi);
108114 +
108115 + if (!phi)
108116 + return MARK_NO;
108117 +
108118 + pointer_set_insert(visited, phi);
108119 + for (i = 0; i < n; i++) {
108120 + enum mark marked;
108121 + const_tree arg = gimple_phi_arg_def(phi, i);
108122 + marked = pre_expand(visited, search_err_code, arg);
108123 + if (marked != MARK_NO)
108124 + return marked;
108125 + }
108126 + return MARK_NO;
108127 +}
108128 +
108129 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
108130 +{
108131 + gimple def_stmt = get_def_stmt(lhs);
108132 + const_tree rhs;
108133 +
108134 + if (!def_stmt)
108135 + return MARK_NO;
108136 +
108137 + rhs = gimple_assign_rhs1(def_stmt);
108138 +
108139 + def_stmt = get_def_stmt(rhs);
108140 + if (is_gimple_constant(rhs))
108141 + search_err_code[FROM_CONST] = true;
108142 +
108143 + return pre_expand(visited, search_err_code, rhs);
108144 +}
108145 +
108146 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
108147 +{
108148 + gimple def_stmt = get_def_stmt(lhs);
108149 + const_tree rhs1, rhs2;
108150 + enum mark marked;
108151 +
108152 + if (!def_stmt)
108153 + return MARK_NO;
108154 +
108155 + search_err_code[CAST_ONLY] = false;
108156 +
108157 + rhs1 = gimple_assign_rhs1(def_stmt);
108158 + rhs2 = gimple_assign_rhs2(def_stmt);
108159 + marked = pre_expand(visited, search_err_code, rhs1);
108160 + if (marked != MARK_NO)
108161 + return marked;
108162 + return pre_expand(visited, search_err_code, rhs2);
108163 +}
108164 +
108165 +static const_tree search_field_decl(const_tree comp_ref)
108166 +{
108167 + const_tree field = NULL_TREE;
108168 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
108169 +
108170 + for (i = 0; i < len; i++) {
108171 + field = TREE_OPERAND(comp_ref, i);
108172 + if (TREE_CODE(field) == FIELD_DECL)
108173 + break;
108174 + }
108175 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
108176 + return field;
108177 +}
108178 +
108179 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
108180 +{
108181 + const_tree attr, p;
108182 +
108183 + // 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);
108184 + if (fndecl == NULL_TREE)
108185 + return MARK_NO;
108186 +
108187 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
108188 + if (!attr || !TREE_VALUE(attr))
108189 + return MARK_NO;
108190 +
108191 + p = TREE_VALUE(attr);
108192 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
108193 + return MARK_TURN_OFF;
108194 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
108195 + return MARK_NOT_INTENTIONAL;
108196 + if (argnum == 0) {
108197 + gcc_assert(current_function_decl == fndecl);
108198 + return MARK_NO;
108199 + }
108200 +
108201 + do {
108202 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
108203 + return MARK_YES;
108204 + p = TREE_CHAIN(p);
108205 + } while (p);
108206 +
108207 + return MARK_NO;
108208 +}
108209 +
108210 +static void print_missing_msg(tree func, unsigned int argnum)
108211 +{
108212 + unsigned int new_hash;
108213 + size_t len;
108214 + unsigned char tree_codes[CODES_LIMIT];
108215 + location_t loc;
108216 + const char *curfunc;
108217 +
108218 + func = get_original_function_decl(func);
108219 + loc = DECL_SOURCE_LOCATION(func);
108220 + curfunc = get_asm_name(func);
108221 +
108222 + len = get_function_decl(func, tree_codes);
108223 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
108224 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
108225 +}
108226 +
108227 +static unsigned int search_missing_attribute(const_tree arg)
108228 +{
108229 + unsigned int argnum;
108230 + const struct size_overflow_hash *hash;
108231 + const_tree type = TREE_TYPE(arg);
108232 + tree func = get_original_function_decl(current_function_decl);
108233 +
108234 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
108235 +
108236 + if (TREE_CODE(type) == POINTER_TYPE)
108237 + return 0;
108238 +
108239 + argnum = find_arg_number(arg, func);
108240 + if (argnum == 0)
108241 + return 0;
108242 +
108243 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
108244 + return argnum;
108245 +
108246 + hash = get_function_hash(func);
108247 + if (!hash || !(hash->param & (1U << argnum))) {
108248 + print_missing_msg(func, argnum);
108249 + return 0;
108250 + }
108251 + return argnum;
108252 +}
108253 +
108254 +static enum mark is_already_marked(const_tree lhs)
108255 +{
108256 + unsigned int argnum;
108257 + const_tree fndecl;
108258 +
108259 + argnum = search_missing_attribute(lhs);
108260 + fndecl = get_original_function_decl(current_function_decl);
108261 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
108262 + return MARK_YES;
108263 + return MARK_NO;
108264 +}
108265 +
108266 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
108267 +{
108268 + const_gimple def_stmt;
108269 +
108270 + if (skip_types(lhs))
108271 + return MARK_NO;
108272 +
108273 + if (TREE_CODE(lhs) == PARM_DECL)
108274 + return is_already_marked(lhs);
108275 +
108276 + if (TREE_CODE(lhs) == COMPONENT_REF) {
108277 + const_tree field, attr;
108278 +
108279 + field = search_field_decl(lhs);
108280 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
108281 + if (!attr || !TREE_VALUE(attr))
108282 + return MARK_NO;
108283 + return MARK_YES;
108284 + }
108285 +
108286 + def_stmt = get_def_stmt(lhs);
108287 +
108288 + if (!def_stmt)
108289 + return MARK_NO;
108290 +
108291 + if (pointer_set_contains(visited, def_stmt))
108292 + return MARK_NO;
108293 +
108294 + switch (gimple_code(def_stmt)) {
108295 + case GIMPLE_NOP:
108296 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
108297 + return is_already_marked(lhs);
108298 + return MARK_NO;
108299 + case GIMPLE_PHI:
108300 + return walk_phi(visited, search_err_code, lhs);
108301 + case GIMPLE_CALL:
108302 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
108303 + return MARK_TURN_OFF;
108304 + check_function_hash(def_stmt);
108305 + return MARK_NO;
108306 + case GIMPLE_ASM:
108307 + search_err_code[CAST_ONLY] = false;
108308 + return MARK_NO;
108309 + case GIMPLE_ASSIGN:
108310 + switch (gimple_num_ops(def_stmt)) {
108311 + case 2:
108312 + return walk_unary_ops(visited, search_err_code, lhs);
108313 + case 3:
108314 + return walk_binary_ops(visited, search_err_code, lhs);
108315 + }
108316 + default:
108317 + debug_gimple_stmt((gimple)def_stmt);
108318 + error("%s: unknown gimple code", __func__);
108319 + gcc_unreachable();
108320 + }
108321 +}
108322 +
108323 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
108324 +static bool skip_asm(const_tree arg)
108325 +{
108326 + gimple def_stmt = get_def_stmt(arg);
108327 +
108328 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
108329 + return false;
108330 +
108331 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
108332 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
108333 +}
108334 +
108335 +/*
108336 +0</MARK_YES: no dup, search attributes (so, int)
108337 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
108338 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
108339 +*/
108340 +
108341 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
108342 +{
108343 + struct pointer_set_t *visited;
108344 + enum mark is_marked, is_found;
108345 + location_t loc;
108346 + bool search_err_code[2] = {true, false};
108347 +
108348 + is_marked = mark_status(current_function_decl, 0);
108349 + if (is_marked == MARK_TURN_OFF)
108350 + return true;
108351 +
108352 + is_marked = mark_status(fndecl, argnum + 1);
108353 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
108354 + return true;
108355 +
108356 + visited = pointer_set_create();
108357 + is_found = pre_expand(visited, search_err_code, arg);
108358 + pointer_set_destroy(visited);
108359 +
108360 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
108361 + return true;
108362 +
108363 + if (where == FROM_ARG && skip_asm(arg))
108364 + return true;
108365 +
108366 + if (is_found == MARK_TURN_OFF)
108367 + return true;
108368 +
108369 + if ((is_found == MARK_YES && is_marked == MARK_YES))
108370 + return true;
108371 +
108372 + if (is_found == MARK_YES) {
108373 + loc = DECL_SOURCE_LOCATION(fndecl);
108374 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
108375 + return true;
108376 + }
108377 + return false;
108378 +}
108379 +
108380 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
108381 +{
108382 + struct pointer_set_t *visited;
108383 + tree arg, new_arg;
108384 + bool match;
108385 +
108386 + if (argnum == 0)
108387 + return;
108388 +
108389 + argnum--;
108390 +
108391 + match = get_function_arg(&argnum, fndecl);
108392 + if (!match)
108393 + return;
108394 + gcc_assert(gimple_call_num_args(stmt) > argnum);
108395 + arg = gimple_call_arg(stmt, argnum);
108396 + if (arg == NULL_TREE)
108397 + return;
108398 +
108399 + if (skip_types(arg))
108400 + return;
108401 +
108402 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
108403 + return;
108404 +
108405 + visited = pointer_set_create();
108406 + new_arg = expand(visited, arg);
108407 + pointer_set_destroy(visited);
108408 +
108409 + if (new_arg == NULL_TREE)
108410 + return;
108411 +
108412 + change_function_arg(stmt, arg, argnum, new_arg);
108413 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
108414 +}
108415 +
108416 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
108417 +{
108418 + tree p = TREE_VALUE(attr);
108419 + do {
108420 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
108421 + p = TREE_CHAIN(p);
108422 + } while (p);
108423 +}
108424 +
108425 +static void handle_function_by_hash(gimple stmt, tree fndecl)
108426 +{
108427 + unsigned int num;
108428 + const struct size_overflow_hash *hash;
108429 +
108430 + hash = get_function_hash(fndecl);
108431 + if (!hash)
108432 + return;
108433 +
108434 + for (num = 0; num <= MAX_PARAM; num++)
108435 + if (hash->param & (1U << num))
108436 + handle_function_arg(stmt, fndecl, num);
108437 +}
108438 +
108439 +static bool check_return_value(void)
108440 +{
108441 + const struct size_overflow_hash *hash;
108442 +
108443 + hash = get_function_hash(current_function_decl);
108444 + if (!hash || !(hash->param & 1U << 0))
108445 + return false;
108446 +
108447 + return true;
108448 +}
108449 +
108450 +static void handle_return_value(gimple ret_stmt)
108451 +{
108452 + struct pointer_set_t *visited;
108453 + tree ret, new_ret;
108454 +
108455 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
108456 + return;
108457 +
108458 + ret = gimple_return_retval(ret_stmt);
108459 +
108460 + if (skip_types(ret))
108461 + return;
108462 +
108463 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
108464 + return;
108465 +
108466 + visited = pointer_set_create();
108467 + new_ret = expand(visited, ret);
108468 + pointer_set_destroy(visited);
108469 +
108470 + change_function_return(ret_stmt, ret, new_ret);
108471 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
108472 +}
108473 +
108474 +static void set_plf_false(void)
108475 +{
108476 + basic_block bb;
108477 +
108478 + FOR_ALL_BB(bb) {
108479 + gimple_stmt_iterator si;
108480 +
108481 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
108482 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
108483 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
108484 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
108485 + }
108486 +}
108487 +
108488 +static unsigned int handle_function(void)
108489 +{
108490 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
108491 + bool check_ret;
108492 +
108493 + set_plf_false();
108494 +
108495 + check_ret = check_return_value();
108496 +
108497 + do {
108498 + gimple_stmt_iterator gsi;
108499 + next = bb->next_bb;
108500 +
108501 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
108502 + tree fndecl, attr;
108503 + gimple stmt = gsi_stmt(gsi);
108504 +
108505 + if (check_ret)
108506 + handle_return_value(stmt);
108507 +
108508 + if (!(is_gimple_call(stmt)))
108509 + continue;
108510 + fndecl = gimple_call_fndecl(stmt);
108511 + if (fndecl == NULL_TREE)
108512 + continue;
108513 + if (gimple_call_num_args(stmt) == 0)
108514 + continue;
108515 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
108516 + if (!attr || !TREE_VALUE(attr))
108517 + handle_function_by_hash(stmt, fndecl);
108518 + else
108519 + handle_function_by_attribute(stmt, attr, fndecl);
108520 + gsi = gsi_for_stmt(stmt);
108521 + next = gimple_bb(stmt)->next_bb;
108522 + }
108523 + bb = next;
108524 + } while (bb);
108525 + return 0;
108526 +}
108527 +
108528 +static struct gimple_opt_pass size_overflow_pass = {
108529 + .pass = {
108530 + .type = GIMPLE_PASS,
108531 + .name = "size_overflow",
108532 +#if BUILDING_GCC_VERSION >= 4008
108533 + .optinfo_flags = OPTGROUP_NONE,
108534 +#endif
108535 + .gate = NULL,
108536 + .execute = handle_function,
108537 + .sub = NULL,
108538 + .next = NULL,
108539 + .static_pass_number = 0,
108540 + .tv_id = TV_NONE,
108541 + .properties_required = PROP_cfg,
108542 + .properties_provided = 0,
108543 + .properties_destroyed = 0,
108544 + .todo_flags_start = 0,
108545 + .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
108546 + }
108547 +};
108548 +
108549 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
108550 +{
108551 + tree fntype;
108552 +
108553 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
108554 +
108555 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
108556 + fntype = build_function_type_list(void_type_node,
108557 + const_char_ptr_type_node,
108558 + unsigned_type_node,
108559 + const_char_ptr_type_node,
108560 + const_char_ptr_type_node,
108561 + NULL_TREE);
108562 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
108563 +
108564 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
108565 + TREE_PUBLIC(report_size_overflow_decl) = 1;
108566 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
108567 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
108568 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
108569 +}
108570 +
108571 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
108572 +{
108573 + int i;
108574 + const char * const plugin_name = plugin_info->base_name;
108575 + const int argc = plugin_info->argc;
108576 + const struct plugin_argument * const argv = plugin_info->argv;
108577 + bool enable = true;
108578 +
108579 + struct register_pass_info size_overflow_pass_info = {
108580 + .pass = &size_overflow_pass.pass,
108581 + .reference_pass_name = "ssa",
108582 + .ref_pass_instance_number = 1,
108583 + .pos_op = PASS_POS_INSERT_AFTER
108584 + };
108585 +
108586 + if (!plugin_default_version_check(version, &gcc_version)) {
108587 + error(G_("incompatible gcc/plugin versions"));
108588 + return 1;
108589 + }
108590 +
108591 + for (i = 0; i < argc; ++i) {
108592 + if (!strcmp(argv[i].key, "no-size-overflow")) {
108593 + enable = false;
108594 + continue;
108595 + }
108596 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
108597 + }
108598 +
108599 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
108600 + if (enable) {
108601 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
108602 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
108603 + }
108604 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
108605 +
108606 + return 0;
108607 +}
108608 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
108609 new file mode 100644
108610 index 0000000..ac2901e
108611 --- /dev/null
108612 +++ b/tools/gcc/stackleak_plugin.c
108613 @@ -0,0 +1,327 @@
108614 +/*
108615 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
108616 + * Licensed under the GPL v2
108617 + *
108618 + * Note: the choice of the license means that the compilation process is
108619 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
108620 + * but for the kernel it doesn't matter since it doesn't link against
108621 + * any of the gcc libraries
108622 + *
108623 + * gcc plugin to help implement various PaX features
108624 + *
108625 + * - track lowest stack pointer
108626 + *
108627 + * TODO:
108628 + * - initialize all local variables
108629 + *
108630 + * BUGS:
108631 + * - none known
108632 + */
108633 +#include "gcc-plugin.h"
108634 +#include "config.h"
108635 +#include "system.h"
108636 +#include "coretypes.h"
108637 +#include "tree.h"
108638 +#include "tree-pass.h"
108639 +#include "flags.h"
108640 +#include "intl.h"
108641 +#include "toplev.h"
108642 +#include "plugin.h"
108643 +//#include "expr.h" where are you...
108644 +#include "diagnostic.h"
108645 +#include "plugin-version.h"
108646 +#include "tm.h"
108647 +#include "function.h"
108648 +#include "basic-block.h"
108649 +#include "gimple.h"
108650 +#include "rtl.h"
108651 +#include "emit-rtl.h"
108652 +
108653 +#if BUILDING_GCC_VERSION >= 4008
108654 +#define TODO_dump_func 0
108655 +#endif
108656 +
108657 +extern void print_gimple_stmt(FILE *, gimple, int, int);
108658 +
108659 +int plugin_is_GPL_compatible;
108660 +
108661 +static int track_frame_size = -1;
108662 +static const char track_function[] = "pax_track_stack";
108663 +static const char check_function[] = "pax_check_alloca";
108664 +static bool init_locals;
108665 +
108666 +static struct plugin_info stackleak_plugin_info = {
108667 + .version = "201302112000",
108668 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
108669 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
108670 +};
108671 +
108672 +static bool gate_stackleak_track_stack(void);
108673 +static unsigned int execute_stackleak_tree_instrument(void);
108674 +static unsigned int execute_stackleak_final(void);
108675 +
108676 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
108677 + .pass = {
108678 + .type = GIMPLE_PASS,
108679 + .name = "stackleak_tree_instrument",
108680 +#if BUILDING_GCC_VERSION >= 4008
108681 + .optinfo_flags = OPTGROUP_NONE,
108682 +#endif
108683 + .gate = gate_stackleak_track_stack,
108684 + .execute = execute_stackleak_tree_instrument,
108685 + .sub = NULL,
108686 + .next = NULL,
108687 + .static_pass_number = 0,
108688 + .tv_id = TV_NONE,
108689 + .properties_required = PROP_gimple_leh | PROP_cfg,
108690 + .properties_provided = 0,
108691 + .properties_destroyed = 0,
108692 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
108693 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
108694 + }
108695 +};
108696 +
108697 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
108698 + .pass = {
108699 + .type = RTL_PASS,
108700 + .name = "stackleak_final",
108701 +#if BUILDING_GCC_VERSION >= 4008
108702 + .optinfo_flags = OPTGROUP_NONE,
108703 +#endif
108704 + .gate = gate_stackleak_track_stack,
108705 + .execute = execute_stackleak_final,
108706 + .sub = NULL,
108707 + .next = NULL,
108708 + .static_pass_number = 0,
108709 + .tv_id = TV_NONE,
108710 + .properties_required = 0,
108711 + .properties_provided = 0,
108712 + .properties_destroyed = 0,
108713 + .todo_flags_start = 0,
108714 + .todo_flags_finish = TODO_dump_func
108715 + }
108716 +};
108717 +
108718 +static bool gate_stackleak_track_stack(void)
108719 +{
108720 + return track_frame_size >= 0;
108721 +}
108722 +
108723 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
108724 +{
108725 + gimple check_alloca;
108726 + tree fntype, fndecl, alloca_size;
108727 +
108728 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
108729 + fndecl = build_fn_decl(check_function, fntype);
108730 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
108731 +
108732 + // insert call to void pax_check_alloca(unsigned long size)
108733 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
108734 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
108735 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
108736 +}
108737 +
108738 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
108739 +{
108740 + gimple track_stack;
108741 + tree fntype, fndecl;
108742 +
108743 + fntype = build_function_type_list(void_type_node, NULL_TREE);
108744 + fndecl = build_fn_decl(track_function, fntype);
108745 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
108746 +
108747 + // insert call to void pax_track_stack(void)
108748 + track_stack = gimple_build_call(fndecl, 0);
108749 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
108750 +}
108751 +
108752 +#if BUILDING_GCC_VERSION == 4005
108753 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
108754 +{
108755 + tree fndecl;
108756 +
108757 + if (!is_gimple_call(stmt))
108758 + return false;
108759 + fndecl = gimple_call_fndecl(stmt);
108760 + if (!fndecl)
108761 + return false;
108762 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
108763 + return false;
108764 +// print_node(stderr, "pax", fndecl, 4);
108765 + return DECL_FUNCTION_CODE(fndecl) == code;
108766 +}
108767 +#endif
108768 +
108769 +static bool is_alloca(gimple stmt)
108770 +{
108771 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
108772 + return true;
108773 +
108774 +#if BUILDING_GCC_VERSION >= 4007
108775 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
108776 + return true;
108777 +#endif
108778 +
108779 + return false;
108780 +}
108781 +
108782 +static unsigned int execute_stackleak_tree_instrument(void)
108783 +{
108784 + basic_block bb, entry_bb;
108785 + bool prologue_instrumented = false, is_leaf = true;
108786 +
108787 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
108788 +
108789 + // 1. loop through BBs and GIMPLE statements
108790 + FOR_EACH_BB(bb) {
108791 + gimple_stmt_iterator gsi;
108792 +
108793 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
108794 + gimple stmt;
108795 +
108796 + stmt = gsi_stmt(gsi);
108797 +
108798 + if (is_gimple_call(stmt))
108799 + is_leaf = false;
108800 +
108801 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
108802 + if (!is_alloca(stmt))
108803 + continue;
108804 +
108805 + // 2. insert stack overflow check before each __builtin_alloca call
108806 + stackleak_check_alloca(&gsi);
108807 +
108808 + // 3. insert track call after each __builtin_alloca call
108809 + stackleak_add_instrumentation(&gsi);
108810 + if (bb == entry_bb)
108811 + prologue_instrumented = true;
108812 + }
108813 + }
108814 +
108815 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
108816 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
108817 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
108818 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
108819 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
108820 + return 0;
108821 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
108822 + return 0;
108823 +
108824 + // 4. insert track call at the beginning
108825 + if (!prologue_instrumented) {
108826 + gimple_stmt_iterator gsi;
108827 +
108828 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
108829 + if (dom_info_available_p(CDI_DOMINATORS))
108830 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
108831 + gsi = gsi_start_bb(bb);
108832 + stackleak_add_instrumentation(&gsi);
108833 + }
108834 +
108835 + return 0;
108836 +}
108837 +
108838 +static unsigned int execute_stackleak_final(void)
108839 +{
108840 + rtx insn, next;
108841 +
108842 + if (cfun->calls_alloca)
108843 + return 0;
108844 +
108845 + // keep calls only if function frame is big enough
108846 + if (get_frame_size() >= track_frame_size)
108847 + return 0;
108848 +
108849 + // 1. find pax_track_stack calls
108850 + for (insn = get_insns(); insn; insn = next) {
108851 + // 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))
108852 + rtx body;
108853 +
108854 + next = NEXT_INSN(insn);
108855 + if (!CALL_P(insn))
108856 + continue;
108857 + body = PATTERN(insn);
108858 + if (GET_CODE(body) != CALL)
108859 + continue;
108860 + body = XEXP(body, 0);
108861 + if (GET_CODE(body) != MEM)
108862 + continue;
108863 + body = XEXP(body, 0);
108864 + if (GET_CODE(body) != SYMBOL_REF)
108865 + continue;
108866 + if (strcmp(XSTR(body, 0), track_function))
108867 + continue;
108868 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
108869 + // 2. delete call
108870 + delete_insn_and_edges(insn);
108871 +#if BUILDING_GCC_VERSION >= 4007
108872 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
108873 + insn = next;
108874 + next = NEXT_INSN(insn);
108875 + delete_insn_and_edges(insn);
108876 + }
108877 +#endif
108878 + }
108879 +
108880 +// print_simple_rtl(stderr, get_insns());
108881 +// print_rtl(stderr, get_insns());
108882 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
108883 +
108884 + return 0;
108885 +}
108886 +
108887 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
108888 +{
108889 + const char * const plugin_name = plugin_info->base_name;
108890 + const int argc = plugin_info->argc;
108891 + const struct plugin_argument * const argv = plugin_info->argv;
108892 + int i;
108893 + struct register_pass_info stackleak_tree_instrument_pass_info = {
108894 + .pass = &stackleak_tree_instrument_pass.pass,
108895 +// .reference_pass_name = "tree_profile",
108896 + .reference_pass_name = "optimized",
108897 + .ref_pass_instance_number = 1,
108898 + .pos_op = PASS_POS_INSERT_BEFORE
108899 + };
108900 + struct register_pass_info stackleak_final_pass_info = {
108901 + .pass = &stackleak_final_rtl_opt_pass.pass,
108902 + .reference_pass_name = "final",
108903 + .ref_pass_instance_number = 1,
108904 + .pos_op = PASS_POS_INSERT_BEFORE
108905 + };
108906 +
108907 + if (!plugin_default_version_check(version, &gcc_version)) {
108908 + error(G_("incompatible gcc/plugin versions"));
108909 + return 1;
108910 + }
108911 +
108912 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
108913 +
108914 + for (i = 0; i < argc; ++i) {
108915 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
108916 + if (!argv[i].value) {
108917 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
108918 + continue;
108919 + }
108920 + track_frame_size = atoi(argv[i].value);
108921 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
108922 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
108923 + continue;
108924 + }
108925 + if (!strcmp(argv[i].key, "initialize-locals")) {
108926 + if (argv[i].value) {
108927 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
108928 + continue;
108929 + }
108930 + init_locals = true;
108931 + continue;
108932 + }
108933 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
108934 + }
108935 +
108936 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
108937 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
108938 +
108939 + return 0;
108940 +}
108941 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
108942 new file mode 100644
108943 index 0000000..4fae911
108944 --- /dev/null
108945 +++ b/tools/gcc/structleak_plugin.c
108946 @@ -0,0 +1,277 @@
108947 +/*
108948 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
108949 + * Licensed under the GPL v2
108950 + *
108951 + * Note: the choice of the license means that the compilation process is
108952 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
108953 + * but for the kernel it doesn't matter since it doesn't link against
108954 + * any of the gcc libraries
108955 + *
108956 + * gcc plugin to forcibly initialize certain local variables that could
108957 + * otherwise leak kernel stack to userland if they aren't properly initialized
108958 + * by later code
108959 + *
108960 + * Homepage: http://pax.grsecurity.net/
108961 + *
108962 + * Usage:
108963 + * $ # for 4.5/4.6/C based 4.7
108964 + * $ 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
108965 + * $ # for C++ based 4.7/4.8+
108966 + * $ 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
108967 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
108968 + *
108969 + * TODO: eliminate redundant initializers
108970 + * increase type coverage
108971 + */
108972 +
108973 +#include "gcc-plugin.h"
108974 +#include "config.h"
108975 +#include "system.h"
108976 +#include "coretypes.h"
108977 +#include "tree.h"
108978 +#include "tree-pass.h"
108979 +#include "intl.h"
108980 +#include "plugin-version.h"
108981 +#include "tm.h"
108982 +#include "toplev.h"
108983 +#include "function.h"
108984 +#include "tree-flow.h"
108985 +#include "plugin.h"
108986 +#include "gimple.h"
108987 +#include "diagnostic.h"
108988 +#include "cfgloop.h"
108989 +#include "langhooks.h"
108990 +
108991 +#if BUILDING_GCC_VERSION >= 4008
108992 +#define TODO_dump_func 0
108993 +#endif
108994 +
108995 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
108996 +
108997 +// unused type flag in all versions 4.5-4.8
108998 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
108999 +
109000 +int plugin_is_GPL_compatible;
109001 +void debug_gimple_stmt(gimple gs);
109002 +
109003 +static struct plugin_info structleak_plugin_info = {
109004 + .version = "201304082245",
109005 + .help = "disable\tdo not activate plugin\n",
109006 +};
109007 +
109008 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
109009 +{
109010 + *no_add_attrs = true;
109011 +
109012 + // check for types? for now accept everything linux has to offer
109013 + if (TREE_CODE(*node) != FIELD_DECL)
109014 + return NULL_TREE;
109015 +
109016 + *no_add_attrs = false;
109017 + return NULL_TREE;
109018 +}
109019 +
109020 +static struct attribute_spec user_attr = {
109021 + .name = "user",
109022 + .min_length = 0,
109023 + .max_length = 0,
109024 + .decl_required = false,
109025 + .type_required = false,
109026 + .function_type_required = false,
109027 + .handler = handle_user_attribute,
109028 +#if BUILDING_GCC_VERSION >= 4007
109029 + .affects_type_identity = true
109030 +#endif
109031 +};
109032 +
109033 +static void register_attributes(void *event_data, void *data)
109034 +{
109035 + register_attribute(&user_attr);
109036 +// register_attribute(&force_attr);
109037 +}
109038 +
109039 +static tree get_field_type(tree field)
109040 +{
109041 + return strip_array_types(TREE_TYPE(field));
109042 +}
109043 +
109044 +static bool is_userspace_type(tree type)
109045 +{
109046 + tree field;
109047 +
109048 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
109049 + tree fieldtype = get_field_type(field);
109050 + enum tree_code code = TREE_CODE(fieldtype);
109051 +
109052 + if (code == RECORD_TYPE || code == UNION_TYPE)
109053 + if (is_userspace_type(fieldtype))
109054 + return true;
109055 +
109056 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
109057 + return true;
109058 + }
109059 + return false;
109060 +}
109061 +
109062 +static void finish_type(void *event_data, void *data)
109063 +{
109064 + tree type = (tree)event_data;
109065 +
109066 + if (TYPE_USERSPACE(type))
109067 + return;
109068 +
109069 + if (is_userspace_type(type))
109070 + TYPE_USERSPACE(type) = 1;
109071 +}
109072 +
109073 +static void initialize(tree var)
109074 +{
109075 + basic_block bb;
109076 + gimple_stmt_iterator gsi;
109077 + tree initializer;
109078 + gimple init_stmt;
109079 +
109080 + // this is the original entry bb before the forced split
109081 + // TODO: check further BBs in case more splits occured before us
109082 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
109083 +
109084 + // first check if the variable is already initialized, warn otherwise
109085 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
109086 + gimple stmt = gsi_stmt(gsi);
109087 + tree rhs1;
109088 +
109089 + // we're looking for an assignment of a single rhs...
109090 + if (!gimple_assign_single_p(stmt))
109091 + continue;
109092 + rhs1 = gimple_assign_rhs1(stmt);
109093 +#if BUILDING_GCC_VERSION >= 4007
109094 + // ... of a non-clobbering expression...
109095 + if (TREE_CLOBBER_P(rhs1))
109096 + continue;
109097 +#endif
109098 + // ... to our variable...
109099 + if (gimple_get_lhs(stmt) != var)
109100 + continue;
109101 + // if it's an initializer then we're good
109102 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
109103 + return;
109104 + }
109105 +
109106 + // these aren't the 0days you're looking for
109107 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
109108 +
109109 + // build the initializer expression
109110 + initializer = build_constructor(TREE_TYPE(var), NULL);
109111 +
109112 + // build the initializer stmt
109113 + init_stmt = gimple_build_assign(var, initializer);
109114 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
109115 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
109116 + update_stmt(init_stmt);
109117 +}
109118 +
109119 +static unsigned int handle_function(void)
109120 +{
109121 + basic_block bb;
109122 + unsigned int ret = 0;
109123 + tree var;
109124 +
109125 +#if BUILDING_GCC_VERSION == 4005
109126 + tree vars;
109127 +#else
109128 + unsigned int i;
109129 +#endif
109130 +
109131 + // split the first bb where we can put the forced initializers
109132 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
109133 + if (dom_info_available_p(CDI_DOMINATORS))
109134 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
109135 +
109136 + // enumarate all local variables and forcibly initialize our targets
109137 +#if BUILDING_GCC_VERSION == 4005
109138 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
109139 + var = TREE_VALUE(vars);
109140 +#else
109141 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
109142 +#endif
109143 + tree type = TREE_TYPE(var);
109144 +
109145 + gcc_assert(DECL_P(var));
109146 + if (!auto_var_in_fn_p(var, current_function_decl))
109147 + continue;
109148 +
109149 + // only care about structure types
109150 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
109151 + continue;
109152 +
109153 + // if the type is of interest, examine the variable
109154 + if (TYPE_USERSPACE(type))
109155 + initialize(var);
109156 + }
109157 +
109158 + return ret;
109159 +}
109160 +
109161 +static struct gimple_opt_pass structleak_pass = {
109162 + .pass = {
109163 + .type = GIMPLE_PASS,
109164 + .name = "structleak",
109165 +#if BUILDING_GCC_VERSION >= 4008
109166 + .optinfo_flags = OPTGROUP_NONE,
109167 +#endif
109168 + .gate = NULL,
109169 + .execute = handle_function,
109170 + .sub = NULL,
109171 + .next = NULL,
109172 + .static_pass_number = 0,
109173 + .tv_id = TV_NONE,
109174 + .properties_required = PROP_cfg,
109175 + .properties_provided = 0,
109176 + .properties_destroyed = 0,
109177 + .todo_flags_start = 0,
109178 + .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
109179 + }
109180 +};
109181 +
109182 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
109183 +{
109184 + int i;
109185 + const char * const plugin_name = plugin_info->base_name;
109186 + const int argc = plugin_info->argc;
109187 + const struct plugin_argument * const argv = plugin_info->argv;
109188 + bool enable = true;
109189 +
109190 + struct register_pass_info structleak_pass_info = {
109191 + .pass = &structleak_pass.pass,
109192 + .reference_pass_name = "ssa",
109193 + .ref_pass_instance_number = 1,
109194 + .pos_op = PASS_POS_INSERT_AFTER
109195 + };
109196 +
109197 + if (!plugin_default_version_check(version, &gcc_version)) {
109198 + error(G_("incompatible gcc/plugin versions"));
109199 + return 1;
109200 + }
109201 +
109202 + if (strcmp(lang_hooks.name, "GNU C")) {
109203 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
109204 + enable = false;
109205 + }
109206 +
109207 + for (i = 0; i < argc; ++i) {
109208 + if (!strcmp(argv[i].key, "disable")) {
109209 + enable = false;
109210 + continue;
109211 + }
109212 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
109213 + }
109214 +
109215 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
109216 + if (enable) {
109217 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
109218 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
109219 + }
109220 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
109221 +
109222 + return 0;
109223 +}
109224 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
109225 index 926cbf3..b8403e0 100644
109226 --- a/tools/lib/lk/Makefile
109227 +++ b/tools/lib/lk/Makefile
109228 @@ -10,7 +10,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
109229
109230 LIBFILE = liblk.a
109231
109232 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
109233 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
109234 EXTLIBS = -lpthread -lrt -lelf -lm
109235 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
109236 ALL_LDFLAGS = $(LDFLAGS)
109237 diff --git a/tools/perf/Makefile b/tools/perf/Makefile
109238 index b0f164b..63c9f7d 100644
109239 --- a/tools/perf/Makefile
109240 +++ b/tools/perf/Makefile
109241 @@ -188,7 +188,7 @@ endif
109242
109243 ifndef PERF_DEBUG
109244 ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y)
109245 - CFLAGS := $(CFLAGS) -D_FORTIFY_SOURCE=2
109246 + CFLAGS := $(CFLAGS) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
109247 endif
109248 endif
109249
109250 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
109251 index 6789d78..4afd019e 100644
109252 --- a/tools/perf/util/include/asm/alternative-asm.h
109253 +++ b/tools/perf/util/include/asm/alternative-asm.h
109254 @@ -5,4 +5,7 @@
109255
109256 #define altinstruction_entry #
109257
109258 + .macro pax_force_retaddr rip=0, reload=0
109259 + .endm
109260 +
109261 #endif
109262 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
109263 index 96b919d..c49bb74 100644
109264 --- a/tools/perf/util/include/linux/compiler.h
109265 +++ b/tools/perf/util/include/linux/compiler.h
109266 @@ -18,4 +18,12 @@
109267 #define __force
109268 #endif
109269
109270 +#ifndef __size_overflow
109271 +# define __size_overflow(...)
109272 +#endif
109273 +
109274 +#ifndef __intentional_overflow
109275 +# define __intentional_overflow(...)
109276 +#endif
109277 +
109278 #endif
109279 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
109280 index 302681c..3bde377 100644
109281 --- a/virt/kvm/kvm_main.c
109282 +++ b/virt/kvm/kvm_main.c
109283 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
109284
109285 static cpumask_var_t cpus_hardware_enabled;
109286 static int kvm_usage_count = 0;
109287 -static atomic_t hardware_enable_failed;
109288 +static atomic_unchecked_t hardware_enable_failed;
109289
109290 struct kmem_cache *kvm_vcpu_cache;
109291 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
109292
109293 -static __read_mostly struct preempt_ops kvm_preempt_ops;
109294 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
109295 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
109296 +static struct preempt_ops kvm_preempt_ops = {
109297 + .sched_in = kvm_sched_in,
109298 + .sched_out = kvm_sched_out,
109299 +};
109300
109301 struct dentry *kvm_debugfs_dir;
109302
109303 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
109304 /* We can read the guest memory with __xxx_user() later on. */
109305 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
109306 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
109307 - !access_ok(VERIFY_WRITE,
109308 + !__access_ok(VERIFY_WRITE,
109309 (void __user *)(unsigned long)mem->userspace_addr,
109310 mem->memory_size)))
109311 goto out;
109312 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
109313 return 0;
109314 }
109315
109316 -static struct file_operations kvm_vcpu_fops = {
109317 +static file_operations_no_const kvm_vcpu_fops __read_only = {
109318 .release = kvm_vcpu_release,
109319 .unlocked_ioctl = kvm_vcpu_ioctl,
109320 #ifdef CONFIG_COMPAT
109321 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
109322 return 0;
109323 }
109324
109325 -static struct file_operations kvm_vm_fops = {
109326 +static file_operations_no_const kvm_vm_fops __read_only = {
109327 .release = kvm_vm_release,
109328 .unlocked_ioctl = kvm_vm_ioctl,
109329 #ifdef CONFIG_COMPAT
109330 @@ -2662,7 +2667,7 @@ out:
109331 return r;
109332 }
109333
109334 -static struct file_operations kvm_chardev_ops = {
109335 +static file_operations_no_const kvm_chardev_ops __read_only = {
109336 .unlocked_ioctl = kvm_dev_ioctl,
109337 .compat_ioctl = kvm_dev_ioctl,
109338 .llseek = noop_llseek,
109339 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
109340
109341 if (r) {
109342 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
109343 - atomic_inc(&hardware_enable_failed);
109344 + atomic_inc_unchecked(&hardware_enable_failed);
109345 printk(KERN_INFO "kvm: enabling virtualization on "
109346 "CPU%d failed\n", cpu);
109347 }
109348 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
109349
109350 kvm_usage_count++;
109351 if (kvm_usage_count == 1) {
109352 - atomic_set(&hardware_enable_failed, 0);
109353 + atomic_set_unchecked(&hardware_enable_failed, 0);
109354 on_each_cpu(hardware_enable_nolock, NULL, 1);
109355
109356 - if (atomic_read(&hardware_enable_failed)) {
109357 + if (atomic_read_unchecked(&hardware_enable_failed)) {
109358 hardware_disable_all_nolock();
109359 r = -EBUSY;
109360 }
109361 @@ -3099,7 +3104,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
109362 kvm_arch_vcpu_put(vcpu);
109363 }
109364
109365 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
109366 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
109367 struct module *module)
109368 {
109369 int r;
109370 @@ -3146,7 +3151,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
109371 if (!vcpu_align)
109372 vcpu_align = __alignof__(struct kvm_vcpu);
109373 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
109374 - 0, NULL);
109375 + SLAB_USERCOPY, NULL);
109376 if (!kvm_vcpu_cache) {
109377 r = -ENOMEM;
109378 goto out_free_3;
109379 @@ -3156,9 +3161,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
109380 if (r)
109381 goto out_free;
109382
109383 + pax_open_kernel();
109384 kvm_chardev_ops.owner = module;
109385 kvm_vm_fops.owner = module;
109386 kvm_vcpu_fops.owner = module;
109387 + pax_close_kernel();
109388
109389 r = misc_register(&kvm_dev);
109390 if (r) {
109391 @@ -3168,9 +3175,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
109392
109393 register_syscore_ops(&kvm_syscore_ops);
109394
109395 - kvm_preempt_ops.sched_in = kvm_sched_in;
109396 - kvm_preempt_ops.sched_out = kvm_sched_out;
109397 -
109398 r = kvm_init_debug();
109399 if (r) {
109400 printk(KERN_ERR "kvm: create debugfs files failed\n");